Guest User

Untitled

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