Skip to content

Commit

Permalink
Prevent hostname from showing up in local X sessions
Browse files Browse the repository at this point in the history
This change prevents the hostname from showing up when a terminal is
opened inside a local X session (displayed as (:1)).

Fixes a regression introduced in sindresorhus#393.
  • Loading branch information
mafredri committed May 6, 2018
1 parent a90b1bc commit 75aaf3b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pure.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,8 @@ prompt_pure_state_setup() {
if [[ -z $ssh_connection ]] && (( $+commands[who] )); then
# When changing user on a remote system, the $SSH_CONNECTION
# environment variable can be lost, attempt detection via who.
if who am i | grep -q '(.*)$' &>/dev/null; then
# Ignore local X sessions displayed as (:1).
if who am i | grep -v '(:[0-9]*)$' | grep -q '(.*)$' &>/dev/null; then
ssh_connection=true
fi
fi
Expand All @@ -496,7 +497,9 @@ prompt_pure_state_setup() {
[[ $UID -eq 0 ]] && username='%F{white}%n%f%F{242}@%m%f'

typeset -gA prompt_pure_state
prompt_pure_state=(username "$username")
prompt_pure_state=(
username "$username"
)
}

prompt_pure_setup() {
Expand Down

0 comments on commit 75aaf3b

Please sign in to comment.