Advertisement
TekhnoLife

.zshrc

May 29th, 2014
469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 8.99 KB | None | 0 0
  1. if [ -r ~/.zshrc -a -r ~/.zshrc.global -a ! -r ~/.zshrc.local ] ; then
  2.     printf '-!-\n'
  3.     printf '-!- Looks like you are using the old zshrc layout of grml.\n'
  4.     printf '-!- Please read the notes in the grml-zsh-refcard, being'
  5.     printf '-!- available at: http://grml.org/zsh/\n'
  6.     printf '-!-\n'
  7.     printf '-!- If you just want to get rid of this warning message execute:\n'
  8.     printf '-!-        touch ~/.zshrc.local\n'
  9.     printf '-!-\n'
  10. fi
  11. [ -r /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ] && source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
  12. [ -r /usr/share/doc/pkgfile/command-not-found.zsh ] && source /usr/share/doc/pkgfile/command-not-found.zsh
  13. which startx 2>&1 > /dev/null && alias startx="startx &> ~/.xlog"
  14.  
  15. # highlighting
  16. source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
  17. ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern)
  18. # brackets
  19. ZSH_HIGHLIGHT_STYLES[bracket-level-1]='fg=blue,bold'
  20. ZSH_HIGHLIGHT_STYLES[bracket-level-2]='fg=red,bold'
  21. ZSH_HIGHLIGHT_STYLES[bracket-level-3]='fg=yellow,bold'
  22. ZSH_HIGHLIGHT_STYLES[bracket-level-4]='fg=magenta,bold'
  23. # cursor
  24. #ZSH_HIGHLIGHT_STYLES[cursor]='bg=blue'
  25. # main
  26. # default
  27. ZSH_HIGHLIGHT_STYLES[default]='none'                                 # стандартный цвет
  28. # unknown
  29. ZSH_HIGHLIGHT_STYLES[unknown-token]='fg=red'                         # неизвестная команда
  30. # command
  31. ZSH_HIGHLIGHT_STYLES[reserved-word]='fg=magenta,bold'                # зарезервированное слово
  32. ZSH_HIGHLIGHT_STYLES[alias]='fg=yellow,bold'                         # алиас
  33. ZSH_HIGHLIGHT_STYLES[builtin]='fg=green,bold'                        # built-in функция (например, echo)
  34. ZSH_HIGHLIGHT_STYLES[function]='fg=green,bold'                       # функция, определенная в шелле
  35. ZSH_HIGHLIGHT_STYLES[command]='fg=green'                             # обычная команда
  36. ZSH_HIGHLIGHT_STYLES[precommand]='fg=blue,bold'                      # пре-команда (например, sudo в sudo cp ...)
  37. ZSH_HIGHLIGHT_STYLES[commandseparator]='fg=yellow'                   # разделитель команд, && || ;
  38. ZSH_HIGHLIGHT_STYLES[hashed-command]='fg=green'                      # команда, найденная в путях (hashed)
  39. ZSH_HIGHLIGHT_STYLES[single-hyphen-option]='fg=blue,bold'            # флаги типа -*
  40. ZSH_HIGHLIGHT_STYLES[double-hyphen-option]='fg=blue,bold'            # флаги типа --*
  41. # path
  42. ZSH_HIGHLIGHT_STYLES[path]='fg=cyan,bold'                            # станлартный путь
  43. ZSH_HIGHLIGHT_STYLES[path_prefix]='fg=cyan'                          # префикс пути
  44. ZSH_HIGHLIGHT_STYLES[path_approx]='fg=cyan'                          # примерный путь
  45. # shell
  46. ZSH_HIGHLIGHT_STYLES[globbing]='fg=cyan'                             # шаблон (например, /dev/sda*)
  47. ZSH_HIGHLIGHT_STYLES[history-expansion]='fg=blue'                    # подстановка из истории (команда, начинающаяся с !)
  48. ZSH_HIGHLIGHT_STYLES[assign]='fg=magenta'                            # присвоение
  49. ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]='fg=cyan'        # конструкции типа "$VARIABLE"
  50. ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]='fg=cyan'          # конструкции типа \"
  51. ZSH_HIGHLIGHT_STYLES[back-quoted-argument]='fg=blue'                 # конструкции типа `command`
  52. # quotes
  53. ZSH_HIGHLIGHT_STYLES[single-quoted-argument]='fg=yellow,underline'   # конструкции типа 'text'
  54. ZSH_HIGHLIGHT_STYLES[double-quoted-argument]='fg=yellow'             # конструкции типа "text"
  55. # pattern
  56. ZSH_HIGHLIGHT_PATTERNS+=('rm -rf *' 'fg=white,bold,bg=red')
  57. # root
  58. ZSH_HIGHLIGHT_STYLES[root]='bg=red'
  59. # bindkeys
  60. bindkey '^[[A'  up-line-or-search               # up arrow for back-history-search
  61. bindkey '^[[B'  down-line-or-search             # down arrow for fwd-history-search
  62. bindkey '\e[1~' beginning-of-line               # home
  63. bindkey '^[[2~' overwrite-mode                  # insert
  64. bindkey '^[[3~' delete-char                     # del
  65. bindkey '\e[4~' end-of-line                     # end
  66. bindkey '^[[5~' up-line-or-history              # page-up
  67. bindkey '^[[6~' down-line-or-history            # page-down
  68. bindkey "^[[1;5C" forward-word        # Ctrl-Right
  69. bindkey "^[[1;5D" backward-word       # Ctrl-Left
  70. bindkey '^[[H' beginning-of-line  # Home
  71. bindkey '^[[F' end-of-line        # End
  72. autoload -U compinit
  73. compinit
  74. zstyle ':completion:*' insert-tab false
  75. zstyle ':completion:*' max-errors 2
  76. zstyle :compinstall filename '/home/dmitry/.zshrc'
  77. autoload -Uz compinit
  78. compinit
  79. # End of lines added by compinstall
  80. # promptinit
  81. autoload -U promptinit
  82. promptinit
  83. # colors
  84. autoload -U colors
  85. colors
  86. # append history
  87. setopt APPEND_HISTORY
  88. # ignore dups in history
  89. setopt HIST_IGNORE_ALL_DUPS
  90. # ighore additional space in history
  91. setopt HIST_IGNORE_SPACE
  92. # reduce blanks in history
  93. setopt HIST_REDUCE_BLANKS
  94. # disable beeps
  95. unsetopt beep
  96. # pkgfile
  97. source /usr/share/doc/pkgfile/command-not-found.zsh
  98. # PROMPT && RPROMPT
  99. if [[ $EUID == 0 ]]; then
  100. # [root dir] #
  101.   PROMPT="%{$fg_bold[blue]%}%n%{$reset_color%} %{$fg_no_bold[yellow]%}%1~ %{$fg_bold[red]%}# %{$reset_color%}"
  102.   RPROMPT="[%{$fg_no_bold[yellow]%}%?%{$reset_color%}]"
  103. else
  104. # [user dir] $
  105.   PROMPT="%{$fg_bold[blue]%}%n%{$reset_color%} %{$fg_no_bold[yellow]%}%1~ %{$fg_bold[green]%}$ %{$reset_color%}"
  106.   RPROMPT="[%{$fg_no_bold[yellow]%}%?%{$reset_color%}]"
  107. fi
  108. su () {
  109.   checksu=0
  110.   for flags in $*; do
  111.     if [[ $flags == "-" ]]; then
  112.       checksu=1
  113.     fi
  114.   done
  115.   if [[ $checksu == 0 ]]; then
  116.     echo "Use 'su -', Luke"
  117.     /usr/bin/su - $*
  118.   else
  119.     /usr/bin/su $*
  120.   fi
  121. }
  122. # sudo alias
  123. if [[ $EUID == 0 ]]; then
  124.   alias fat32mnt='show_which fat32mnt && mount -t vfat -o codepage=866,iocharset=utf8,umask=000'
  125.   alias synctime='show_which synctime && { ntpd -qg; hwclock -w; date; }'
  126. else
  127.   alias fat32mnt='show_which fat32mnt && sudo mount -t vfat -o codepage=866,iocharset=utf8,umask=000'
  128.   alias umount='show_which umount && sudo umount'
  129.   alias mount='show_which mount && sudo mount'
  130.   alias netctl='show_which netctl && sudo netctl'
  131.   alias synctime='show_which synctime && { sudo ntpd -qg; sudo hwclock -w; date; }'
  132.   alias wifi-menu='show_which wifi-menu && sudo wifi-menu'
  133.   alias dhcpcd='show_which dhcpcd && sudo dhcpcd'
  134.   alias journalctl='show_which journalctl && sudo journalctl'
  135.   alias systemctl='show_which systemctl && sudo systemctl'
  136.   alias modprobe='show_which modprobe && sudo modprobe'
  137.   alias rmmod='show_which rmmod && sudo rmmod'
  138.   alias staging-i686-build='show_which staging-i686-build && sudo staging-i686-build'
  139.   alias staging-x86_64-build='show_which staging-x86_64-build && sudo staging-x86_64-build'
  140. fi
  141. # function to extract archives
  142. # EXAMPLE: unpack file
  143. unpack () {
  144.   if [[ -f $1 ]]; then
  145.     case $1 in
  146.       *.tar.bz2)   tar xjfv $1                             ;;
  147.       *.tar.gz)    tar xzfv $1                             ;;
  148.       *.tar.xz)    tar xvJf $1                             ;;
  149.       *.bz2)       bunzip2 $1                              ;;
  150.       *.gz)        gunzip $1                               ;;
  151.       *.rar)       unrar x $1                              ;;
  152.       *.tar)       tar xf $1                               ;;
  153.       *.tbz)       tar xjvf $1                             ;;
  154.       *.tbz2)      tar xjf $1                              ;;
  155.       *.tgz)       tar xzf $1                              ;;
  156.       *.zip)       unzip $1                                ;;
  157.       *.Z)         uncompress $1                           ;;
  158.       *.7z)        7z x $1                                 ;;
  159.       *)           echo "I don't know how to extract '$1'" ;;
  160.     esac
  161.   else
  162.     case $1 in
  163.       *help)       echo "Usage: unpack ARCHIVE_NAME"       ;;
  164.       *)           echo "'$1' is not a valid file"         ;;
  165.     esac
  166.   fi
  167. }
  168. aur() {
  169.   yaourt --noconfirm $*
  170. }
  171. # function to create archives
  172. # EXAMPLE: pack tar file
  173. pack () {
  174.   if [ $1 ]; then
  175.     case $1 in
  176.       tar.bz2)     tar -cjvf $2.tar.bz2 $2                 ;;
  177.       tar.gz)      tar -czvf $2.tar.bz2 $2                 ;;
  178.       tar.xz)      tar -cf - $2 | xz -9 -c - > $2.tar.xz   ;;
  179.       bz2)         bzip $2                                 ;;
  180.       gz)          gzip -c -9 -n $2 > $2.gz                ;;
  181.       tar)         tar cpvf $2.tar  $2                     ;;
  182.       tbz)         tar cjvf $2.tar.bz2 $2                  ;;
  183.       tgz)         tar czvf $2.tar.gz  $2                  ;;
  184.       zip)         zip -r $2.zip $2                        ;;
  185.       7z)          7z a $2.7z $2                           ;;
  186.       *help)       echo "Usage: pack TYPE FILES"           ;;
  187.       *)           echo "'$1' cannot be packed via pack()" ;;
  188.     esac
  189.   else
  190.     echo "'$1' is not a valid file"
  191.   fi
  192. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement