2020年12月11日 星期五

MacOS Git auto completion, bash and zsh

最近換電腦在安裝 git auto completion,按照之前的設定使用 brew install bash-completion,但怎麼做都沒用,後來才發現,原來 macOS terminal 的 default login shell 從 2019 的 Catalina 版本就已經改成 Zsh

In 2019, macOS Catalina adopted Zsh as the default login shell, replacing the aging GPLv2 licensed version of Bash, and when Bash is run interactively on Catalina, a warning is shown by default.

那解決方式有三種

  1. 將 default login shell 改回 bash
  2. 改為使用 zsh-completions
  3. 使用 zsh 自帶的 tab-completion library

第一種方式怎麼改呢?
要進入 系統偏好設定 -> 使用者與群組 按右下角解除鎖頭後,在使用者上按右鍵,點選進階選項,就可以看到登入 shell 的下拉選單。





第二種方式其實就是 brew install zsh-completions,官方的教學就滿清楚的,請參考這裡


第三種是只要在 ~/.zshrc 的檔案裡加上這一行,再重啟 terminal 就好了。

autoload -Uz compinit && compinit

如果不行就試試 force rebuild zcompdump

rm -f ~/.zcompdump; compinit

沒有留言:

張貼留言