Guest User

Untitled

a guest
Jan 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. CURRENT_BG='NONE'
  2. SEGMENT_SEPARATOR='\u25B6'
  3. CURRENT_BG_OLD="$CURRENT_BG"
  4.  
  5. # Begin a segment
  6. # Takes two arguments, background and foreground. Both can be omitted,
  7. # rendering default background/foreground.
  8. prompt_segment() {
  9. local bg fg
  10. [[ -n $1 ]] && bg="%K{$1}" || bg="%k"
  11. [[ -n $2 ]] && fg="%F{$2}" || fg="%f"
  12. if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then
  13. echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} "
  14. else
  15. echo -n "%{$bg%}%{$fg%} "
  16. fi
  17. CURRENT_BG=$1
  18. [[ -n $3 ]] && echo -n $3
  19. }
  20.  
  21. prompt_begin() {
  22. echo -e "\n"
  23. prompt_segment blue blue ' '
  24.  
  25. prompt_status(){
  26.  
  27. local symbols
  28. symbols=()
  29. [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘"
  30. # [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡"
  31. symbols+="%{%F{yellow}%}%#"
  32. [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙"
  33. symbols=$symbols" "
  34. [[ -n "$symbols" ]] && prompt_segment black default "$symbols "
  35.  
  36. }
  37. }
  38.  
  39.  
  40.  
  41.  
  42. prompt_begin_2(){
  43. echo -e "\n"
  44. # CURRENT_BG='NONE'
  45. # prompt_segment blue black ' '
  46. }
  47.  
  48. # End the prompt, closing any open segments
  49. prompt_end() {
  50. if [[ -n $CURRENT_BG ]]; then
  51. echo -n "%{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR"
  52. else
  53. echo -n "%{%k%}"
  54. fi
  55. echo -n "%{%f%}"
  56. CURRENT_BG=''
  57. }
  58.  
  59. ### Prompt components
  60. # Each component will draw itself, and hide itself if no information needs to be shown
  61.  
  62. # Context: user@hostname (who am I and where am I)
  63. prompt_context() {
  64. prompt_segment black green "%n@%m"
  65. }
  66.  
  67. prompt_date() {
  68. prompt_segment blue black "$(date +%d.%m-%H:%M:%S)"
  69. prompt_segment black green ' %~'
  70. }
  71.  
  72. vcs_info_wrapper() {
  73. vcs_info
  74. if [ -n "$vcs_info_msg_0_" ]; then
  75. echo "%{$fg[grey]%}${vcs_info_msg_0_}%{$reset_color%}$del"
  76. fi
  77. }
  78.  
  79. prompt_git() {
  80. prompt_segment yellow black "$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/')"
  81. }
  82.  
  83. # Dir: current working directory
  84. #prompt_dir() {
  85. # prompt_segment black green ' %~'
  86. #}
  87.  
  88.  
  89. prompt_between(){
  90. prompt_segment black black ''
  91. # RPROMPT=$(build_prompt_right)
  92.  
  93. #build_prompt_right() {
  94. CURRENT_BG='black'
  95. prompt_segment blue black ${vcs_info_msg_0_}
  96. #}
  97.  
  98.  
  99. }
  100. # Virtualenv: current working virtualenv
  101. prompt_virtualenv() {
  102. local virtualenv_path="$VIRTUAL_ENV"
  103. if [[ -n $virtualenv_path ]]; then
  104. prompt_segment blue black "(`basename $virtualenv_path`)"
  105. fi
  106. }
  107.  
  108. # Status:
  109. # - was there an error
  110. # - am I root
  111. # - are there background jobs?
  112.  
  113. zstyle ':vcs_info:*' enable git hg svn
  114. zstyle ':vcs_info:*' get-revision true
  115. zstyle ':vcs_info:*' check-for-changes true
  116. zstyle ':vcs_info:*' formats "%s \u25B6 [%r/%S] %b %u%c "
  117. zstyle ':vcs_info:*' stagedstr '%F{green}●'
  118. zstyle ':vcs_info:*' unstagedstr '%F{yellow}●'
  119.  
  120.  
  121.  
  122. ## Main prompt
  123. #build_prompt() {
  124. # RETVAL=$?
  125. # prompt_begin
  126. # prompt_status
  127. # prompt_virtualenv
  128. # prompt_context
  129. # prompt_date
  130. # prompt_between
  131. # prompt_end
  132. # CURRENT_BG=''
  133. # prompt_begin_2
  134. ## prompt_dir
  135. # prompt_end
  136. #}
  137.  
  138. #PROMPT='%{%f%b%k%}$(build_prompt)%{$reset_color%} '
  139.  
  140. ## Main prompt
  141.  
  142. build_prompt() {
  143. RETVAL=$?
  144. prompt_begin
  145. prompt_status
  146. prompt_virtualenv
  147. prompt_context
  148. prompt_date
  149. prompt_git
  150. prompt_between
  151. prompt_end
  152. CURRENT_BG=''
  153. prompt_begin_2
  154. # prompt_dir
  155. prompt_end
  156. }
  157.  
  158. PROMPT='%{%f%b%k%}$(build_prompt)%{$reset_color%} '
Add Comment
Please, Sign In to add comment