LoginSignup
9
4

More than 5 years have passed since last update.

MSYS2のログインシェルをzshに変更する(msys2-launcher対応版)

Posted at

はじめに

久々にMSYS2の更新を行ったところ、どうやらexe経由での起動方法に変更されたようだ。

参考: pacman -Syu で更新したら msys2 や mingw32/64 が起動しなくなった…(震え声

cmd経由での起動であればMSYS2でWindowsにzsh環境を導入するMSYS2でデフォルトシェルをzshにするにある方法でログインシェルの変更が出来たが、exe経由となったためこれらの方法は使えなくなってしまった。

調べてみると割と簡単に変更できたので、変更方法を共有したい。

情報元

elieux/msys2-launcherのIssueを見てみると、以下のような投稿が見つかった。

You can either set the login shell of everyone using your MSYS2 installation using nsswitch.conf or use mkpasswd -c to create an /etc/passwd entry that you can modify.

(引用元: Add an ability to configure default shell #3

方法1: /etc/nsswitch.confを修正する

/etc/nsswitch.confを何かしらのエディタで開き、下記のようになっているところを、

db_shell: cygwin desc

こう変える。

#db_shell: cygwin desc
db_shell: /usr/bin/zsh

変更後にexeを再度起動すると、zshが立ち上がる。

方法2: /etc/passwdを作成して修正する

デフォルトでは/etc/passwdがないため、mkpasswd -cでファイルを作る。

$ mkpasswd -c > /etc/passwd

その後、行末の/usr/bin/bash/usr/bin/zshに修正すればよい。

蛇足: /etc/nsswitch.conf/etc/passwdではどちらが優先される?

試してみたところ、/etc/passwdに書いたほうが立ち上がるようだ。

9
4
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
9
4