zsh & bash 不同
zsh 和 shell 基本上兼容, 但也有好多不同, 在安装 o-my-zsh
后, 需要在 .zshrc
中添加 source ~/.bash_profile
才能正常使用之前的脚本哈.
不同
if 判断
bash 使用两个等号
[ "1" == "1" ] echo "equals.";
zsh 使用一个等号
if [ "$foo" = "" ];
then
echo "foo is empty!"
exit
fi
function
bash 中可省略 function 声明
zsh 中, 必须显式声明
改变后的 bash
# just env path
# export JAVA_HOME=/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
export CLASSPATH=JAVA_HOME/lib
export PATH=/Users/zhoukeke/.just-installs/bin:$JAVA_HOME/bin:$PATH
#export PATH=/Users/zhoukeke/.just-installs/bin:$PATH
#test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"
alias ip="ifconfig | grep -o \"30\.\d*\.\d*.\d* \" | awk '{\$1=\$1};1' | pbcopy"
alias sip="ifconfig | grep -o \"30\.\d*\.\d*.\d* \" | awk '{\$1=\$1};1'"
alias br="source ~/.bash_profile"
# GIT
alias gs="git status"
# Difference in zsh & original terminal
# use = in zsh terminal & use == in origin terminal
# you have to add string `function` before function in zsh.
function gp() {
if [ "$1" = "" ]; then
git push
else
git push --set-upstream origin $1
fi
}
function gb2() {
echo "git checkout -b daily/$1"
git checkout -b "daily/$1"
}
function commit() {
echo "git add ."
git add .
if [ "$1" = "" ]; then
echo "git commit -m 'Update Code'"
git commit -m "Update Code"
else
echo "git commit -m '$1'"
git commit -m "$1"
fi
}
function setnpm() {
if [ "$1" = "alibaba" ]; then
echo "set npm to [alibaba]"
npm config set registry http://registry.npm.alibaba-inc.com
elif [ "$1" = "npm" ]; then
echo "set npm to [npm]"
npm config delete registry
else
echo "set npm to [taobao]"
npm config set registry https://registry.npm.taobao.org
fi
echo ""
echo "===== Current NPM Config ===="
echo ""
npm config list
}
Comments
Leave a comment