Advertisement
codewing

zsh-lambda-username

Nov 29th, 2015
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. # prompt style and colors based on Steve Losh's Prose theme:
  2. # http://github.com/sjl/oh-my-zsh/blob/master/themes/prose.zsh-theme
  3. #
  4. # vcs_info modifications from Bart Trojanowski's zsh prompt:
  5. # http://www.jukie.net/bart/blog/pimping-out-zsh-prompt
  6. #
  7. # git untracked files modification from Brian Carper:
  8. # http://briancarper.net/blog/570/git-info-in-your-zsh-prompt
  9.  
  10. function virtualenv_info {
  11. [ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
  12. }
  13. PR_GIT_UPDATE=1
  14.  
  15. setopt prompt_subst
  16.  
  17. autoload -U add-zsh-hook
  18. autoload -Uz vcs_info
  19.  
  20. #use extended color pallete if available
  21. if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then
  22. turquoise="%F{81}"
  23. orange="%F{166}"
  24. purple="%F{135}"
  25. hotpink="%F{161}"
  26. limegreen="%F{118}"
  27. else
  28. turquoise="$fg[cyan]"
  29. orange="$fg[yellow]"
  30. purple="$fg[magenta]"
  31. hotpink="$fg[red]"
  32. limegreen="$fg[green]"
  33. fi
  34.  
  35. # enable VCS systems you use
  36. zstyle ':vcs_info:*' enable git svn
  37.  
  38. # check-for-changes can be really slow.
  39. # you should disable it, if you work with large repositories
  40. zstyle ':vcs_info:*:prompt:*' check-for-changes true
  41.  
  42. # set formats
  43. # %b - branchname
  44. # %u - unstagedstr (see below)
  45. # %c - stagedstr (see below)
  46. # %a - action (e.g. rebase-i)
  47. # %R - repository path
  48. # %S - path in the repository
  49. PR_RST="%{${reset_color}%}"
  50. FMT_BRANCH=" on %{$turquoise%}%b%u%c${PR_RST}"
  51. FMT_ACTION=" performing a %{$limegreen%}%a${PR_RST}"
  52. FMT_UNSTAGED="%{$orange%} ●"
  53. FMT_STAGED="%{$limegreen%} ●"
  54.  
  55. zstyle ':vcs_info:*:prompt:*' unstagedstr "${FMT_UNSTAGED}"
  56. zstyle ':vcs_info:*:prompt:*' stagedstr "${FMT_STAGED}"
  57. zstyle ':vcs_info:*:prompt:*' actionformats "${FMT_BRANCH}${FMT_ACTION}"
  58. zstyle ':vcs_info:*:prompt:*' formats "${FMT_BRANCH}"
  59. zstyle ':vcs_info:*:prompt:*' nvcsformats ""
  60.  
  61.  
  62. function steeef_preexec {
  63. case "$(history $HISTCMD)" in
  64. *git*)
  65. PR_GIT_UPDATE=1
  66. ;;
  67. *svn*)
  68. PR_GIT_UPDATE=1
  69. ;;
  70. esac
  71. }
  72. add-zsh-hook preexec steeef_preexec
  73.  
  74. function steeef_chpwd {
  75. PR_GIT_UPDATE=1
  76. }
  77. add-zsh-hook chpwd steeef_chpwd
  78.  
  79. function steeef_precmd {
  80. if [[ -n "$PR_GIT_UPDATE" ]] ; then
  81. # check for untracked files or updated submodules, since vcs_info doesn't
  82. if [[ ! -z $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
  83. PR_GIT_UPDATE=1
  84. FMT_BRANCH="${PM_RST} on %{$turquoise%}%b%u%c%{$hotpink%} ●${PR_RST}"
  85. else
  86. FMT_BRANCH="${PM_RST} on %{$turquoise%}%b%u%c${PR_RST}"
  87. fi
  88. zstyle ':vcs_info:*:prompt:*' formats "${FMT_BRANCH}"
  89.  
  90. vcs_info 'prompt'
  91. PR_GIT_UPDATE=
  92. fi
  93. }
  94. add-zsh-hook precmd steeef_precmd
  95.  
  96. PROMPT=$'%{$purple%}%n%{$reset_color%} %{$limegreen%}%~%{$reset_color%}$(ruby_prompt_info " with%{$fg[red]%} " v g "%{$reset_color%}")$vcs_info_msg_0_%{$orange%} λ%{$reset_color%} '
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement