我有一个问题,如何告诉用户正在使用的shell。假设一个脚本,如果用户正在使用zsh,然后把PATH他的.zshrc和如果使用bash应放在.bashrc。并相应地设置rvmrc。
#!/usr/bin/env bash
export PATH='/usr/local/bin:$PATH'" >> ~/.zshrc
source ~/.zshrc
我试过以下,但它不工作:(
if [[ $0 == "bash ]]; then
export PATH='/usr/local/bin:$PATH'" >> ~/.bashrc
elif [[ $0 == "zsh" ]]; then
export PATH='/usr/local/bin:$PATH'" >> ~/.zshrc
fi
# ... more commands ...
if [[ $0 == "bash ]]; then
[[ -s '/Users/`whoami`/.rvm/scripts/rvm' ]] && source '/Users/`whoami`/.rvm/scripts/rvm'" >> ~/.bashrc
source ~/.bashrc
elif [[ $0 == "zsh" ]]; then
[[ -s '/Users/`whoami`/.rvm/scripts/rvm' ]] && source '/Users/`whoami`/.rvm/scripts/rvm'" >> ~/.zshrc
source ~/.zshrc
fi
最后
以上就是笨笨小鸽子最近收集整理的关于linux查看是bash还是zsh,如何判断它是否使用zsh或bash的全部内容,更多相关linux查看是bash还是zsh内容请搜索靠谱客的其他文章。
发表评论 取消回复