diff options
| author | Matt Turner <mattst88@gmail.com> | 2026-11-07 22:21:01 -0500 |
|---|---|---|
| committer | Matt Turner <mattst88@gmail.com> | 2026-11-08 14:07:17 -0500 |
| commit | fd79fbe238f9eb3bd25d5814b9f38a413a1f180a (patch) | |
| tree | 0e7df0952da3e4680cbc7f9f6c1d43bf22fe293f /bash | |
| parent | 4422a20fae24f08f36884bac3b1fc02b97b9fad2 (diff) | |
bash: add bashrc that hands interactive sessions to zsh
Keep bash as the login shell so that if zsh is removed or broken, SSH
logins and other login sessions still get a working shell. Interactive
sessions on a terminal exec zsh, unless NO_ZSH is set or zsh isn't
installed. Scripts and scp/rsync stay on bash.
Diffstat (limited to 'bash')
| -rw-r--r-- | bash/.bash_profile | 7 | ||||
| -rw-r--r-- | bash/.bashrc | 28 |
2 files changed, 35 insertions, 0 deletions
diff --git a/bash/.bash_profile b/bash/.bash_profile new file mode 100644 index 0000000..1de05a4 --- /dev/null +++ b/bash/.bash_profile @@ -0,0 +1,7 @@ +# /etc/skel/.bash_profile + +# This file is sourced by bash for login shells. The following line +# runs your .bashrc and is recommended by the bash info pages. +if [[ -f ~/.bashrc ]] ; then + . ~/.bashrc +fi diff --git a/bash/.bashrc b/bash/.bashrc new file mode 100644 index 0000000..81d58e5 --- /dev/null +++ b/bash/.bashrc @@ -0,0 +1,28 @@ +# /etc/skel/.bashrc +# +# This file is sourced by all *interactive* bash shells on startup, +# including some apparently interactive shells such as scp and rcp +# that can't tolerate any output. So make sure this doesn't display +# anything or bad things will happen ! + + +# Test for an interactive shell. There is no need to set anything +# past this point for scp and rcp, and it's important to refrain from +# outputting anything in those cases. +if [[ $- != *i* ]] ; then + # Shell is non-interactive. Be done now! + return +fi + + +# Put your fun stuff here. + +# Hand interactive terminal sessions to zsh. Scripts and scp/rsync stay +# on bash. Falls back to bash if zsh is gone. +if [[ -t 0 && -z $NO_ZSH ]] && command -v zsh >/dev/null; then + if shopt -q login_shell; then + exec zsh -l + else + exec zsh + fi +fi |
