zshrc (2349B) - raw


      1 # vim: filetype=zsh
      2 
      3 # load colors and set up prompt
      4 autoload -U colors && colors
      5 setopt PROMPT_SUBST
      6 
      7 # prompt
      8 git-head-abbrev() {
      9     c="$(git rev-parse --abbrev-ref HEAD 2>/dev/null)"
     10     if [ "$c" = "HEAD" ]; then
     11         c="$(git describe --tags 2>/dev/null)"
     12         [ -z "$c" ] && c="$(git rev-parse --short HEAD 2>/dev/null)"
     13     fi
     14     [ -n "$c" ] && printf " ($c)"
     15 }
     16 PS1='%B%{$fg[magenta]%}%n%{$fg[blue]%}@%{$fg[green]%}%m %{$fg[yellow]%}%~%b%{$fg[cyan]%}$(git-head-abbrev)%{$fg[red]%}%(!.#.$)%{$reset_color%} '
     17 
     18 # set up history and history file
     19 HISTSIZE=100000
     20 SAVEHIST=100000
     21 HISTFILE=~/.cache/zsh/history
     22 
     23 setopt HIST_IGNORE_DUPS
     24 setopt HIST_FIND_NO_DUPS
     25 setopt EXTENDED_HISTORY
     26 
     27 # set up navigation menu when pressing tab multiple times
     28 autoload -U compinit
     29 zstyle ':completion:*' menu select
     30 zmodload zsh/complist
     31 compinit -d ~/.cache/zsh/zcompdump
     32 #_comp_options+=(globdots)
     33 
     34 # auto complete case insensitive
     35 zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
     36 
     37 # set up vi style keys
     38 bindkey -v
     39 export KEYTIMEOUT=1
     40 
     41 # also set vi keys to navigate the menus when double pressing tab
     42 bindkey -M menuselect 'h' vi-backward-char
     43 bindkey -M menuselect 'k' vi-up-line-or-history
     44 bindkey -M menuselect 'l' vi-forward-char
     45 bindkey -M menuselect 'j' vi-down-line-or-history
     46 
     47 [ -f "$XDG_CONFIG_HOME/zsh/aliases" ] && source "$XDG_CONFIG_HOME/zsh/aliases"
     48 [ -f "$XDG_CONFIG_HOME/zsh/host-$(hostname -s)" ] && source "$XDG_CONFIG_HOME/zsh/host-$(hostname -s)"
     49 
     50 # source fzf key bindings
     51 if [ -f "/usr/share/fzf/key-bindings.zsh" ]; then # arch
     52     source "/usr/share/fzf/key-bindings.zsh" 2> /dev/null
     53 elif [ -f "/usr/share/doc/fzf/examples/key-bindings.zsh" ]; then # debian
     54     source "/usr/share/doc/fzf/examples/key-bindings.zsh" 2> /dev/null
     55 elif [ -f "/usr/share/fzf/shell/key-bindings.zsh" ]; then # fedora
     56     source "/usr/share/fzf/shell/key-bindings.zsh" 2> /dev/null
     57 fi
     58 
     59 # highlighting plug-in
     60 if [ -f "/usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]; then # arch and debian
     61     source "/usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" 2> /dev/null
     62 elif [ -f "/usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]; then # fedora
     63     source "/usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" 2> /dev/null
     64 fi