Skip to content

Instantly share code, notes, and snippets.

@rescenic
Forked from n-st/.bash_profile
Last active June 9, 2020 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rescenic/78bf9acba9e3b025c04d559e03e2c98b to your computer and use it in GitHub Desktop.
Save rescenic/78bf9acba9e3b025c04d559e03e2c98b to your computer and use it in GitHub Desktop.
Start zsh from bashrc. Useful when you can't use chsh or when the same LDAP account is used both on systems with zsh installed and ones without.
# .bash_profile is executed for login shells,
# .bashrc is executed for interactive non-login shells.
# We want the same behaviour for both, so we source .bashrc from .bash_profile.
# Also, when .bash_profile exists, bash ignores .profile, so we have to source
# it explicitly.
if [ -f "$HOME/.profile" ]; then
. "$HOME/.profile"
fi
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
# .bash_profile is executed for login shells,
# .bashrc is executed for interactive non-login shells.
# We want the same behaviour for both, so we source .bashrc from .bash_profile.
if [ -z "${NOZSH}" ] && [ $TERM = "xterm" -o $TERM = "xterm-256color" -o $TERM = "screen" ] && type zsh &> /dev/null
then
export SHELL=$(which zsh)
if [[ -o login ]]
then
exec zsh -l
else
exec zsh
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment