My personal dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

.zshrc 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. ##
  2. ## E N V I R O N M E N T
  3. ##
  4. export PAGER='less -R'
  5. export GOROOT=/usr/lib/go
  6. export GOPATH=$HOME/Projects/go
  7. if which virtualenvwrapper.sh 2>&1 > /dev/null; then
  8. source virtualenvwrapper.sh
  9. fi
  10. export GPG_TTY="$(tty)"
  11. export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
  12. gpgconf --create-socketdir
  13. gpg-connect-agent updatestartuptty /bye > /dev/null
  14. ##
  15. ## S E T T I N G S
  16. ##
  17. # Vi mode
  18. bindkey -v
  19. # Enable Ctrl-x e to edit command line in editor
  20. autoload -U edit-command-line
  21. # Enable colors
  22. autoload -U colors && colors
  23. # enable colored output from ls, etc. on FreeBSD-based systems
  24. export CLICOLOR=1
  25. # awesome cd movements from zshkit
  26. setopt autopushd pushdminus pushdsilent pushdtohome
  27. DIRSTACKSIZE=5
  28. # Enable extended globbing
  29. setopt extendedglob
  30. # Allow [ or ] whereever you want
  31. unsetopt nomatch
  32. # Allow bash style comments
  33. setopt interactivecomments
  34. # Setup zsh path
  35. fpath=(
  36. ~/.zsh/prompt/
  37. $fpath)
  38. # Set vim as default editor
  39. export EDITOR='vim'
  40. export VISUAL='vim'
  41. ## History
  42. HISTFILE=$HOME/.zhistory # enable history saving on shell exit
  43. setopt APPEND_HISTORY # append rather than overwrite history file.
  44. HISTSIZE=1200 # lines of history to maintain memory
  45. SAVEHIST=1000 # lines of history to maintain in history file.
  46. setopt HIST_EXPIRE_DUPS_FIRST # allow dups, but expire old ones when I hit HISTSIZE
  47. setopt EXTENDED_HISTORY # save timestamp and runtime information
  48. # Adds case insensitivity
  49. zstyle ':completion:*' completer _complete
  50. zstyle ':completion:*' matcher-list '' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' '+l:|=* r:|=*'
  51. # Color completion folders
  52. zstyle -e ':completion:*:default' list-colors 'reply=("${PREFIX:+=(#bi)($PREFIX:t)(?)*==34=34}:${(s.:.)LS_COLORS}")';
  53. # Kill colors
  54. zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
  55. zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
  56. # Option colors
  57. zstyle ':completion:*:options' list-colors '=^(-- *)=34'
  58. # Highlights current option
  59. zstyle ':completion:*' menu select
  60. autoload -Uz compinit
  61. compinit -i
  62. # Nice auto correct prompt
  63. setopt correct
  64. autoload -U colors && colors
  65. export SPROMPT="Correct $fg[red]%R$reset_color to $fg[green]%r?$reset_color (Yes, No, Abort, Edit) "
  66. # Colorify man
  67. function man() {
  68. env \
  69. LESS_TERMCAP_mb=$(printf "\e[1;31m") \
  70. LESS_TERMCAP_md=$(printf "\e[1;31m") \
  71. LESS_TERMCAP_me=$(printf "\e[0m") \
  72. LESS_TERMCAP_se=$(printf "\e[0m") \
  73. LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
  74. LESS_TERMCAP_ue=$(printf "\e[0m") \
  75. LESS_TERMCAP_us=$(printf "\e[1;32m") \
  76. man "$@"
  77. }
  78. ##
  79. ## T W E A K S
  80. ##
  81. fancy-ctrl-z () {
  82. if [[ $#BUFFER -eq 0 ]]; then
  83. BUFFER="fg"
  84. zle accept-line
  85. else
  86. zle push-input
  87. zle clear-screen
  88. fi
  89. }
  90. zle -N fancy-ctrl-z
  91. bindkey '^Z' fancy-ctrl-z
  92. ##
  93. ## K E Y B I N D I N G S
  94. ##
  95. bindkey '^P' up-history
  96. bindkey '^N' down-history
  97. # backspace and ^h working even after
  98. # returning from command mode
  99. bindkey '^?' backward-delete-char
  100. bindkey '^h' backward-delete-char
  101. # ctrl-w removed word backwards
  102. bindkey '^w' backward-kill-word
  103. backward-kill-dir () {
  104. local WORDCHARS=${WORDCHARS/\/}
  105. zle backward-kill-word
  106. }
  107. zle -N backward-kill-dir
  108. bindkey '^[^?' backward-kill-dir
  109. # ctrl-r starts searching history backward
  110. bindkey '^r' history-incremental-search-backward
  111. # VI MODE KEYBINDINGS (ins mode)
  112. bindkey -M viins '^a' beginning-of-line
  113. bindkey -M viins '^e' end-of-line
  114. bindkey -M viins '^k' kill-line
  115. bindkey -M viins '^w' backward-kill-word
  116. bindkey -M viins '^u' backward-kill-line
  117. zle -N edit-command-line
  118. bindkey -M viins '^xe' edit-command-line
  119. bindkey -M viins '^x^e' edit-command-line
  120. ##
  121. ## A L I A S E S
  122. ##
  123. # Misc
  124. alias :q='exit'
  125. alias less='less -R'
  126. alias grep='grep --color=always'
  127. alias pacaur='pacaur --color=always'
  128. alias open='xdg-open'
  129. alias wttr='~/bin/weather'
  130. alias ducolor='cdu -i -s -dh'
  131. alias yp='echo You meant to use yay!'
  132. # List directory contents
  133. alias lsa='ls -lah --color'
  134. alias l='ls --color'
  135. alias ll='ls -lh --color'
  136. alias la='ls -A --color'
  137. alias ls='ls --color'
  138. # Push and pop directories on directory stack
  139. alias md='mkdir -p'
  140. alias rd=rmdir
  141. alias d='dirs -v | head -10'
  142. alias -g ...='../..'
  143. alias -g ....='../../..'
  144. alias -g .....='../../../..'
  145. alias -g ......='../../../../..'
  146. # Emacs clients
  147. alias e='emacs -nw'
  148. alias et='emacsclient -t'
  149. alias ec='emacsclient -c'
  150. qemu () {
  151. $(which qemu-system-x86_64) "$@" 2>&1 | grep -v "Gtk-WARNING"
  152. }
  153. pgrepk () {
  154. pgrep -i $1 | xargs kill -9
  155. }
  156. ##
  157. ## P R O M P T
  158. ##
  159. _newline=$'\n'
  160. _lineup=$'\e[1A'
  161. _linedown=$'\e[1B'
  162. function preexec() {
  163. echo
  164. }
  165. function precmd() {
  166. echo
  167. }
  168. function promptjobs() {
  169. jobs %% 2> /dev/null | cut -d " " -f6
  170. }
  171. PROMPT="%F{red}%n%F{white}@%F{green}%m %F{blue}%~ ${_newline}%F{white}$ "
  172. RPROMPT='%{${_lineup}%}%F{red}%(?..%? )%F{yellow}%v%F{white}$(promptjobs) [`date +%H:%M:%S`]%{${_linedown}%}'
  173. setopt promptsubst
  174. # Delay of 0.1 seconds
  175. export KEYTIMEOUT=1
  176. source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
  177. ##
  178. ## E N D
  179. ##
  180. # FZF custom options
  181. if [ -f ~/.fzf.zsh ] && which tree > /dev/null 2>&1; then
  182. source ~/.fzf.zsh
  183. export FZF_CTRL_T_OPTS="--preview '(highlight -O ansi -l {} 2> /dev/null || cat {} || tree -C {}) 2> /dev/null | head -200'"
  184. export FZF_ALT_C_OPTS="--preview 'tree -C {} | head -200'"
  185. fi
  186. [ -f ~/.travis/travis.sh ] && source ~/.travis/travis.sh