Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2017
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.33 KB | None | 0 0
  1. #
  2. # A simple theme that displays relevant, contextual information.
  3. #
  4. # Authors:
  5. # Sorin Ionescu <[email protected]>
  6. #
  7. # Screenshots:
  8. # http://i.imgur.com/nrGV6pg.png
  9. #
  10.  
  11. #
  12. # 16 Terminal Colors
  13. # -- ---------------
  14. # 0 black
  15. # 1 red
  16. # 2 green
  17. # 3 yellow
  18. # 4 blue
  19. # 5 magenta
  20. # 6 cyan
  21. # 7 white
  22. # 8 bright black
  23. # 9 bright red
  24. # 10 bright green
  25. # 11 bright yellow
  26. # 12 bright blue
  27. # 13 bright magenta
  28. # 14 bright cyan
  29. # 15 bright white
  30. #
  31.  
  32. # Load dependencies.
  33. pmodload 'helper'
  34.  
  35. #function prompt_sorin_pwd {
  36. #local pwd="${PWD/#$HOME/~}"
  37.  
  38. #if [[ "$pwd" == (#m)[/~] ]]; then
  39. #_prompt_sorin_pwd="$MATCH"
  40. #unset MATCH
  41. #else
  42. #_prompt_sorin_pwd="${${${${(@j:/:M)${(@s:/:)pwd}##.#?}:h}%/}//\%/%%}/${${pwd:t}//\%/%%}"
  43. #fi
  44. #}
  45.  
  46. #function prompt_sorin_git_info {
  47. #if (( _prompt_sorin_precmd_async_pid > 0 )); then
  48. ## Append Git status.
  49. #if [[ -s "$_prompt_sorin_precmd_async_data" ]]; then
  50. #alias typeset='typeset -g'
  51. #source "$_prompt_sorin_precmd_async_data"
  52. #RPROMPT+='${git_info:+${(e)git_info[status]}}'
  53. #unalias typeset
  54. #fi
  55.  
  56. ## Reset PID.
  57. #_prompt_sorin_precmd_async_pid=0
  58.  
  59. ## Redisplay prompt.
  60. #zle && zle reset-prompt
  61. #fi
  62. #}
  63.  
  64. #function prompt_sorin_precmd_async {
  65. ## Get Git repository information.
  66. #if (( $+functions[git-info] )); then
  67. #git-info
  68. #typeset -p git_info >! "$_prompt_sorin_precmd_async_data"
  69. #fi
  70.  
  71. ## Signal completion to parent process.
  72. #kill -WINCH $$
  73. #}
  74.  
  75. #function prompt_sorin_precmd {
  76. #setopt LOCAL_OPTIONS
  77. #unsetopt XTRACE KSH_ARRAYS
  78.  
  79. ## Format PWD.
  80. #prompt_sorin_pwd
  81.  
  82. ## Define prompts.
  83. #RPROMPT='${editor_info[overwrite]}%(?:: %F{1}⏎%f)${VIM:+" %B%F{6}V%f%b"}'
  84.  
  85. ## Kill the old process of slow commands if it is still running.
  86. #if (( _prompt_sorin_precmd_async_pid > 0 )); then
  87. #kill -KILL "$_prompt_sorin_precmd_async_pid" &>/dev/null
  88. #fi
  89.  
  90. ## Compute slow commands in the background.
  91. #trap prompt_sorin_git_info WINCH
  92. #prompt_sorin_precmd_async &!
  93. #_prompt_sorin_precmd_async_pid=$!
  94. #}
  95.  
  96. function prompt_paymahn_hg_info {
  97. if (( _prompt_paymahn_precmd_async_pid > 0 )); then
  98. # Reset PID.
  99. _prompt_paymahn_precmd_async_pid=0
  100.  
  101. _hg_info=$(_dotfiles_scm_info)
  102.  
  103. # Redisplay prompt.
  104. zle && zle reset-prompt
  105. fi
  106. }
  107.  
  108. function prompt_paymahn_precmd_async {
  109.  
  110. # Signal completion to parent process.
  111. kill -WINCH $$
  112. }
  113.  
  114. function paymahn_func {
  115. _hg_info=" (unkown)"
  116.  
  117. # Kill the old process of slow commands if it is still running.
  118. if (( _prompt_paymahn_precmd_async_pid > 0 )); then
  119. kill -KILL "$_prompt_paymahn_precmd_async_pid" &>/dev/null
  120. fi
  121. trap prompt_paymahn_hg_info WINCH
  122. prompt_paymahn_precmd_async &! _prompt_paymahn_precmd_async_pid=$!
  123.  
  124. }
  125.  
  126. function prompt_sorin_setup {
  127. setopt LOCAL_OPTIONS
  128. unsetopt XTRACE KSH_ARRAYS
  129. prompt_opts=(cr percent subst)
  130. _prompt_sorin_precmd_async_pid=0
  131. _prompt_sorin_precmd_async_data="${TMPPREFIX}-prompt_sorin_data"
  132.  
  133. # Load required functions.
  134. autoload -Uz add-zsh-hook
  135.  
  136. # Add hook for calling git-info before each command.
  137. # add-zsh-hook precmd prompt_sorin_precmd
  138. add-zsh-hook precmd paymahn_func
  139.  
  140. # Set editor-info parameters.
  141. zstyle ':prezto:module:editor:info:completing' format '%B%F{7}...%f%b'
  142. zstyle ':prezto:module:editor:info:keymap:primary' format ' %B%F{1}❯%F{3}❯%F{2}❯%f%b'
  143. zstyle ':prezto:module:editor:info:keymap:primary:overwrite' format ' %F{3}♺%f'
  144. zstyle ':prezto:module:editor:info:keymap:alternate' format ' %B%F{2}❮%F{3}❮%F{1}❮%f%b'
  145.  
  146. # Set git-info parameters.
  147. zstyle ':prezto:module:git:info' verbose 'yes'
  148. zstyle ':prezto:module:git:info:action' format '%F{7}:%f%%B%F{9}%s%f%%b'
  149. zstyle ':prezto:module:git:info:added' format ' %%B%F{2}✚%f%%b'
  150. zstyle ':prezto:module:git:info:ahead' format ' %%B%F{13}⬆%f%%b'
  151. zstyle ':prezto:module:git:info:behind' format ' %%B%F{13}⬇%f%%b'
  152. zstyle ':prezto:module:git:info:branch' format ' %%B%F{2}%b%f%%b'
  153. zstyle ':prezto:module:git:info:commit' format ' %%B%F{3}%.7c%f%%b'
  154. zstyle ':prezto:module:git:info:deleted' format ' %%B%F{1}✖%f%%b'
  155. zstyle ':prezto:module:git:info:modified' format ' %%B%F{4}✱%f%%b'
  156. zstyle ':prezto:module:git:info:position' format ' %%B%F{13}%p%f%%b'
  157. zstyle ':prezto:module:git:info:renamed' format ' %%B%F{5}➜%f%%b'
  158. zstyle ':prezto:module:git:info:stashed' format ' %%B%F{6}✭%f%%b'
  159. zstyle ':prezto:module:git:info:unmerged' format ' %%B%F{3}═%f%%b'
  160. zstyle ':prezto:module:git:info:untracked' format ' %%B%F{7}◼%f%%b'
  161. zstyle ':prezto:module:git:info:keys' format \
  162. 'status' '$(coalesce "%b" "%p" "%c")%s%A%B%S%a%d%m%r%U%u'
  163.  
  164. # Define prompts.
  165. #PROMPT='${SSH_TTY:+"%F{9}%n%f%F{7}@%f%F{3}%m%f "}%F{4}${_prompt_sorin_pwd}%(!. %B%F{1}#%f%b.)${editor_info[keymap]} '
  166. #PROMPT='${SSH_TTY:+"%F{9}%n%f%F{7}@%f%F{3}%2m%f "}%F{4}%d%(!. %B%F{1}#%f%b.)${_hg_info} $prompt_newline${editor_info[keymap]} '
  167. PROMPT='${SSH_TTY:+"%F{9}%n%f%F{7}@%f%F{3}%2m%f "}%F{4}%d%(!. %B%F{1}#%f%b.)${_hg_info} ${editor_info[keymap]} '
  168. RPROMPT=''
  169. SPROMPT='zsh: correct %F{1}%R%f to %F{2}%r%f [nyae]? '
  170. }
  171.  
  172. function prompt_sorin_preview {
  173. local +h PROMPT=''
  174. local +h RPROMPT=''
  175. local +h SPROMPT=''
  176.  
  177. editor-info 2>/dev/null
  178. prompt_preview_theme 'sorin'
  179. }
  180.  
  181. prompt_sorin_setup "$@"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement