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.0KB

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