Improve remote prompt
faf815f02b881c010193c3e72518cf31e4048ded
1 parent
80ba7164
.zshrc
+9 -9
| 156 | 156 | # |
|
| 157 | 157 | # Set prompt |
|
| 158 | 158 | # |
|
| 159 | 159 | precmd() { |
|
| 160 | 160 | local last=$? |
|
| 161 | - | local remote="" |
|
| 161 | + | local indicator=">" |
|
| 162 | 162 | ||
| 163 | 163 | if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then |
|
| 164 | - | remote=" $(whoami)@$(cat /etc/hostname)" |
|
| 164 | + | indicator="$(whoami)@$(cat /etc/hostname) #" |
|
| 165 | 165 | fi |
|
| 166 | 166 | ||
| 167 | 167 | # Status |
|
| 168 | 168 | if [ "$last" -eq 0 ]; then |
|
| 169 | - | PROMPT="%{$fg[blue]%}> %{$reset_color%}" |
|
| 170 | - | RPROMPT="$remote" |
|
| 169 | + | PROMPT="%{$fg[blue]%}$indicator %{$reset_color%}" |
|
| 170 | + | RPROMPT="" |
|
| 171 | 171 | else |
|
| 172 | - | PROMPT="%{$fg[red]%}> %{$reset_color%}" |
|
| 172 | + | PROMPT="%{$fg[red]%}$indicator %{$reset_color%}" |
|
| 173 | 173 | RPROMPT=" $last" |
|
| 174 | 174 | fi |
|
| 175 | 175 | ||
| 176 | 176 | if [ "$RPROMPT" != "" ]; then |
|
| 177 | 177 | RPROMPT="%{$fg[red]%}#$RPROMPT%{$reset_color%}" |
|
| 178 | 178 | fi |
|
| 179 | 179 | ||
| 180 | - | # Set the window title to the pwd. |
|
| 181 | - | print -Pn "\e]2;%~\a" |
|
| 180 | + | # Set the window title to the pwd. |
|
| 181 | + | print -Pn "\e]2;%~\a" |
|
| 182 | 182 | } |
|
| 183 | 183 | ||
| 184 | 184 | preexec() { |
|
| 185 | - | # Set the window title to the command and pwd. |
|
| 186 | - | print -Pn "\e]2;$1 [%~]\a" |
|
| 185 | + | # Set the window title to the command and pwd. |
|
| 186 | + | print -Pn "\e]2;$1 [%~]\a" |
|
| 187 | 187 | } |
|
| 188 | 188 | ||
| 189 | 189 | # |
|
| 190 | 190 | # Vi-mode |
|
| 191 | 191 | # |