dotfiles/recipes/zsh

45 lines
960 B
Bash

#!/bin/bash
# Description: Feature-rich interactive shell with plugins
set -e
case $_PLATFORM in
darwin)
_recipe brew
_brew zsh
;;
arch)
_recipe _arch
_pacman zsh
;;
debian)
_recipe _apt
_apt zsh
;;
esac
__zsh_bin="$(which zsh)"
__zsh_files=(.zshrc)
if ! grep "^$__zsh_bin\$" /etc/shells >/dev/null; then
sudo sh -c "echo $__zsh_bin >> /etc/shells"
fi
case $_PLATFORM in
darwin)
__shell=$(dscl . -read /Users/${USER} UserShell | awk '{print $2}')
;;
*)
__shell=$(getent passwd $USER | cut -d: -f7)
;;
esac
if [ "$__shell" != "$__zsh_bin" ]; then
echo "Install $__zsh_bin as default shell (currently $__shell)"
sudo chsh -s $__zsh_bin ${USER}
export SHELL=$__zsh_bin
RESTART_SHELL=1
fi
if ! [ -f ${HOME}/.zshrc ]; then
_run "Install .zshrc" ln -s ${HOME}/dotfiles/.zshrc ${HOME}/.zshrc
RESTART_SHELL=1
fi