aboutsummaryrefslogtreecommitdiff
path: root/zsh
diff options
context:
space:
mode:
Diffstat (limited to 'zsh')
-rw-r--r--zsh/zshrc7
-rw-r--r--zsh/zshrc.d/prompt.zsh7
2 files changed, 14 insertions, 0 deletions
diff --git a/zsh/zshrc b/zsh/zshrc
index 2376e568..6edcdb67 100644
--- a/zsh/zshrc
+++ b/zsh/zshrc
@@ -7,6 +7,13 @@ HISTFILE=$HOME/.zsh_history
SAVEHIST=$((1 << 12))
HISTSIZE=$((1 << 10))
+# Set a SHLVL-derived value that takes tmux into account. This is used to show
+# the current SHLVL in the prompt
+if [[ -n $TMUX && -z $TMUX_SHLVL ]] ; then
+ TMUX_SHLVL=$((SHLVL - 1))
+ export TMUX_SHLVL
+fi
+
# Load POSIX shell startup files and then Bash-specific ones
for sh in "$ENV" "$HOME"/.zshrc.d/*.zsh ; do
[[ -e $sh ]] && source "$sh"
diff --git a/zsh/zshrc.d/prompt.zsh b/zsh/zshrc.d/prompt.zsh
index ca5ecf3e..0ac2be55 100644
--- a/zsh/zshrc.d/prompt.zsh
+++ b/zsh/zshrc.d/prompt.zsh
@@ -32,6 +32,13 @@ prompt() {
# Add terminating "$" or "#" sign
PS1=$PS1'%#'
+ # Add > signs at the front of the prompt to show the current shell
+ # level, taking tmux sessions into account
+ local shlvl
+ for ((shlvl = SHLVL - TMUX_SHLVL; shlvl > 1; shlvl--)) ; do
+ PS1='>'$PS1
+ done
+
# Bold and color the prompt if it looks like we can
if (( $({ tput colors || tput Co ; } 2>/dev/null) >= 8 )) ; then
PS1='%B%F{green}'$PS1'%f%b'