Advertisement
big_bum

Zsh

Jun 17th, 2012
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.34 KB | None | 0 0
  1. # location of history
  2. export HISTFILE=~/.histfile
  3. # number of lines kept in history
  4. export HISTSIZE=10000
  5. # number of lines saved in the history after logout
  6. export SAVEHIST=10000
  7. export EDITOR="nano"
  8. # emacs style key binding
  9. bindkey -e
  10. # backward delete
  11. # chars as part of filename
  12. WORDCHARS='*?_-[]~=&;!#$%^(){}<>'
  13. bindkey "^[OH" beginning-of-line
  14. bindkey "^[OF" end-of-line
  15. bindkey "^[[3~" delete-char
  16. bindkey "^[[5~" beginning-of-history
  17. bindkey "^[[6~" end-of-history
  18. bindkey "^[[1;5C" forward-word
  19. bindkey "^[[1;5D" backward-word
  20. bindkey "^[[1;3C" forward-word
  21. bindkey "^[[1;3D" backward-word
  22. autoload -Uz compinit
  23. compinit
  24. # End of lines added by compinstall
  25.  
  26. #Disable core dumps
  27. limit coredumpsize 0
  28.  
  29. setopt AUTO_LIST
  30. setopt AUTO_MENU
  31. setopt MENU_COMPLETE
  32. setopt autocd
  33. setopt extendedglob
  34. setopt hist_ignore_all_dups
  35.  
  36. autoload -U compinit
  37. compinit
  38.  
  39. # Completion caching
  40. zstyle ':completion::complete:*' use-cache on
  41. zstyle ':completion::complete:*' cache-path .zcache
  42. zstyle ':completion:*:cd:*' ignore-parents parent pwd
  43.  
  44. #Completion Options
  45. zstyle ':completion:*:match:*' original only
  46. zstyle ':completion::prefix-1:*' completer _complete
  47. zstyle ':completion:predict:*' completer _complete
  48. zstyle ':completion:incremental:*' completer _complete _correct
  49. zstyle ':completion:*' completer _complete _prefix _correct _prefix _match _approximate
  50.  
  51. # Path Expansion
  52. zstyle ':completion:*' expand 'yes'
  53. zstyle ':completion:*' squeeze-shlashes 'yes'
  54. zstyle ':completion::complete:*' '\\'
  55.  
  56. zstyle ':completion:*:*:*:default' menu yes select
  57. zstyle ':completion:*:*:default' force-list always
  58.  
  59. # GNU Colors /etc/DIR_COLORS
  60.  
  61. LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=00;35:*.jpeg=00;35:*.gif=00;35:*.bmp=00;35:*.pbm=00;35:*.pgm=00;35:*.ppm=00;35:*.tga=00;35:*.xbm=00;35:*.xpm=00;35:*.tif=00;35:*.tiff=00;35:*.png=00;35:*.svg=00;35:*.svgz=00;35:*.mng=00;35:*.pcx=00;35:*.mov=00;35:*.mpg=00;35:*.mpeg=00;35:*.m2v=00;35:*.mkv=00;35:*.webm=00;35:*.ogm=00;35:*.mp4=00;35:*.m4v=00;35:*.mp4v=00;35:*.vob=00;35:*.qt=00;35:*.nuv=00;35:*.wmv=00;35:*.asf=00;35:*.rm=00;35:*.rmvb=00;35:*.flc=00;35:*.avi=00;35:*.fli=00;35:*.flv=00;35:*.gl=00;35:*.dl=00;35:*.xcf=00;35:*.xwd=00;35:*.yuv=00;35:*.cgm=00;35:*.emf=00;35:*.axv=00;35:*.anx=00;35:*.ogv=00;35:*.ogx=00;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:*.doc=00;33:*.docx=00;33:*.odt=00;33:*.pdf=00;33:*.html=00;33';
  62. export LS_COLORS
  63. [ -f /etc/DIR_COLORS ] && eval $(dircolors -b /etc/DIR_COLORS)
  64. export ZLSCOLORS="${LS_COLORS}"
  65. zmodload zsh/complist
  66. zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
  67. zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
  68.  
  69. zstyle ':completion:*' completer _complete _match _approximate
  70. zstyle ':completion:*:match:*' original only
  71. zstyle ':completion:*:approximate:*' max-errors 1 numeric
  72.  
  73. compdef pkill=kill
  74. compdef pkill=killall
  75. zstyle ':completion:*:*:kill:*' menu yes select
  76. zstyle ':completion:*:processes' command 'ps -au$USER'
  77.  
  78. # Group matches and Describe
  79. zstyle ':completion:*:matches' group 'yes'
  80. zstyle ':completion:*:options' description 'yes'
  81. zstyle ':completion:*:options' auto-description '%d'
  82. zstyle ':completion:*:descriptions' format $'\e[01;33m -- %d --\e[0m'
  83. zstyle ':completion:*:messages' format $'\e[01;35m -- %d --\e[0m'
  84. zstyle ':completion:*:warnings' format $'\e[01;31m -- No Matches Found --\e[0m'
  85.  
  86. # command alias
  87. alias ls='ls -aF --color=auto'
  88. alias ll='ls -alh'
  89. alias grep='grep --color=auto'
  90. alias ec='emacsclient -n -a emacs'
  91. alias rm='rm -v'
  92. alias acp='acp -vgi'
  93. alias amv='amv -vgi'
  94. alias cp='cp -v'
  95. alias mv='mv -v'
  96. alias aleq='alsamixer -D equal'
  97. alias sp='sudo pacman'
  98. alias sy='yaourt'
  99. alias suu='sudo yaourt -Syyua'
  100. alias snn='sudo nano'
  101. alias scc='sudo pacman -Scc && sudo pacman-optimize'
  102. alias avscan='clamscan -i --bytecode-unsigned=yes -r --detect-pua=yes'
  103. alias bdscan='/opt/BitDefender-scanner/bin/bdscan'
  104. alias yt='/home/cristi/Downloads/youtube-downloader'
  105. alias 7z_ppmd='7z a -t7z -m0=ppmd -mx=9 -mo=32 -mmem=1024m -ms=on'
  106. alias 7z_lzma='7z a -t7z -m0=lzma -mx=9 -mfb=273 -md=1024m -ms=on'
  107. alias 7z_lzma2='7z a -t7z -m0=lzma2 -mx=9 -mfb=273 -md=1024m -ms=on'
  108. alias -g '...'='../..'
  109. alias -g '....'='../../..'
  110. #alias -g BG='& exit'
  111. #alias -g C='|wc -l'
  112. #alias -g G='|grep'
  113. #alias -g H='|head'
  114. #alias -g Hl=' --help |& less -r'
  115. #alias -g K='|keep'
  116. #alias -g L='|less'
  117. #alias -g LL='|& less -r'
  118. #alias -g M='|most'
  119. #alias -g N='&>/dev/null'
  120. #alias -g R='| tr A-z N-za-m'
  121. #alias -g SL='| sort | less'
  122. #alias -g S='| sort'
  123. #alias -g T='|tail'
  124. #alias -g V='| vim -'
  125.  
  126. function precmd {
  127.  
  128. local TERMWIDTH
  129. (( TERMWIDTH = ${COLUMNS} - 1 ))
  130.  
  131. ###
  132. # Truncate the path if it's too long.
  133.  
  134. PR_FILLBAR=""
  135. PR_PWDLEN=""
  136.  
  137. local promptsize=${#${(%):---(%n@%m:%d)----}}
  138. local pwdsize=${#${(%):-}}
  139.  
  140. if [[ "$promptsize + $pwdsize" -gt $TERMWIDTH ]]; then
  141. ((PR_PWDLEN=$TERMWIDTH - $promptsize))
  142. else
  143. PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $pwdsize)))..${PR_HBAR}.)}"
  144. fi
  145.  
  146. ###
  147. # Get APM info.
  148.  
  149. if which ibam > /dev/null; then
  150. PR_APM_RESULT=`ibam --percentbattery`
  151. elif which apm > /dev/null; then
  152. PR_APM_RESULT=`apm`
  153. fi
  154. }
  155.  
  156. setopt extended_glob
  157. preexec () {
  158. if [[ "$TERM" == "screen" ]]; then
  159. local CMD=${1[(wr)^(*=*|sudo|-*)]}
  160. echo -n "\ek$CMD\e\\"
  161. fi
  162. }
  163.  
  164. setprompt () {
  165. ###
  166. # Need this so the prompt will work.
  167.  
  168. setopt prompt_subst
  169.  
  170. ###
  171. # See if we can use colors.
  172.  
  173. autoload colors zsh/terminfo
  174. if [[ "$terminfo[colors]" -ge 8 ]]; then
  175. colors
  176. fi
  177. for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
  178. eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
  179. eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
  180. (( count = $count + 1 ))
  181. done
  182. PR_NO_COLOUR="%{$terminfo[sgr0]%}"
  183.  
  184. ###
  185. # See if we can use extended characters to look nicer.
  186.  
  187. typeset -A altchar
  188. set -A altchar ${(s..)terminfo[acsc]}
  189. PR_SET_CHARSET="%{$terminfo[enacs]%}"
  190. PR_SHIFT_IN="%{$terminfo[smacs]%}"
  191. PR_SHIFT_OUT="%{$terminfo[rmacs]%}"
  192. PR_HBAR=${altchar[q]:--}
  193. PR_ULCORNER=${altchar[l]:--}
  194. PR_LLCORNER=${altchar[m]:--}
  195. PR_LRCORNER=${altchar[j]:--}
  196. PR_URCORNER=${altchar[k]:--}
  197.  
  198. ###
  199. # Decide if we need to set titlebar text.
  200.  
  201. case $TERM in
  202. xterm*)
  203. PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}'
  204. ;;
  205. screen)
  206. PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}'
  207. ;;
  208. *)
  209. PR_TITLEBAR=''
  210. ;;
  211. esac
  212.  
  213. ###
  214. # Decide whether to set a screen title
  215. if [[ "$TERM" == "screen" ]]; then
  216. PR_STITLE=$'%{\ekzsh\e\\%}'
  217. else
  218. PR_STITLE=''
  219. fi
  220.  
  221. ###
  222. # APM detection
  223.  
  224. if which ibam > /dev/null; then
  225. PR_APM='$PR_RED${${PR_APM_RESULT[(f)1]}[(w)-2]}%%(${${PR_APM_RESULT[(f)3]}[(w)-1]})$PR_LIGHT_BLUE:'
  226. elif which apm > /dev/null; then
  227. PR_APM='$PR_RED${PR_APM_RESULT[(w)5,(w)6]/\% /%%}$PR_LIGHT_BLUE:'
  228. else
  229. PR_APM=''
  230. fi
  231.  
  232.  
  233.  
  234. path=(
  235. #"$HOME/bin/$MACHTYPE-$OSTYPE"
  236. #"$HOME/bin"
  237. /usr/local/bin
  238. /usr/local/sbin
  239. /usr/local/etc
  240. /sbin
  241. /etc
  242. /bin
  243. /usr/bin
  244. /usr/sbin
  245. /usr/ucb
  246. /usr/bsd
  247. /usr/X11/bin
  248. /usr/bin/X11
  249. /usr/local/X11/bin
  250. /usr/monash/X11/bin
  251. /usr/monash/bin
  252. /usr/monash/etc
  253. /usr/monash/gnu/bin
  254. /usr/monash/contrib/bin
  255. /usr/monash/contrib/etc
  256. /usr/monash/contrib/X11/bin
  257. /usr/local/contrib/lib/kde/bin
  258. /usr/local/tex/bin
  259. /usr/local/lib/zsh/scr
  260. /usr/monash/contrib/games
  261. /usr/local/games
  262. /usr/monash/games
  263. /usr/games
  264. /opt
  265. /usr/lib/ccache/bin/
  266. "$path[@]"
  267. "$fpath[@]"
  268. )
  269. export PATH
  270.  
  271. extract () {
  272. if [ -f $1 ] ; then
  273. case $1 in
  274. *.tar.bz2) tar xvjf $1 && cd $(basename "$1" .tar.bz2) ;;
  275. *.tar.gz) tar xvzf $1 && cd $(basename "$1" .tar.gz) ;;
  276. *.tar.xz) tar Jxvf $1 && cd $(basename "$1" .tar.xz) ;;
  277. *.tar) tar xvf $1 && cd $(basename "$1" .tar) ;;
  278. *.tbz2) tar xvjf $1 && cd $(basename "$1" .tbz2) ;;
  279. *.tgz) tar xvzf $1 && cd $(basename "$1" .tgz) ;;
  280. *.bz2) bunzip2 $1 && cd $(basename "$1" /bz2) ;;
  281. *.rar) unrar x $1 && cd $(basename "$1" .rar) ;;
  282. *.gz) gunzip $1 && cd $(basename "$1" .gz) ;;
  283. *.zip) unzip $1 && cd $(basename "$1" .zip) ;;
  284. *.Z) uncompress $1 && cd $(basename "$1" .Z) ;;
  285. *.7z) 7z x $1 && cd $(basename "$1" .7z) ;;
  286. *) echo "'$1' cannot be extracted via extract()" ;;
  287. esac
  288. else
  289. echo "'$1' is not a valid file!"
  290. fi
  291. }
  292.  
  293. docx(){
  294. if [ -f $1 ] ; then
  295. unzip -p $1 word/document.xml | sed -e 's/<[^>]\{1,\}>//g; s/[^[:print:]]\{1,\}//g'
  296. else
  297. echo "'$1' is not a valid file!"
  298. fi
  299. }
  300. ###
  301. # Finally, the prompt.
  302.  
  303. PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\
  304. $PR_WHITE$PR_SHIFT_IN$PR_ULCORNER$PR_WHITE$PR_HBAR$PR_SHIFT_OUT%\[$PR_GREEN%(!.%SROOT%s.%n$PR_WHITE @ $PR_RED%M$PR_WHITE] - \
  305. %\[$PR_YELLOW%d)$PR_WHITE]
  306. $PR_WHITE$PR_SHIFT_IN$PR_LLCORNER$PR_WHITE$PR_HBAR$PR_SHIFT_OUT$PR_WHITE%\[$PR_BLUE%*$PR_WHITE]$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
  307. $PR_WHITE$PR_SHIFT_IN%\[$PR_BLUE>$PR_WHITE]$PR_SHIFT_OUT$PR_NO_COLOUR'
  308. #RPROMPT='$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_CYAN$PR_LRCORNER$PR_SHIFT_OUT
  309. #$PR_NO_COLOUR'
  310. #PS2='$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
  311. #$PR_BLUE$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT(\
  312. #$PR_LIGHT_GREEN%_$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
  313. #$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT$PR_NO_COLOUR'
  314. }
  315.  
  316. setprompt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement