Skip to main content

zsh

# 使用相同的配置
echo source ~/.bash_profile >> ~/.zshenv && source ~/.zshenv

echo $ZSH_VERSION
realpath $SHELL
man zshcontrib
featurezshbash
Automatic cd
Recursive path expansion
Spelling correction and approximate completion
Plugin and theme suppor

Awesome

git clone https://github.com/zsh-users/zsh-syntax-highlighting ~/.zsh/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions

git clone https://github.com/larkery/zsh-histdb ~/.zsh/zsh-histdb

FAQ

# 历史搜索
autoload -U up-line-or-beginning-search
autoload -U down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search

bindkey "^[[A" up-line-or-beginning-search # Up
bindkey "^[[B" down-line-or-beginning-search # Down

Why ZSH

  • Pros
    • macOS 默认 Shell
    • 用户友好
  • Cons
    • 大多 ZSH 有的特性 Bash 也有
      • 但 zsh 可能支持的更完善
    • 大多服务器环境都是 Bash 或 POSIX Shell
      • 平时使用 bash 更利于服务端编码
      • 过多使用 zsh 相关特性会产生依赖

CORRECT vs CORRECT_ALL

  • CORRECT
    • 仅针对命令
  • CORRECT_ALL
    • 会检查整个命令行
    • 会矫正参数 - 例如文件名