Ubuntu 17.04でZsh+Zplugを使っていい感じの端末環境を
最強のシェル
http://news.mynavi.jp/column/zsh/001/news.mynavi.jp
最強のシェル、それは「zsh」
なにせ補完が強いらしい
zsh
のプラグインマネージャーといえばoh-my-zsh
だったのだが、遅いみたいで今ではzplug
がいい感じらしい
環境
- Ubuntu 17.04
- Git 2.13.0
- Zplug
Zshをインストール
apt
で引っ張ってくる
$ sudo apt install zsh
Zshをデフォルトシェルに
$ chsh -s $(which zsh)
パスワードを求められるので入力する
chsh
とは、ログインするときに使用するシェルを変更するコマンド
Zshの初期設定
初めてzsh
を起動するとこのように.zshrc
の場所などを聞かれるので答えてあげます
ここではRecommendされてる(2)
を選びます
$ zsh This is the Z Shell configuration function for new users, zsh-newuser-install. You are seeing this message because you have no zsh startup files (the files .zshenv, .zprofile, .zshrc, .zlogin in the directory ~). This function can help you with a few settings that should make your use of the shell easier. You can: (q) Quit and do nothing. The function will be run again next time. (0) Exit, creating the file ~/.zshrc containing just a comment. That will prevent this function being run again. (1) Continue to the main menu. (2) Populate your ~/.zshrc with the configuration recommended by the system administrator and exit (you will need to edit the file by hand, if so desired). --- Type one of the keys in parentheses --- 2 /home/user/.zshrc:15: scalar parameter HISTFILE created globally in function zsh-newuser-install
Gitの最新版をインストール
zplug
がgit
に依存してるのでインストール
なんで、わざわざ最新版を入れるのかって?
なんとなくに決まってるじゃないか
よく使うし最新版にして損はないと思う多分
$ sudo apt install git $ git version git version 2.11.0
普通にインストールすると2.11.0
PPAを追加して最新版にする
$ sudo add-apt-repository ppa:git-core/ppa $ sudo apt update $ sudo apt upgrade $ git version git version 2.13.0
現時点での最新版2.13.0がインストールされた
残りの依存関係をインストール
$ sudo apt install curl gawk
Zplutのインストール
$ curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh| zsh ✔ Checking if your zsh version is newer than 4.1.9 [SUCCEEDED] ✔ Installing zplug to /home/user/.zplug [SUCCEEDED] All processes are successfully completed 🎉 For more information, see http://zplug.sh 🌺 Enjoy zplug!
これでホームディレクトリに.zplug
というフォルダができました
あとは.zshrc
に.zplug
を読み込むように指定してやればいい
zplug
の.zshrc
へのテンプレート
source ~/.zplug/init.zsh # インストールしたいプラグイン # Install plugins if there are plugins that have not been installed if ! zplug check --verbose; then printf "Install? [y/N]: " if read -q; then echo; zplug install fi fi zplug load --verbose > /dev/null
詳細は公式READMEに
.zshrc
に追記したら
次回zsh
を起動したときにインストールされる