]> arthur.barton.de Git - OhMyZshExtensions.git/commitdiff
"alex.zsh-theme": Add hostname to the prompt on remote systems
authorAlexander Barton <alex@barton.de>
Tue, 5 May 2015 20:58:25 +0000 (22:58 +0200)
committerAlexander Barton <alex@barton.de>
Tue, 5 May 2015 20:58:25 +0000 (22:58 +0200)
alex.zsh-theme

index c7b1d1cf112c4157a775568e24a424c0cbf635fb..4a6621e6d52701eafb6ffdc93cbc6601c362b6c3 100644 (file)
@@ -1,6 +1,6 @@
 # Alex "oh my ZSH" theme
 # Based on the "Sunrise" theme, thanks!
-# 2015-03-08, alex@barton.de
+# 2015-05-05, alex@barton.de
 
 # Color shortcuts; %B sets bold text
 B=$fg_no_bold[blue]
@@ -27,9 +27,17 @@ function custom_git_prompt() {
        echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/} $(parse_git_dirty)$(git_prompt_ahead)$ZSH_THEME_GIT_PROMPT_SUFFIX"
 }
 
+ZSH_THEME_HOSTNAME_PROMPT_PREFIX=""
+ZSH_THEME_HOSTNAME_PROMPT_SUFFIX="${RESET}:"
+
+function custom_hostname_prompt() {
+       [ -z "$SSH_CLIENT" ] && return
+       echo "$ZSH_THEME_HOSTNAME_PROMPT_PREFIX$(hostname -s)$ZSH_THEME_HOSTNAME_PROMPT_SUFFIX"
+}
+
 local return_code="%(?..%{$R%}%? ↵%{$RESET%})"
 
-PROMPT='%B%2~%b $(custom_git_prompt)%{$G%}%B$%b%{$RESET%} '
+PROMPT='$(custom_hostname_prompt)%B%2~%b $(custom_git_prompt)%{$G%}%B$%b%{$RESET%} '
 RPS1="${return_code}"
 
 unset LSCOLORS