From 3087fc8d7dd4de02dcfeddddff63544216a7e4c1 Mon Sep 17 00:00:00 2001 From: Wentao Han Date: Wed, 14 May 2014 14:23:13 +0800 Subject: [PATCH] Improve my prompt theme * Display username@hostname when ssh * Change git style, using ASCII characters * Combine status code with the prompt character --- themes/hanwentao.zsh-theme | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/themes/hanwentao.zsh-theme b/themes/hanwentao.zsh-theme index fe7f5fe2e..e18420c73 100644 --- a/themes/hanwentao.zsh-theme +++ b/themes/hanwentao.zsh-theme @@ -1,7 +1,15 @@ -local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)" -PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%~ %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}%# %{$reset_color%}' +function ssh_username_hostname() { + if [[ -n "$SSH_CONNECTION" ]]; then + echo "%{$fg_bold[green]%}%n@%m " + fi +} -ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}" -ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} " -ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}" -ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})" +ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[cyan]%}git:(%{$fg[red]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX=" " +ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[yellow]%}X%{$fg[cyan]%})" +ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[cyan]%})" + +local current_dir="%{$fg[blue]%}%~ " +local ret_status="%(?:%{$fg_bold[green]%}:%{$fg_bold[red]%}%? )%# " + +PROMPT='$(ssh_username_hostname)${current_dir}$(git_prompt_info)${ret_status}%{$reset_color%}'