diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2022-08-09 19:26:12 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2022-08-09 19:26:12 +1200 |
commit | 79f1da9ffb26d24ae752491076df600c40b124ed (patch) | |
tree | 69cd6fce571d1df386bf98ec2c9862db17338e8d | |
parent | Restore tmux history to defaults (diff) | |
download | dotfiles-79f1da9ffb26d24ae752491076df600c40b124ed.tar.gz dotfiles-79f1da9ffb26d24ae752491076df600c40b124ed.zip |
Better way to elide hostname prompt in screen/tmux
-rw-r--r-- | bash/bashrc.d/prompt.bash | 4 | ||||
-rw-r--r-- | ksh/kshrc.d/prompt.ksh | 4 | ||||
-rw-r--r-- | sh/shrc.d/prompt.sh | 7 | ||||
-rw-r--r-- | zsh/zshrc.d/prompt.zsh | 4 |
4 files changed, 9 insertions, 10 deletions
diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash index bdea7ace..e0a03438 100644 --- a/bash/bashrc.d/prompt.bash +++ b/bash/bashrc.d/prompt.bash @@ -14,9 +14,9 @@ prompt() { PROMPT_DIRTRIM=4 fi - # Basic prompt shape depends on whether we're in SSH or not + # Prompt has hostname via SSH outside of screen/tmux PS1= - if [[ -n $SSH_CLIENT || -n $SSH_CONNECTION ]] ; then + if [[ -n $SSH_CLIENT && -z $STY && -z $TMUX ]] ; then PS1=$PS1'\h:' fi PS1=$PS1'\w' diff --git a/ksh/kshrc.d/prompt.ksh b/ksh/kshrc.d/prompt.ksh index b0023670..99d999de 100644 --- a/ksh/kshrc.d/prompt.ksh +++ b/ksh/kshrc.d/prompt.ksh @@ -12,9 +12,9 @@ function prompt { # Turn complex, colored PS1 and debugging PS4 prompts on on) - # Basic prompt shape depends on whether we're in SSH or not + # Prompt has hostname via SSH outside of screen/tmux PS1= - if [[ -n $SSH_CLIENT || -n $SSH_CONNECTION ]] ; then + if [[ -n $SSH_CLIENT && -z $STY && -z $TMUX ]] ; then PS1=$PS1'${HOSTNAME%%.*}:' fi diff --git a/sh/shrc.d/prompt.sh b/sh/shrc.d/prompt.sh index cb32c113..72cf59b6 100644 --- a/sh/shrc.d/prompt.sh +++ b/sh/shrc.d/prompt.sh @@ -11,8 +11,7 @@ PS3='? ' unset PS4 PS4='+ ' -# If we have an SSH_CLIENT or SSH_CONNECTION environment variable, put the -# hostname in PS1 too. -if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_CONNECTION" ] ; then - PS1=$(hostname -s)'$ ' +# Prompt has hostname via SSH outside of screen/tmux +if [ -n "$SSH_CLIENT" ] && [ -z "$STY" ] && [ -z "$TMUX" ] ; then + PS1=$(hostname -s)$PS1 fi diff --git a/zsh/zshrc.d/prompt.zsh b/zsh/zshrc.d/prompt.zsh index eb43484f..245f2973 100644 --- a/zsh/zshrc.d/prompt.zsh +++ b/zsh/zshrc.d/prompt.zsh @@ -8,9 +8,9 @@ prompt() { on) setopt promptsubst promptpercent - # Basic prompt shape depends on whether we're in SSH or not + # Prompt has hostname via SSH outside of screen/tmux PS1= - if [[ -n $SSH_CLIENT || -n $SSH_CONNECTION ]] ; then + if [[ -n $SSH_CLIENT && -z $STY && -z $TMUX ]] ; then PS1=$PS1'%m:' fi PS1=$PS1'%~' |