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 4.9KB

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