0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Macのターミナル, zshのカスタマイズ

0
Posted at
  1. zinitのインストール

    bash -c "$(curl --fail --show-error --silent --location https://raw.githubusercontent.com/zdharma-continuum/zinit/HEAD/scripts/install.sh)"
    

    exec zshでシェルを再起動。

    zinit self-update
    

    でzinitを初期化, ~/.zshrc の末尾にzinitのロード設定が書いてあることを確認する。

  2. zinit経由でプラグインをインストール

    ~/.zshrc の末尾に以下を記述。

    .zshrc
    zinit light zsh-users/zsh-autosuggestions
    zinit light zsh-users/zsh-completions
    zinit light zsh-users/zsh-syntax-highlighting   
    

    exec zshでシェルを再起動したタイミングでプラグインは ~/.local/share/zinit/plugins/ にインストールされる。

    オプションやサブコマンドの補完を有効化する。

    .zshrc
    autoload -Uz compinit
    compinit
    
  3. starshipを導入

    brew install starship
    

    ~/.zshrc の末尾に以下を記述。

    .zshrc
    # Initialize Starship prompt
    eval "$(starship init zsh)"
    

    exec zshでシェルを再起動。

  4. モダンなlsコマンド。ezaをいれる。

    brew install eza
    

    この後に
    以下からNerdFontを好きなものをダウンロードしてFontBookで登録する。
    https://www.nerdfonts.com/font-downloads

    そして,ターミナルにフォントを設定する。
    VS codeのターミナルを使っている人は以下も設定する。

    settings.json
      "terminal.integrated.fontFamily": "'0xProto Nerd Font'"
    

    lsコマンドをオーバーライドする。

    .zshrc
    # Use eza instead of ls
    alias ls='eza --icons --group-directories-first --color=always'
    alias ll='eza -lh --icons --group-directories-first'
    alias la='eza -lha --icons --group-directories-first'
    

    treeコマンドも定義しておくと便利。

    .zshrc
    alias tree='eza --tree --icons --group-directories-first'
    alias lt='eza --tree --git-ignore --icons --group-directories-first'
    
  5. touch ~/.hushlogin で ログインメッセージを一切非表示 にする。

ここからは+αの設定

  1. fzf-tabを入れる。

    brew install fzf
    

    zinitでプラグイン追加。

    .zshrc
    zinit light Aloxaf/fzf-tab
    

    ezaと色を合わせるため以下の設定を追加。

    .zshrc
    # --- fzf-tab preview with eza and bat ---
    zstyle ':fzf-tab:*' fzf-preview ''
    zstyle ':fzf-tab:*' fzf-flags --preview-window=hidden
    
    zstyle ':fzf-tab:complete:(cd|ls|cat|less|vim|nvim|nano|emacs|code|bat|exa|eza|cp|mv|rm):*' fzf-preview '[[ -d $realpath ]] && eza --color=always --icons --tree -L 1 --git-ignore --group-directories-first -- $realpath || bat --style=numbers --color=always --line-range=:400 -- $realpath 2>/dev/null || head -400 -- $realpath'
    
    zstyle ':fzf-tab:complete:(cd|ls|cat|less|vim|nvim|nano|emacs|code|bat|exa|eza|cp|mv|rm):*' fzf-flags --preview-window='right:50%:wrap'
    
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?