Arch Linux - シェルをzshに変更
zshをインストール
zsh
$ sudo pacman -S zsh
ログインシェルを変更
ログインシェルをzshに変更。次のターミナル起動からzshが起動するようになる。
zsh
$ chsh -s /bin/zsh
gijuro のシェルを変更します。
パスワード:                    *パスワードを入力
シェルを変更しました。
.zshrcを設置
ターミナルを再起動して、.zshrcが設置されていない状態だとこのメッセージが表示される。
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.
--- Type one of the keys in parentheses ---
「0」を押してホームディレクトリに.zshrc設置。
これで次回のターミナル起動からこのメッセージは表示されなくなる。
zshの設定
zshの設定ファイルは目的別に複数に別れているので、 ArchWikiのZshページ の「設定ファイル」の項目を一読しておくとよいが、とりあえずは「動作に関わる設定は .zshrc」と覚えておけば問題ない。
$ vim ~/.zshrc
~/.zshrc
#コマンド補完
autoload -U compinit
compinit
#コマンドを打ち間違えたときにスペルミスの修正候補を表示
setopt correct
#コマンドの予測変換
autoload predict-on
predict-on
変更した .zshrc の設定を反映。ターミナルの再起動でもOK。
$ source ~/.zshrc
他にzshでどんなオプションが指定できるかはコマンドで確認。現在そのオプションが有効かどうかもわかる。
$ set -o
setopt
noaliases             off
aliasfuncdef          off
allexport             off
noalwayslastprompt    off
alwaystoend           off
appendcreate          off
noappendhistory       off
autocd                off
・・・
・・・
・・・
先頭に「no」がついているオプションはonとoffの意味が逆になるので注意。
Sample: この2つは同じ意味。
noaliases             off
aliases               on
先頭に「no」がない状態の一覧を生成する方法がこちらの記事で紹介されている。機能がon/offを知りたい場合はこっちの方がわかりやすいかもしれない。
Qiita: zshでオプション一覧の出力を分かりやすくする
https://qiita.com/mollifier/items/26c67347734f9fcda274
 
                        
                                             
                        
                                             
                        
                                             
                        
                                             
                        
                                            