.zshrc.local 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. # Filename: /etc/skel/.zshrc
  2. # Purpose: config file for zsh (z shell)
  3. # Authors: (c) grml-team (grml.org)
  4. # Bug-Reports: see http://grml.org/bugs/
  5. # License: This file is licensed under the GPL v2 or any later version.
  6. ################################################################################
  7. # Nowadays, grml's zsh setup lives in only *one* zshrc file.
  8. # That is the global one: /etc/zsh/zshrc (from grml-etc-core).
  9. # It is best to leave *this* file untouched and do personal changes to
  10. # your zsh setup via ${HOME}/.zshrc.local which is loaded at the end of
  11. # the global zshrc.
  12. #
  13. # That way, we enable people on other operating systems to use our
  14. # setup, too, just by copying our global zshrc to their ${HOME}/.zshrc.
  15. # Adjustments would still go to the .zshrc.local file.
  16. ################################################################################
  17. ## Inform users about upgrade path for grml's old zshrc layout, assuming that:
  18. ## /etc/skel/.zshrc was installed as ~/.zshrc,
  19. ## /etc/zsh/zshrc was installed as ~/.zshrc.global and
  20. ## ~/.zshrc.local does not exist yet.
  21. if [ -r ~/.zshrc -a -r ~/.zshrc.global -a ! -r ~/.zshrc.local ] ; then
  22. printf '-!-\n'
  23. printf '-!- Looks like you are using the old zshrc layout of grml.\n'
  24. printf '-!- Please read the notes in the grml-zsh-refcard, being'
  25. printf '-!- available at: http://grml.org/zsh/\n'
  26. printf '-!-\n'
  27. printf '-!- If you just want to get rid of this warning message execute:\n'
  28. printf '-!- touch ~/.zshrc.local\n'
  29. printf '-!-\n'
  30. fi
  31. ## Settings for umask
  32. #if (( EUID == 0 )); then
  33. # umask 002
  34. #else
  35. # umask 022
  36. #fi
  37. ## Now, we'll give a few examples of what you might want to use in your
  38. ## .zshrc.local file (just copy'n'paste and uncomment it there):
  39. ## Prompt theme extension ##
  40. # Virtualenv support
  41. #function virtual_env_prompt () {
  42. # REPLY=${VIRTUAL_ENV+(${VIRTUAL_ENV:t}) }
  43. #}
  44. #grml_theme_add_token virtual-env -f virtual_env_prompt '%F{magenta}' '%f'
  45. #zstyle ':prompt:grml:left:setup' items rc virtual-env change-root user at host path vcs percent
  46. ## ZLE tweaks ##
  47. ## use the vi navigation keys (hjkl) besides cursor keys in menu completion
  48. #bindkey -M menuselect 'h' vi-backward-char # left
  49. #bindkey -M menuselect 'k' vi-up-line-or-history # up
  50. #bindkey -M menuselect 'l' vi-forward-char # right
  51. #bindkey -M menuselect 'j' vi-down-line-or-history # bottom
  52. ## set command prediction from history, see 'man 1 zshcontrib'
  53. #is4 && zrcautoload predict-on && \
  54. #zle -N predict-on && \
  55. #zle -N predict-off && \
  56. #bindkey "^X^Z" predict-on && \
  57. #bindkey "^Z" predict-off
  58. ## press ctrl-q to quote line:
  59. #mquote () {
  60. # zle beginning-of-line
  61. # zle forward-word
  62. # # RBUFFER="'$RBUFFER'"
  63. # RBUFFER=${(q)RBUFFER}
  64. # zle end-of-line
  65. #}
  66. #zle -N mquote && bindkey '^q' mquote
  67. ## define word separators (for stuff like backward-word, forward-word, backward-kill-word,..)
  68. #WORDCHARS='*?_-.[]~=/&;!#$%^(){}<>' # the default
  69. #WORDCHARS=.
  70. #WORDCHARS='*?_[]~=&;!#$%^(){}'
  71. #WORDCHARS='${WORDCHARS:s@/@}'
  72. # just type '...' to get '../..'
  73. #rationalise-dot() {
  74. #local MATCH
  75. #if [[ $LBUFFER =~ '(^|/| | |'$'\n''|\||;|&)\.\.$' ]]; then
  76. # LBUFFER+=/
  77. # zle self-insert
  78. # zle self-insert
  79. #else
  80. # zle self-insert
  81. #fi
  82. #}
  83. #zle -N rationalise-dot
  84. #bindkey . rationalise-dot
  85. ## without this, typing a . aborts incremental history search
  86. #bindkey -M isearch . self-insert
  87. #bindkey '\eq' push-line-or-edit
  88. ## some popular options ##
  89. ## add `|' to output redirections in the history
  90. #setopt histallowclobber
  91. ## try to avoid the 'zsh: no matches found...'
  92. #setopt nonomatch
  93. ## warning if file exists ('cat /dev/null > ~/.zshrc')
  94. #setopt NO_clobber
  95. ## don't warn me about bg processes when exiting
  96. #setopt nocheckjobs
  97. ## alert me if something failed
  98. #setopt printexitvalue
  99. ## with spelling correction, assume dvorak kb
  100. #setopt dvorak
  101. ## Allow comments even in interactive shells
  102. #setopt interactivecomments
  103. ## compsys related snippets ##
  104. ## changed completer settings
  105. #zstyle ':completion:*' completer _complete _correct _approximate
  106. #zstyle ':completion:*' expand prefix suffix
  107. ## another different completer setting: expand shell aliases
  108. #zstyle ':completion:*' completer _expand_alias _complete _approximate
  109. ## to have more convenient account completion, specify your logins:
  110. #my_accounts=(
  111. # {grml,grml1}@foo.invalid
  112. # grml-devel@bar.invalid
  113. #)
  114. #other_accounts=(
  115. # {fred,root}@foo.invalid
  116. # vera@bar.invalid
  117. #)
  118. #zstyle ':completion:*:my-accounts' users-hosts $my_accounts
  119. #zstyle ':completion:*:other-accounts' users-hosts $other_accounts
  120. ## add grml.org to your list of hosts
  121. #hosts+=(grml.org)
  122. #zstyle ':completion:*:hosts' hosts $hosts
  123. ## telnet on non-default ports? ...well:
  124. ## specify specific port/service settings:
  125. #telnet_users_hosts_ports=(
  126. # user1@host1:
  127. # user2@host2:
  128. # @mail-server:{smtp,pop3}
  129. # @news-server:nntp
  130. # @proxy-server:8000
  131. #)
  132. #zstyle ':completion:*:*:telnet:*' users-hosts-ports $telnet_users_hosts_ports
  133. ## the default grml setup provides '..' as a completion. it does not provide
  134. ## '.' though. If you want that too, use the following line:
  135. #zstyle ':completion:*' special-dirs true
  136. ## aliases ##
  137. ## translate
  138. #alias u='translate -i'
  139. ## ignore ~/.ssh/known_hosts entries
  140. #alias insecssh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null" -o "PreferredAuthentications=keyboard-interactive"'
  141. ## global aliases (for those who like them) ##
  142. #alias -g '...'='../..'
  143. #alias -g '....'='../../..'
  144. #alias -g BG='& exit'
  145. #alias -g C='|wc -l'
  146. #alias -g G='|grep'
  147. #alias -g H='|head'
  148. #alias -g Hl=' --help |& less -r'
  149. #alias -g K='|keep'
  150. #alias -g L='|less'
  151. #alias -g LL='|& less -r'
  152. #alias -g M='|most'
  153. #alias -g N='&>/dev/null'
  154. #alias -g R='| tr A-z N-za-m'
  155. #alias -g SL='| sort | less'
  156. #alias -g S='| sort'
  157. #alias -g T='|tail'
  158. #alias -g V='| vim -'
  159. ## instead of global aliase it might be better to use grmls $abk assoc array, whose contents are expanded after pressing ,.
  160. #$abk[SnL]="| sort -n | less"
  161. ## get top 10 shell commands:
  162. #alias top10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
  163. ## Execute \kbd{./configure}
  164. #alias CO="./configure"
  165. ## Execute \kbd{./configure --help}
  166. #alias CH="./configure --help"
  167. ## miscellaneous code ##
  168. ## Use a default width of 80 for manpages for more convenient reading
  169. #export MANWIDTH=${MANWIDTH:-80}
  170. ## Set a search path for the cd builtin
  171. #cdpath=(.. ~)
  172. ## variation of our manzsh() function; pick you poison:
  173. #manzsh() { /usr/bin/man zshall | most +/"$1" ; }
  174. ## Switching shell safely and efficiently? http://www.zsh.org/mla/workers/2001/msg02410.html
  175. #bash() {
  176. # NO_SWITCH="yes" command bash "$@"
  177. #}
  178. #restart () {
  179. # exec $SHELL $SHELL_ARGS "$@"
  180. #}
  181. ## Handy functions for use with the (e::) globbing qualifier (like nt)
  182. #contains() { grep -q "$*" $REPLY }
  183. #sameas() { diff -q "$*" $REPLY &>/dev/null }
  184. #ot () { [[ $REPLY -ot ${~1} ]] }
  185. ## get_ic() - queries imap servers for capabilities; real simple. no imaps
  186. #ic_get() {
  187. # emulate -L zsh
  188. # local port
  189. # if [[ ! -z $1 ]] ; then
  190. # port=${2:-143}
  191. # print "querying imap server on $1:${port}...\n";
  192. # print "a1 capability\na2 logout\n" | nc $1 ${port}
  193. # else
  194. # print "usage:\n $0 <imap-server> [port]"
  195. # fi
  196. #}
  197. ## List all occurrences of programm in current PATH
  198. #plap() {
  199. # emulate -L zsh
  200. # if [[ $# = 0 ]] ; then
  201. # echo "Usage: $0 program"
  202. # echo "Example: $0 zsh"
  203. # echo "Lists all occurrences of program in the current PATH."
  204. # else
  205. # ls -l ${^path}/*$1*(*N)
  206. # fi
  207. #}
  208. ## Find out which libs define a symbol
  209. #lcheck() {
  210. # if [[ -n "$1" ]] ; then
  211. # nm -go /usr/lib/lib*.a 2>/dev/null | grep ":[[:xdigit:]]\{8\} . .*$1"
  212. # else
  213. # echo "Usage: lcheck <function>" >&2
  214. # fi
  215. #}
  216. ## Download a file and display it locally
  217. #uopen() {
  218. # emulate -L zsh
  219. # if ! [[ -n "$1" ]] ; then
  220. # print "Usage: uopen \$URL/\$file">&2
  221. # return 1
  222. # else
  223. # FILE=$1
  224. # MIME=$(curl --head $FILE | \
  225. # grep Content-Type | \
  226. # cut -d ' ' -f 2 | \
  227. # cut -d\; -f 1)
  228. # MIME=${MIME%$'\r'}
  229. # curl $FILE | see ${MIME}:-
  230. # fi
  231. #}
  232. ## Memory overview
  233. #memusage() {
  234. # ps aux | awk '{if (NR > 1) print $5;
  235. # if (NR > 2) print "+"}
  236. # END { print "p" }' | dc
  237. #}
  238. ## print hex value of a number
  239. #hex() {
  240. # emulate -L zsh
  241. # if [[ -n "$1" ]]; then
  242. # printf "%x\n" $1
  243. # else
  244. # print 'Usage: hex <number-to-convert>'
  245. # return 1
  246. # fi
  247. #}
  248. ## log out? set timeout in seconds...
  249. ## ...and do not log out in some specific terminals:
  250. #if [[ "${TERM}" == ([Exa]term*|rxvt|dtterm|screen*) ]] ; then
  251. # unset TMOUT
  252. #else
  253. # TMOUT=1800
  254. #fi
  255. ## associate types and extensions (be aware with perl scripts and anwanted behaviour!)
  256. #check_com zsh-mime-setup || { autoload zsh-mime-setup && zsh-mime-setup }
  257. #alias -s pl='perl -S'
  258. ## ctrl-s will no longer freeze the terminal.
  259. #stty erase "^?"
  260. ## you want to automatically use a bigger font on big terminals?
  261. #if [[ "$TERM" == "xterm" ]] && [[ "$LINES" -ge 50 ]] && [[ "$COLUMNS" -ge 100 ]] && [[ -z "$SSH_CONNECTION" ]] ; then
  262. # large
  263. #fi
  264. ## Some quick Perl-hacks aka /useful/ oneliner
  265. #bew() { perl -le 'print unpack "B*","'$1'"' }
  266. #web() { perl -le 'print pack "B*","'$1'"' }
  267. #hew() { perl -le 'print unpack "H*","'$1'"' }
  268. #weh() { perl -le 'print pack "H*","'$1'"' }
  269. #pversion() { perl -M$1 -le "print $1->VERSION" } # i. e."pversion LWP -> 5.79"
  270. #getlinks () { perl -ne 'while ( m/"((www|ftp|http):\/\/.*?)"/gc ) { print $1, "\n"; }' $* }
  271. #gethrefs () { perl -ne 'while ( m/href="([^"]*)"/gc ) { print $1, "\n"; }' $* }
  272. #getanames () { perl -ne 'while ( m/a name="([^"]*)"/gc ) { print $1, "\n"; }' $* }
  273. #getforms () { perl -ne 'while ( m:(\</?(input|form|select|option).*?\>):gic ) { print $1, "\n"; }' $* }
  274. #getstrings () { perl -ne 'while ( m/"(.*?)"/gc ) { print $1, "\n"; }' $*}
  275. #getanchors () { perl -ne 'while ( m/«([^«»\n]+)»/gc ) { print $1, "\n"; }' $* }
  276. #showINC () { perl -e 'for (@INC) { printf "%d %s\n", $i++, $_ }' }
  277. #vimpm () { vim `perldoc -l $1 | sed -e 's/pod$/pm/'` }
  278. #vimhelp () { vim -c "help $1" -c on -c "au! VimEnter *" }
  279. ## END OF FILE #################################################################
  280. #
  281. source ~/.zshrc.alias
  282. # source /etc/zsh_command_not_found
  283. #export PATH=~/.config/composer/vendor/bin:$PATH
  284. #export PATH=~/utils:$PATH
  285. #export PATH=/usr/local/go/bin:$PATH
  286. #export PATH=~/go/bin:$PATH
  287. #export PATH=$PATH:/opt/mssql-tools/bin/
  288. # customize vcs_info
  289. zstyle ':vcs_info:git*:*' check-for-changes true
  290. zstyle ':vcs_info:git*:*' unstagedstr ' %F{red}•'
  291. zstyle ':vcs_info:git*:*' stagedstr ' %F{yellow}•'
  292. # enable hooks, requires Zsh >=4.3.11
  293. if [[ $ZSH_VERSION == 4.3.<11->* || $ZSH_VERSION == 4.<4->* || $ZSH_VERSION == <5->* ]] ; then
  294. # hook for untracked files
  295. +vi-untracked() {
  296. if [[ $(git rev-parse --is-inside-work-tree 2>/dev/null) == 'true' ]] && \
  297. [[ -n $(git ls-files --others --exclude-standard) ]] ; then
  298. hook_com[staged]+=' %F{red}•'
  299. fi
  300. }
  301. # unpushed commits
  302. +vi-outgoing() {
  303. local gitdir="$(git rev-parse --git-dir 2>/dev/null)"
  304. [ -n "$gitdir" ] || return 0
  305. if [ -r "${gitdir}/refs/remotes/git-svn" ] ; then
  306. local count=$(git rev-list remotes/git-svn.. 2>/dev/null | wc -l)
  307. else
  308. local branch="$(cat ${gitdir}/HEAD 2>/dev/null)"
  309. branch=${branch##*/heads/}
  310. local count=$(git rev-list remotes/origin/${branch}.. 2>/dev/null | wc -l | xargs)
  311. fi
  312. if [[ "$count" -gt 0 ]] ; then
  313. hook_com[staged]+="%F{cyan} $count"
  314. fi
  315. }
  316. # hook for stashed files
  317. +vi-stashed() {
  318. if git rev-parse --verify refs/stash &>/dev/null ; then
  319. hook_com[staged]+=' %F{cyan}•'
  320. fi
  321. }
  322. zstyle ':vcs_info:git*+set-message:*' hooks stashed untracked outgoing
  323. fi
  324. # required for *formats in vcs_info, see below
  325. BLUE="%F{blue}"
  326. RED="%F{red}"
  327. GREEN="%F{green}"
  328. CYAN="%F{cyan}"
  329. MAGENTA="%F{magenta}"
  330. YELLOW="%F{yellow}"
  331. WHITE="%F{white}"
  332. NO_COLOR="%f"
  333. # extend default vcs_info in prompt
  334. zstyle ':vcs_info:*' actionformats "${MAGENTA}(${NO_COLOR}%s${MAGENTA})${YELLOW}-${MAGENTA}[${GREEN}%b${YELLOW}|${RED}%a%u%c${MAGENTA}]${NO_COLOR} " "zsh: %r"
  335. zstyle ':vcs_info:*' formats "${MAGENTA}(${NO_COLOR}%s${MAGENTA})${YELLOW}-${MAGENTA}[${GREEN}%b%u%c${MAGENTA}]${NO_COLOR}%} " "zsh: %r"
  336. setopt HIST_IGNORE_SPACE
  337. # ps -p $SSH_AGENT_PID > /dev/null || eval `ssh-agent -s`
  338. # ssh-add -l | grep sevikgr > /dev/null 2>&1 || (echo "Adding ssh-key to ssh-agent"; ssh-add)
  339. #
  340. [ ! -d ~/.ssh ] && mkdir ~/.ssh
  341. if [ ! -S ~/.ssh/ssh_auth_sock ]; then
  342. eval `ssh-agent -s`
  343. ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock
  344. fi
  345. export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock
  346. ssh-add -l > /dev/null 2>&1 || ssh-add