Advertisement
fredbezies

zshrc

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