1
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?

UbuntuにZsh+sheldonを導入

Last updated at Posted at 2025-09-07

概要

UbuntuにZshを導入した時の手順を残します。
設定はシンプルにしたいけれど、補完は効いて欲しいという人向け。
sheldonを使ってプラグインの管理を行います。

導入するもの

  • zsh
  • sheldon : zshやbashのプラグイン管理ツール
  • zsh-autosuggestions : 履歴からコマンド補完
  • zsh-syntax-highlighting : コマンドの構文を色分け
  • zsh-completions : 標準より多くのコマンド補完

手順

1. Zshのインストール

sudo apt update
sudo apt install zsh -y

2. デフォルトシェルをZshに変更

cat /etc/shells
# 上のコマンドの結果からzshのパスを確認し以下で設定
chsh -s /bin/zsh
# ~/.local/binにパスが通っていなければ以下で設定(後のsheldon実行に必要)
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshenv
# エディタはvim (個人の好み)
echo 'export EDITOR=vim' >> ~/.zshenv 
  • 変更後、再ログインするとZshが有効になります

3. sheldonインストール

curl --proto '=https' -fLsS https://rossmacarthur.github.io/install/crate.sh \
    | bash -s -- --repo rossmacarthur/sheldon --to ~/.local/bin
  • ビルド済みバイナリをインストールします
  • この方法はLinux (x86-64, aarch64, armv7) and macOS (x86-64) のみ可能につき、
    他の導入方法を知りたい場合は GitHubのREADME を参照下さい

4. Zshプラグイン登録(sheldon)

# sheldonの初期化 (ファイル名を聞かれたら y を押す)
sheldon init --shell zsh

# sheldonが管理するプラグインの読込み設定追加
echo 'eval "$(sheldon source)"' >> ~/.zshrc

# プラグイン登録
sheldon add zsh-autosuggestions --github zsh-users/zsh-autosuggestions 
sheldon add zsh-syntax-highlighting --github zsh-users/zsh-syntax-highlighting 
sheldon add zsh-completions --github zsh-users/zsh-completions
  • 標準では ~/.config/sheldon/plugins.tomlに sheldonの設定ファイルができます

まとめ

再ログインまたはsource ~/.zshrcとすれば設定が有効化されます。
コマンドへの色付けや補完が有効になっているかを確認してください。
これだけでもzshを堪能できると思いますよ。

【ご参考】

私が今回導入した設定はこちらです。
pure導入などで見た目を変更し、履歴の設定を加えています。
ご参考まで。

# pureテーマ追加
sheldon add pure --github sindresorhus/pure --use async.zsh pure.zsh
~/.zshrcファイル
# sheldonが管理するプラグインの読込み
eval "$(sheldon source)"
# pureテーマ設定
fpath+=($HOME//.local/share/sheldon/repos/github.com/sindresorhus/pure/)
autoload -U promptinit; promptinit
prompt pure

# lsなどの出力への色付け 
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'

# HISTORY関連
HISTSIZE=10000
SAVEHIST=10000
# 重複するコマンドを記録しない
setopt hist_ignore_dups
# スペースで始まるコマンドを履歴に記録しない
setopt hist_ignore_space
# 古い重複コマンドを削除
setopt hist_ignore_all_dups

# emacsキーバインド設定
bindkey -e
1
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
1
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?