Contents

mac

Mac 优化

1、mac终端增加颜色,参考centos7

eval "$(/opt/homebrew/bin/brew shellenv)"

# Setting PATH for Python 3.9
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}"

export PG_HOME=/opt/homebrew/Cellar/postgresql@10/10.17
export PATH
export GOPROXY=https://goproxy.cn,direct
export GOPATH=/Users/sugar/go
export GO111MODULE="on"
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOROOT/bin:$GOBIN:$PG_HOME/bin

# 参考RHEL console
export PS1="[\u@\h \W]\\$ "
export CLICOLOR=1
export LSCOLORS=ExGxFxdaCxDaDahbadeche
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

2、安装homebrew

参考:http://mirrors.ustc.edu.cn/help/brew.git.html

配置环境变量

[sugar@localhost ~]$ cat ~/.bash_profile
# brew 安装其他目录下才需要设置
#eval "$(/opt/homebrew/bin/brew shellenv)"

export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"

安装

/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/Homebrew/install@HEAD/install.sh)"

3、去除自动生成.DS_Store文件

  • .DS_StoreMac OS保存文件夹的自定义属性的隐藏文件,如文件的图标位置或背景色,相当于Windowsdesktop.ini

1)禁止.DS_Store文件的生成:

defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE

2)恢复.DS_Store文件的生成

defaults delete com.apple.desktopservices DSDontWriteNetworkStores

3)删除磁盘上的 .DS_Store,删除当前目录及其子目录下的所有.DS_Store 文件:

sudo find . -name '*.DS_Store' -type f -delete

最后重启电脑即可生效!

4、环境变量

eval "$(/opt/homebrew/bin/brew shellenv)"


export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"

export PG_HOME=/opt/homebrew/Cellar/postgresql@10/10.17
export GOPROXY=https://goproxy.cn,direct
export GOPATH=/Users/sugar/go
export GO111MODULE="on"
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOROOT/bin:$GOBIN:$PG_HOME/bin
export GOPRIVATE="local.com,gitee.com/cccccc"
export GOINSECURE="local.com"
#export CGO_ENABLED="0"

#export PS1='[\u@\h \W]\$ '

export  PS1="[\u@\h \W]\\$ "

export CLICOLOR=1
export LSCOLORS=ExGxFxdaCxDaDahbadeche

export LC_ALL=en_US.UTF-8

export LANG=en_US.UTF-8


function k8s-local(){
    unset KUBECONFIG
    export KUBECONFIG=~/.kube/kubeconfig-local.json
    kubectl cluster-info
    kubectl get namespace
}


function k8s-1(){
    unset KUBECONFIG
    export KUBECONFIG=~/.kube/kubeconfig-1.json
    kubectl cluster-info
    kubectl get namespace
}





alias ll='ls -l'
alias lh='ls -lh'


#UserIP=$(who -u am i | cut -d"("  -f 2 | sed -e "s/[()]//g")
export HISTTIMEFORMAT="[%F %T] [`whoami`] "
export HISTSIZE=99999

export HISTFILESIZE=550


# socket5 
proxy(){
export http_proxy="http://127.0.0.1:5559"
export https_proxy="http://127.0.0.1:5559"  

# 设置代理
networksetup -setwebproxy Wi-Fi 127.0.0.1 5559
networksetup -setsecurewebproxy Wi-Fi 127.0.0.1 5559
networksetup -setsocksfirewallproxy Wi-Fi 127.0.0.1 5558

# 打开系统代理
networksetup -setwebproxystate Wi-Fi on
networksetup -setsecurewebproxystate Wi-Fi on
networksetup -setsocksfirewallproxystate Wi-Fi on
~/Desktop/v2cc/proxy
}

# 取消设置的代理
noproxy(){
unset http_proxy
unset https_proxy 
networksetup -setwebproxystate Wi-Fi off
networksetup -setsecurewebproxystate Wi-Fi off
networksetup -setsocksfirewallproxystate Wi-Fi off
}


export PATH="/opt/homebrew/opt/icu4c/bin:$PATH"
export PATH="/opt/homebrew/opt/icu4c/sbin:$PATH"

#For compilers to find icu4c you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/icu4c/lib"
export CPPFLAGS="-I/opt/homebrew/opt/icu4c/include"

#For pkg-config to find icu4c you may need to set:
export PKG_CONFIG_PATH="/opt/homebrew/opt/icu4c/lib/pkgconfig"
export PATH="/opt/homebrew/opt/node@14/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/node@14/lib"
export CPPFLAGS="-I/opt/homebrew/opt/node@14/include"

5、使用bash-completion补全

bash-completion部分已经不兼容,需要使用v2版

brew install bash-completion@2
vim ~/.bash_profile

# use bash-completion
export BASH_COMPLETION_COMPAT_DIR="/opt/homebrew/etc/bash_completion.d"
[[ -r "/opt/homebrew/etc/profile.d/bash_completion.sh" ]] && . "/opt/homebrew/etc/profile.d/bash_completion.sh"

6、kubectl命令补齐

vim ~/.bash_profile

kubectl completion bash > /opt/homebrew/etc/bash_completion.d/kubectl

# 设置别名
echo 'alias k=kubectl' >>~/.bash_profile
echo 'complete -o default -F __start_kubectl k' >>~/.bash_profile

7、应用下载网站

http://mac-torrent-download.net/
https://www.torrentmac.net/
https://mac-torrents.io/

8 、软件出现 【xxxxx将对您的电脑造成伤害,您应该将它移动到废纸篓】

# 切换到软件或者cmd所在的目录
codesign -f -s - --deep xxxx_app_name

# 例如
codesign -f -s - --deep terraform

9、安装“Chromium”已损坏,无法打开。 您应该将它移到废纸篓。

# 因为签名不造成的,执行以下命令
sudo xattr -cr /Applications/Chromium.app

10、配置github代理

# http || https
# Host github.com
#   User git
#   ProxyCommand nc -v -x 127.0.0.1:5559 %h %p
Host github.com
  User git
  ProxyCommand nc -v -x 127.0.0.1:5558 %h %p