我自己用bash_profile主要用来将常用的命令简写,更改一些主要信息的颜色。
alias ll='ls -al'
alias ng='sudo nginx'
alias ngr='sudo nginx -s reload'
alias ngs='sudo nginx -s stop & sudo nginx'
alias cl='clear'
alias tcp='lsof -n -P -i TCP -s TCP:LISTEN'
alias ipconfig='ifconfig | grep "inet " | grep -v 127.0.0.1'
alias maven='mvn clean package -Dmaven.test.skip=true'
alias cp='git cherry-pick'
alias gp='git push'
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
alias proxy='sudo /usr/local/sbin/privoxy /usr/local/etc/privoxy/config'
function proxy_on() {
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
export http_proxy="http://127.0.0.1:1087"
export https_proxy="http://127.0.0.1:1087"
echo -e "已开启代理"
}
function proxy_off(){
unset http_proxy
unset https_proxy
echo -e "已关闭代理"
}
1、打开terminal(终端)
2、cd ~
3、open .bash_profile (打开.bash_profile文件,如果文件不存在就 创建文件:touch .bash_profile 编辑文件:open -e bash_profile)
4、直接更改弹出的.bash_profile文件内容
5、command + s 保存文件,然后关闭
6、在terminal(终端)中输入 source .bash_profile (使用刚才更新之后的内容)//很重要的一步哟
贴上我目前的配置:
alias ng='sudo nginx'
alias ngr='sudo nginx -s reload'
alias ngs='sudo nginx -s stop & sudo nginx'
alias cl='clear'
alias tcp='lsof -n -P -i TCP -s TCP:LISTEN'
alias ipconfig='ifconfig | grep "inet " | grep -v 127.0.0.1'
alias maven='mvn clean package -Dmaven.test.skip=true'
alias cp='git cherry-pick'
alias gp='git push'
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
alias proxy='sudo /usr/local/sbin/privoxy /usr/local/etc/privoxy/config'
function proxy_on() {
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
export http_proxy="http://127.0.0.1:1087"
export https_proxy="http://127.0.0.1:1087"
echo -e "已开启代理"
}
function proxy_off(){
unset http_proxy
unset https_proxy
echo -e "已关闭代理"
}