1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ログインシェルはbashのまま、zshに自動切り替え(ルート権限がないけどzshを新たに導入したい!)

Last updated at Posted at 2024-11-11

zshをダウンロードしmakeします。

cd $HOME/local
wget https://sourceforge.net/projects/zsh/files/zsh/5.9/zsh-5.9.tar.xz/download -O zsh-5.9.tar.xz
tar xvf zsh-5.9.tar.xz
cd zsh-5.9
./configure --prefix=$HOME/local --enable-multibyte --enable-locale --with-tcsetpgrp
make
make install

.bash_profileに次のように書き込みます。

# =============================
# シェルと確認と変更
# =============================
# 現在のシェル名を取得
current_shell=$(basename "$SHELL")

if [[ "$current_shell" == bash ]]; then
    if [ -x "$(command -v $HOME/local/bin/zsh)" ]; then
    	exec $HOME/local/bin/zsh
        # .zshrcは自動的にsourceされる
    else
    	source $HOME/.bashrc
    fi

elif [[ "$current_shell" == zsh ]]; then
    : # pass
else
	echo "Error! -- Undefined shell: $current_shell"
fi

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?