diff options
author | Marc Cornellà <marc.cornella@live.com> | 2019-05-27 20:41:55 +0200 |
---|---|---|
committer | Marc Cornellà <marc.cornella@live.com> | 2019-06-03 17:18:24 +0200 |
commit | 794ff4a62daa57b985ea35a3d6dc879d771e53f0 (patch) | |
tree | e44fe07e474422e76a89c53cb04aae92e37b8a2f /tools | |
parent | 43b3126b5cd2253330edf73930d37f17eaf4328f (diff) | |
download | zsh-794ff4a62daa57b985ea35a3d6dc879d771e53f0.tar.gz zsh-794ff4a62daa57b985ea35a3d6dc879d771e53f0.tar.bz2 zsh-794ff4a62daa57b985ea35a3d6dc879d771e53f0.zip |
installer: add ability to skip the default shell change
Co-authored-by: Marshall Ford <inbox@marshallford.me>
Co-authored-by: Joel Kuzmarski <leoj3n@gmail.com>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/install.sh | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/tools/install.sh b/tools/install.sh index 66da05690..b479dc803 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -10,9 +10,12 @@ # sh install.sh # # Respects these environment variables for tweaking the installation process: +# ZSH - path to the Oh My Zsh repository folder (default: $HOME/.oh-my-zsh) # REPO - name of the GitHub repo to install from (default: robbyrussell/oh-my-zsh) # REMOTE - full remote URL of the git repo to install (default: GitHub via HTTPS) # BRANCH - branch to check out immediately after install (default: master) +# Other options: +# CHSH - set to no tells the installer not to change the default shell (default: yes) # set -e @@ -22,6 +25,10 @@ REPO=${REPO:-robbyrussell/oh-my-zsh} REMOTE=${REMOTE:-https://github.com/${REPO}.git} BRANCH=${BRANCH:-master} +# Other options +CHSH=${CHSH:-yes} + + command_exists() { command -v "$@" >/dev/null 2>&1 } @@ -118,6 +125,11 @@ export ZSH=\"$ZSH\" } setup_shell() { + # Skip setup if the user wants or stdin is closed (not running interactively). + if [ $CHSH = no ] || ! [ -t 0 ]; then + return + fi + # If this user's login shell is already "zsh", do not attempt to switch. if [ "$(basename "$SHELL")" = "zsh" ]; then return @@ -161,6 +173,14 @@ setup_shell() { } main() { + # Parse arguments + while [ $# -gt 0 ]; do + case $1 in + --skip-chsh) CHSH=no ;; + esac + shift + done + setup_color if ! command_exists zsh; then @@ -202,4 +222,4 @@ main() { exec zsh -l } -main +main "$@" |