Advertisement
Guest User

Untitled

a guest
Aug 24th, 2012
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 9.18 KB | None | 0 0
  1. # {{{-> bindings                                    |
  2. bindkey -e
  3. bindkey "^[w" backward-delete-word
  4. bindkey "^[d" delete-word
  5. #bindkey "^[[2~" yank
  6. bindkey "^[[3~" delete-char
  7. bindkey "^[[5~" up-line-or-history
  8. bindkey "^[[6~" down-line-or-history
  9. bindkey "^[[1~" beginning-of-line
  10. bindkey "^[[4~" end-of-line
  11. bindkey "^[e" expand-cmd-path ## C-e for expanding path of typed command
  12. bindkey "^[[A" up-line-or-search ## up arrow for back-history-search
  13. bindkey "^[[B" down-line-or-search ## down arrow for fwd-history-search
  14. bindkey " " magic-space ## do history expansion on space
  15. bindkey "^[[2~" accept-and-menu-complete
  16. # }}}
  17. # {{{-> env & other                                 |
  18. # Use hard limits, except for a smaller stack and no core dumps
  19. unlimit
  20. limit stack 8192
  21. limit core 0
  22. limit -s
  23.  
  24. export GREP_COLOR='1;33'
  25. export GREP_OPTIONS=' --color=auto'
  26. export PAGER='less -iMSx4 -FX'
  27. export DOWNLOADER='axel'
  28. export EDITOR='vim'
  29.  
  30. export LESS_TERMCAP_mb=$'\E[01;31m'
  31. export LESS_TERMCAP_md=$'\E[01;31m'
  32. export LESS_TERMCAP_me=$'\E[0m'
  33. export LESS_TERMCAP_se=$'\E[0m'
  34. export LESS_TERMCAP_so=$'\E[01;44m'
  35. export LESS_TERMCAP_ue=$'\E[0m'
  36. if [ "`uname -s`" = 'FreeBSD' ] ; then
  37.         export LESS_TERMCAP_us=$'\E[04;34m'
  38. else
  39.         export LESS_TERMCAP_us=$'\E[04;38;5;146m'
  40.         export PATH="$HOME/bin:$PATH"
  41. fi
  42. if [[ -z "$DISPLAY" ]]; then
  43.         export WWW_BROWSER="links"
  44. else
  45.         export WWW_BROWSER='opera %s &!'
  46. fi
  47.  
  48. # }}}
  49. # {{{-> history                                     |
  50. HISTFILE=~/.zhistory
  51. HISTSIZE=500
  52. SAVEHIST=500
  53. setopt APPEND_HISTORY
  54. setopt HIST_IGNORE_ALL_DUPS
  55. setopt HIST_IGNORE_SPACE
  56. setopt HIST_REDUCE_BLANKS
  57. # }}}
  58. # {{{-> options                                     |
  59. setopt No_Beep AUTO_CONTINUE NO_CHECK_JOBS NO_HUP
  60. setopt notify globdots correct pushdtohome cdablevars autolist
  61. setopt autocd longlistjobs correctall
  62. setopt autoresume histignoredups pushdsilent clobber
  63. setopt autopushd pushdminus extendedglob rcquotes mailwarning
  64. unsetopt bgnice autoparamslash recexact menucomplete
  65.  
  66. zmodload -a zsh/stat stat
  67. zmodload -a zsh/zpty zpty
  68. zmodload -a zsh/zprof zprof
  69. zmodload -ap zsh/mapfile mapfile
  70. zmodload zsh/complist
  71.  
  72. umask 0022
  73. [ "`uname -s`" = 'FreeBSD' ] && hash -d etc=/usr/local/etc
  74. freload() { while (( $# )); do; unfunction $1; autoload -U $1; shift; done }
  75. autoload -U incremental-complete-word
  76. zle -N incremental-complete-word
  77. autoload -U insert-files
  78. zle -N insert-files
  79. autoload -U predict-on
  80. zle -N predict-on
  81. autoload -U pick-web-browser
  82. alias -s {html,htm}=pick-web-browser
  83. # }}}
  84. # {{{-> aliases                                     |
  85. alias -g G='|grep'
  86. alias -g M='|more'
  87. alias -g L='|less'
  88. alias -g H='|head'
  89. alias -g T='|tail'
  90. alias -g N='2>/dev/null'
  91. alias -g IW='| iconv -c -f cp1251 -t koi8r'
  92. alias -g IU='| iconv -c -f utf8 -t koi8r'
  93. alias -g B='|bc -l'
  94.  
  95. alias cp='nocorrect cp -vR'
  96. alias mv='nocorrect mv -v'
  97. alias rm='nocorrect rm -v'
  98. alias rmf='nocorrect rm -f'
  99. alias rmrf='nocorrect rm -fR'
  100.  
  101. alias grep='egrep'
  102. alias h='history'
  103. alias k='kill'
  104. alias less='less -M -R -S'
  105. alias ll='ls -lap'
  106. alias lsa='ls -ld .*'
  107. alias lsd='ls -ld'
  108. #alias mc='/root/temp/freebsd/bin/mc-wrapper.sh'
  109. alias mkdir='nocorrect mkdir -pv'
  110. alias mkisofs='mkisofs -J -joliet-long -l -max-iso9660-filenames'
  111. #alias cdrecord='cdrecord -v -dev=1,0,0'
  112. alias nb='nb -b /usr/local/www/qw3rty.org/data --conf-file /mnt/ad6s1e/www/qw3rty.org/nb/blog.conf --data-dir /mnt/ad6s1e/www/qw3rty.org/nb/data --template-dir /mnt/ad6s1e/www/qw3rty.org/nb/templates --no-preview'
  113. alias nr='netstat -rna'
  114. alias p='ping'
  115. alias pa='ps axuww'
  116. alias pg='pa | grep'
  117. #alias pwg='apg -a1 -M nl -n1 -m10'
  118. alias q='exit'
  119. #alias sc='screen -Amd'
  120. #alias scpm='NO_GUI=1 sc portmaster -BD'
  121. alias su='su -'
  122. alias ta='tail -f'
  123. alias tf='tcpdump -etr'
  124. alias ti='tcpdump -eti'
  125. alias tmux='EVENT_NOKQUEUE=1 tmux'
  126. alias ts='trafshow -R 1 -P 10000'
  127. alias vim='LC_MESSAGES=C vim'
  128.  
  129.  
  130. if [ "`uname -s`" = 'FreeBSD' ] ; then
  131.         alias ls='ls -G'
  132.         alias ni='netstat -bnhI'
  133.         alias pm='portmaster -BD'
  134.         alias spm='pm --show-work'
  135.         alias sg='sockstat | grep'
  136.         alias top='top -PSa'
  137.         alias w='w -n'
  138. else
  139.         alias ls='ls --color=auto'
  140.         alias sg='netstat -napA inet | grep'
  141.         alias top='htop'
  142. fi
  143. function cl() {
  144.         [[ -z "$1" ]] && ccze -A | less || ccze -A < "$1" | less
  145. }
  146. function tl() {
  147.         [[ -z "$1" ]] && tail | ccze -A || tail -f "$@"| ccze -A
  148. }
  149. function gr() {
  150.         cat | grep "$@" | grep -v grep | grep "$@"
  151. }
  152. function pwg() {
  153.         perl -e 'for (0..($ARGV[0] || 8)) { print $chars[int rand(@chars = split("","qwertyuiopasdfghjklzxcvbnm1234567890"))]; } print "\n";' $1
  154. }
  155. # }}}
  156. # {{{-> completion                                  |
  157. autoload -U zcalc
  158. autoload -U compinit promptinit
  159. compinit
  160. promptinit
  161.  
  162. zstyle ':completion:*' menu select=long-list select=0
  163. zstyle ':completion:*' verbose yes
  164. zstyle ':completion:*' old-menu false
  165. zstyle ':completion:*' original true
  166. zstyle ':completion:*' substitute 1
  167. zstyle ':completion:*' use-compctl true
  168. zstyle ':completion:*' verbose true
  169. zstyle ':completion:*' word true
  170. zstyle ':completion:*' group-name ''
  171. zstyle ':completion:*' insert-unambiguous true
  172. zstyle ':completion:*' add-space true
  173. # match uppercase from lowercase
  174. zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
  175. #zstyle ':completion:*' menu yes select
  176. zstyle ':completion:*::::' completer _expand _complete _approximate _list
  177. [ -f ~/.ssh/config ] && : ${(A)ssh_config_hosts:=${${${${(@M)${(f)"$(<~/.ssh/config)"}:#Host *}#Host }:#*\**}:#*\?*}}
  178. [ -f ~/.ssh/known_hosts ] && : ${(A)ssh_known_hosts:=${${${(f)"$(<$HOME/.ssh/known_hosts)"}%%\ *}%%,*}}
  179. zstyle ':completion:*:*:*' hosts $ssh_config_hosts $ssh_known_hosts
  180. # allow one error for every three characters typed in approximate completer
  181. zstyle -e ':completion:*:approximate:*' max-errors 'reply=( $(( ($#PREFIX+$#SUFFIX)/3 )) numeric )'
  182. # insert all expansions for expand completer
  183. zstyle ':completion:*:expand:*' tag-order all-expansions
  184. # formatting and messages
  185. zstyle ':completion:*:descriptions' format $'%{\e[0;31m%}completing %B%d%b%{\e[0m%}'
  186. zstyle ':completion:*:messages' format '%d'
  187. zstyle ':completion:*:warnings' format 'No matches for: %d'
  188. zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b'
  189. zstyle ':completion:*:manuals' separate-sections true
  190. #zstyle ':completion:*:man:*' menu yes select
  191. # offer indexes before parameters in subscripts
  192. zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
  193. zstyle ':completion:complete:*' use-cache 1
  194. # other
  195. zstyle ':completion:*:functions' ignored-patterns '_*'
  196. zstyle ':completion:*:default' list-colors 'no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;31:'
  197. zstyle ':completion:*:processes' command 'ps -axo pid,state,start,args'
  198. zstyle ':completion:*:processes-names' command 'ps xho command'
  199. zstyle ':completion:*:*:kill:*' menu yes select
  200. zstyle ':completion:*:kill:*' force-list always
  201. zstyle ':completion:*:*:kill:*:processes' list-colors "=(#b) #([0-9]#)*=36=31"
  202. # }}}
  203. # {{{-> prompt                                      |
  204. setprompt () {
  205.         setopt prompt_subst
  206.         autoload colors zsh/terminfo
  207.         if [[ "$terminfo[colors]" -ge 8 ]]; then
  208.                 colors
  209.         fi
  210.         for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
  211.                 eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
  212.                 eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
  213.                 (( count = $count + 1 ))
  214.         done
  215.         PR_NO_COLOUR="%{$terminfo[sgr0]%}"
  216.         typeset -A altchar
  217.         #    set -A altchar ${(s..)terminfo[acsc]}
  218.         #    PR_SET_CHARSET="%{$terminfo[enacs]%}"
  219.         PR_SHIFT_IN="%{$terminfo[smacs]%}"
  220.         PR_SHIFT_OUT="%{$terminfo[rmacs]%}"
  221.         PR_HBAR=${altchar[q]:--}
  222.         PR_ULCORNER=${altchar[l]:--}
  223.         PR_LLCORNER=${altchar[m]:--}
  224.         PR_LRCORNER=${altchar[j]:--}
  225.         PR_URCORNER=${altchar[k]:--}
  226.  
  227.         case $TERM in
  228.                 *xterm*|rxvt|(dt|k|E)term*)
  229.                         PR_TITLEBAR=$'%{\e]0;%n@%M:%~\a%}'
  230.                         stty erase '^?'
  231.                         ;;
  232.                 screen)
  233.                         #PR_TITLEBAR=$'%{\ek%n@%M:%~\e\\%}'
  234.                         #PR_TITLEBAR=$'%{\ekzsh\e\\%}'
  235.                         ;;
  236.                 *)
  237.                         PR_TITLEBAR=''
  238.                         ;;
  239.         esac
  240.         PROMPT='${PR_STITLE}${(e)PR_TITLEBAR}${PR_LIGHT_RED}%n${PR_LIGHT_YELLOW}@${PR_LIGHT_GREEN}%M${PR_LIGHT_YELLOW}:${PR_LIGHT_CYAN}[%~]${PR_LIGHT_RED}%#${PR_NO_COLOUR}'
  241.         #RPROMPT='${PR_LIGHT_GREEN}(%D{%H:%M:%S} %l${PR_LIGHT_GREEN})${PR_NO_COLOUR}'
  242.         RPROMPT='${PR_LIGHT_GREY}[%D{%H:%M:%S}/%l]${PR_NO_COLOUR}'
  243. }
  244. precmd () {
  245.         [[ -t 1 ]] || return
  246.         case $TERM in
  247.                 *xterm*|rxvt|(dt|k|E)term*)
  248.                 print -Pn "\e]2;%n@%M:%~\a"
  249.                 ;;
  250.                 screen)
  251.         esac
  252. }
  253. preexec () {
  254.         [[ -t 1 ]] || return
  255.         case $TERM in
  256.                 *xterm*|rxvt|(dt|k|E)term*)
  257.                 print -Pn "\e]2;%n@%M:%~ ($1)\a"
  258.                 ;;
  259.         esac
  260. }
  261. setprompt
  262. # }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement