未分类
oh-my-zsh出现的问题
由于之前的VPS到期了,又买了台VPS,想打造成高逼格的开发环境,结果在装上oh-my-zsh后,.zshrc配置如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
ZSH_CUSTOM=/home/sean/.oh-my-zsh/custom plugins=( git git-extras autojump zsh-syntax-highlighting zsh-autosuggestions osx extract dirhistory ) [[ -s /home/sean/.autojump/etc/profile.d/autojump.sh ]] && source /home/sean/.autojump/etc/profile.d/autojump.sh source $ZSH_CUSTOM/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh source $ZSH_CUSTOM/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh |
装了几个插件后,就出现了各种报错,如下只粘了一条,各种命令找不到:
1 |
/home/user/.oh-my-zsh/plugins/git/git.plugin.zsh:170: command not found: compdef |
根据经验,应该是PATH设置得不对,但是无论怎么设置,就是不行。 后来各种google,终于找到了解决办法:
1 |
chmod a-r /etc/profile.d/autojump.sh |
一大堆报错没了,但又有了新报错:
1 2 3 4 |
/etc/bashrc:37: command not found: shopt omz_history:fc:13: no such event: 1 /etc/bashrc:40: command not found: shopt /etc/bashrc:51: command not found: shopt |
shopt报错的原因为:
1 2 3 4 5 6 |
shopt is not a command, but a shell built-in. You can find out this by running the following command in bash: type shopt output would be: shopt is a shell builtin |
解决方法:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
solution: step1: printf "#!/bin/bash\n\nshopt \$*\n" > /usr/local/bin/shopt then you will get /usr/local/bin/shopt: #!/bin/bash shopt $* step2: chmod +x /usr/local/bin/shopt step3: ln -s /usr/local/bin/shopt /usr/bin/shopt step4: echo "alias shopt='/usr/bin/shopt'" >> ~/.zshrc |
其中升级zsh命令为:
1 |
upgrade_oh_my_zsh |
2019-05-21: 今天发现, 上下方向键不能搜索命令历史了, 后来统一在如下文件里定义(可以放到~/.oh-my-zsh/lib/key-bindings.zsh , 但是为了好管理, 还是统一放到.zshrc里):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
[~]$ tail -n30 ~/.zshrc # # Keypad --added by Sean bindkey '\e[A' history-beginning-search-backward bindkey '\e[B' history-beginning-search-forward # Home bindkey '\e[1~' beginning-of-line # End bindkey '\e[4~' end-of-line bindkey -s "^[Op" "0" bindkey -s "^[Ol" "." bindkey -s "^[OM" "^M" # 1 2 3 bindkey -s "^[Oq" "1" bindkey -s "^[Or" "2" bindkey -s "^[Os" "3" # 4 5 6 bindkey -s "^[Ot" "4" bindkey -s "^[Ou" "5" bindkey -s "^[Ov" "6" # 7 8 9 bindkey -s "^[Ow" "7" bindkey -s "^[Ox" "8" bindkey -s "^[Oy" "9" # + - * / bindkey -s "^[Ok" "+" bindkey -s "^[Om" "-" bindkey -s "^[Oj" "*" bindkey -s "^[Oo" "/" |