Advertisement
Guest User

zshrc

a guest
Feb 24th, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 KB | None | 0 0
  1. # Lines configured by zsh-newuser-install
  2. HISTFILE=~/.histfile
  3. HISTSIZE=1000
  4. SAVEHIST=1000
  5. export CLICOLOR=1
  6.  
  7. # End of lines configured by zsh-newuser-install
  8. # The following lines were added by compinstall
  9. zstyle :compinstall filename '/root/.zshrc'
  10. setopt autocd
  11.  
  12. autoload -Uz compinit
  13. compinit
  14. # End of lines added by compinstal
  15.  
  16.  
  17. function precmd {
  18. local TERMWIDTH
  19. (( TERMWIDTH = ${COLUMNS} - 1 ))
  20. ###
  21. # Truncate the path if it's too long.
  22.  
  23. PR_FILLBAR=""
  24. PR_PWDLEN=""
  25.  
  26. local promptsize=${#${(%):---(%n@%m:%l)---()--}}
  27. local pwdsize=${#${(%):-%~}}
  28.  
  29. if [[ "$promptsize + $pwdsize" -gt $TERMWIDTH ]]; then
  30. ((PR_PWDLEN=$TERMWIDTH - $promptsize))
  31. else
  32. PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $pwdsize)))..${PR_HBAR}.)}"
  33. fi
  34.  
  35. ###
  36. # Get APM info.
  37.  
  38. # if which ibam > /dev/null; then
  39. # PR_APM_RESULT=`ibam --percentbattery`
  40. # elif which apm > /dev/null; then
  41. # PR_APM_RESULT=`apm`
  42. # fi
  43. }
  44.  
  45. setopt extended_glob
  46. preexec () {
  47. if [[ "$TERM" == "screen" ]]; then
  48. local CMD=${1[(wr)^(*=*|sudo|-*)]}
  49. echo -ne "\ek$CMD\e\\"
  50. fi
  51. }
  52.  
  53. setprompt () {
  54. ###
  55. # Need this so the prompt will work.
  56.  
  57. setopt prompt_subst
  58. ###
  59. # See if we can use colors.
  60.  
  61. autoload colors zsh/terminfo
  62. if [[ "$terminfo[colors]" -ge 8 ]]; then
  63. colors
  64. fi
  65. for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
  66. eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
  67. eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
  68. (( count = $count + 1 ))
  69. done
  70. PR_NO_COLOUR="%{$terminfo[sgr0]%}"
  71.  
  72.  
  73. ###
  74. # See if we can use extended characters to look nicer.
  75.  
  76. typeset -A altchar
  77. set -A altchar ${(s..)terminfo[acsc]}
  78. PR_SET_CHARSET="%{$terminfo[enacs]%}"
  79. PR_SHIFT_IN="%{$terminfo[smacs]%}"
  80. PR_SHIFT_OUT="%{$terminfo[rmacs]%}"
  81. PR_HBAR=${altchar[q]:--}
  82. PR_ULCORNER=${altchar[l]:--}
  83. PR_LLCORNER=${altchar[m]:--}
  84. PR_LRCORNER=${altchar[j]:--}
  85. PR_URCORNER=${altchar[k]:--}
  86.  
  87. ###
  88. # Decide if we need to set titlebar text.
  89.  
  90. case $TERM in
  91. xterm*)
  92. PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}'
  93. ;;
  94. screen)
  95. PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}'
  96. ;;
  97. *)
  98. PR_TITLEBAR=''
  99. ;;
  100. esac
  101. ###
  102. # APM detection
  103.  
  104. # if which ibam > /dev/null; then
  105. # PR_APM='$PR_RED${${PR_APM_RESULT[(f)1]}[(w)-2]}%%(${${PR_APM_RESULT[(f)3]}[(w)-1]})$PR_LIGHT_BLUE:'
  106. # elif which apm > /dev/null; then
  107. # PR_APM='$PR_RED${PR_APM_RESULT[(w)5,(w)6]/\% /%%}$PR_LIGHT_BLUE:'
  108. # else
  109. # PR_APM=''
  110. # fi
  111.  
  112.  
  113.  
  114. PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\
  115. $PR_CYAN$PR_SHIFT_IN$PR_ULCORNER$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\
  116. $PR_GREEN%(!.%SROOT%s.%n)$PR_GREEN@%m:%l\
  117. $PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_CYAN$PR_HBAR${(e)PR_FILLBAR}$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\
  118. $PR_MAGENTA%$PR_PWDLEN<...<%~%<<\
  119. $PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_CYAN$PR_URCORNER$PR_SHIFT_OUT\
  120.  
  121. $PR_CYAN$PR_SHIFT_IN$PR_LLCORNER$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\
  122. %(?..$PR_LIGHT_RED%?$PR_BLUE:)\
  123. ${(e)PR_APM}$PR_YELLOW%D{%H:%M}\
  124. $PR_LIGHT_BLUE:%(!.$PR_RED.$PR_WHITE)%#$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
  125. $PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
  126. $PR_NO_COLOUR '
  127. }
  128.  
  129. setprompt
  130. export PATH=${PATH}:/usr/bin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement