diff --git a/zsh/new-prompt b/zsh/new-prompt deleted file mode 100644 index ffd04b2..0000000 --- a/zsh/new-prompt +++ /dev/null @@ -1,35 +0,0 @@ -local current_time="[%B%D{%I:%M:%S}%b]" -local current_dir='%B%F{blue}%~%f%b' - -# user -local user="%F{green}%n%f" - -# host -local host="" -if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then - host='%F{yellow}%M%f' #SSH -else - host='%F{green}%M%f' # no SSH -fi - -# vcs -precmd() { - setopt promptsubst - autoload -Uz vcs_info - - zstyle ':vcs_info:*' enable git hg svn - zstyle ':vcs_info:*:prompt:*' nvcsformats "" - zstyle ':vcs_info:*:prompt:*' check-for-changes true - zstyle ':vcs_info:*:prompt:*' unstagedstr "*" - zstyle ':vcs_info:*:prompt:*' stagedstr "*" - zstyle ':vcs_info:*:prompt:*' formats "[%F{yellow}%b%f%u%c]" - vcs_info 'prompt' -} -local vcs='${vcs_info_msg_0_}' - -# prompt -local return_code="%(?..%?)" -local prompt="%(?.%F{green}->.%F{red}-%B${return_code}%b%F{red}->%{%})%f" - -PROMPT="${current_time} ${user}@${host} ${current_dir} ${vcs} -|$prompt " diff --git a/zsh/prompt b/zsh/prompt index 8cbaade..6312267 100644 --- a/zsh/prompt +++ b/zsh/prompt @@ -1,102 +1,32 @@ -function prompt_pwd { - local pwd="${PWD/#$HOME/~}" +local current_time="[%B%D{%I:%M:%S}%b]" +local current_dir='%B%F{blue}%~%f%b' - if [[ "$pwd" == (#m)[/~] ]]; then - _prompt_pwd="$MATCH" - unset MATCH - else - _prompt_pwd="${${${(@j:/:M)${(@s:/:)pwd}##.#?}:h}%/}/${pwd:t}" - fi -} +# user +local user="%F{green}%n%f" -function prompt_userhost { - eval PR_USER="%F{green}%n%f" - if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then - eval PR_HOST='%F{yellow}%M%f' #SSH - else - eval PR_HOST='%F{green}%M%f' # no SSH - fi +# host +local host="" +if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then + host='%F{yellow}%M%f' #SSH +else + host='%F{green}%M%f' # no SSH +fi - _prompt_userhost="${PR_USER}%F{cyan}@${PR_HOST}%f" -} - -function prompt_ruby { - if which rvm-prompt &> /dev/null; then - _prompt_ruby="[%F{red}$(rvm-prompt i v g s)%f]" - else - if which rbenv &> /dev/null; then - _prompt_ruby="[%F{red}$(rbenv version | sed -e "s/ (set.*$//")%f]" - fi - fi -} - -function prompt_vcs { - local branch_format="(%F{yellow}%b%f%u%c)" - local action_format="(%F{yellow}%a%f)" - local unstaged_format="%F{green}*%f" - local staged_format="%F{yellow}*%f" - - zstyle ':vcs_info:*' enable git hg svn - zstyle ':vcs_info:*:prompt:*' check-for-changes true - zstyle ':vcs_info:*:prompt:*' unstagedstr "${unstaged_format}" - zstyle ':vcs_info:*:prompt:*' stagedstr "${staged_format}" - zstyle ':vcs_info:*:prompt:*' actionformats "${branch_format}${action_format}" - zstyle ':vcs_info:*:prompt:*' formats "${branch_format}" - zstyle ':vcs_info:*:prompt:*' nvcsformats "" - - _prompt_vcs="${vcs_info_msg_0_}" -} - -function prompt_precmd { - setopt LOCAL_OPTIONS - unsetopt XTRACE KSH_ARRAYS - - # Format PWD. - prompt_pwd - - # vcs prompt - if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then - branch_format="[%F{yellow}%b%f%u%c%F{yellow}*%f]" - else - branch_format="[%F{yellow}%b%f%u%c]" - fi - - zstyle ':vcs_info:*:prompt:*' formats "${branch_format}" - - vcs_info 'prompt' -} - -function prompt_setup { - setopt LOCAL_OPTIONS - unsetopt XTRACE KSH_ARRAYS - prompt_opts=(cr percent subst) - - # Load required functions. - autoload -Uz add-zsh-hook +# vcs +precmd() { + setopt promptsubst autoload -Uz vcs_info - # Add hook for calling git-info before each command. - add-zsh-hook precmd prompt_precmd - - # keep this - SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? ' - - # custom stuff - prompt_ruby - prompt_userhost - prompt_vcs - - local current_time="[%B%D{%I:%M:%S}%b]" - local current_dir='%B%F{blue}%~%f%b' - local return_code="%(?..%?)" - local user_host=$_prompt_userhost - local ruby_info=$_prompt_ruby - local git_info=$_prompt_vcs - - local PR_PROMPT="%(?.%F{green}->.%F{red}-%B${return_code}%b%F{red}->%{%})%f" - - PROMPT="${current_time} ${user_host} ${current_dir} ${ruby_info} ${git_info} -|$PR_PROMPT " + zstyle ':vcs_info:*' enable git hg svn + zstyle ':vcs_info:*:prompt:*' nvcsformats "" + zstyle ':vcs_info:*:prompt:*' formats "[%F{yellow}%b%f%u%c]" + vcs_info 'prompt' } +local vcs='${vcs_info_msg_0_}' -prompt_setup "$@" +# prompt +local return_code="%(?..%?)" +local prompt="%(?.%F{green}->.%F{red}-%B${return_code}%b%F{red}->%{%})%f" + +PROMPT="${current_time} ${user}@${host} ${current_dir} ${vcs} +|$prompt " diff --git a/zshrc b/zshrc index 477f54e..8d9c8ee 100644 --- a/zshrc +++ b/zshrc @@ -26,7 +26,7 @@ stty stop undef # Aliases/Functions files source $HOME/.aliases source $HOME/.functions -source $HOME/.zsh/new-prompt +source $HOME/.zsh/prompt if [[ "$OSTYPE" == darwin* ]]; then source $HOME/.aliases-mac