-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_shell.sh
More file actions
35 lines (29 loc) · 974 Bytes
/
setup_shell.sh
File metadata and controls
35 lines (29 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/zsh
local LOG_PREFIX="[setup shell]:"
local _is_ZSH_the_default_sys_shell() {
test $(grep -Fxq $HOMEBREW_BIN_PATH/zsh /etc/shells)
}
local _is_ZSH_the_default_login_shell() {
test $SHELL = $HOMEBREW_BIN_PATH/zsh
}
# set ZSH as the default system shell
if ! _is_ZSH_the_default_sys_shell; then
echo "$LOG_PREFIX change default system shell to zsh..."
echo $HOMEBREW_BIN_PATH/zsh | sudo tee -a /etc/shells >/dev/null
else
echo "$LOG_PREFIX system shell already set to zsh"
fi
# set ZSH as the default login shell
if ! _is_ZSH_the_default_login_shell; then
echo "$LOG_PREFIX change default login shell to zsh..."
chsh -s $HOMEBREW_BIN_PATH/zsh
else
echo "$LOG_PREFIX login shell already set to zsh"
fi
# update `sh` symlink to points to zsh instead of bash
if ! sh --version | grep -q zsh; then
echo "$LOG_PREFIX update sh symlink from bash to zsh..."
sudo ln -sfv /bin/zsh /var/select/sh
else
echo "$LOG_PREFIX sh symlink already points to zsh"
fi