Show different prompt if in ssh session
d8022817f211f3b2ddc4b33dd99e939b93d27c15
1 parent
9431ca8d
.zshrc
+11 -2
| 85 | 85 | # |
|
| 86 | 86 | # Set prompt |
|
| 87 | 87 | # |
|
| 88 | 88 | precmd() { |
|
| 89 | 89 | local last=$? |
|
| 90 | + | local remote="" |
|
| 91 | + | ||
| 92 | + | if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then |
|
| 93 | + | remote=" $(whoami)@$(hostname)" |
|
| 94 | + | fi |
|
| 90 | 95 | ||
| 91 | 96 | # Status |
|
| 92 | 97 | if [ "$last" -eq 0 ]; then |
|
| 93 | 98 | PROMPT='; ' |
|
| 94 | - | RPROMPT='' |
|
| 99 | + | RPROMPT="$remote" |
|
| 95 | 100 | else |
|
| 96 | 101 | PROMPT="%{$fg[red]%}; %{$reset_color%}" |
|
| 97 | - | RPROMPT="%{$fg[red]%}# $last%{$reset_color%}" |
|
| 102 | + | RPROMPT=" $last" |
|
| 103 | + | fi |
|
| 104 | + | ||
| 105 | + | if [ "$RPROMPT" != "" ]; then |
|
| 106 | + | RPROMPT="%{$fg[red]%}#$RPROMPT%{$reset_color%}" |
|
| 98 | 107 | fi |
|
| 99 | 108 | } |
|
| 100 | 109 | ||
| 101 | 110 | col() { |
|
| 102 | 111 | awk "{ print \$$1 }" |