dotfiles

beau's configuration files
git clone https://git.beauhilton.com/dotfiles.git
Log | Files | Refs | README

.zshrc (4173B)


      1 autoload -U colors && colors	# Load colors
      2 
      3 setopt autocd		# Automatically cd into typed directory.
      4 setopt SHARE_HISTORY
      5 setopt HIST_IGNORE_ALL_DUPS
      6 stty stop undef		# Disable ctrl-s to freeze terminal.
      7 
      8 # History in cache directory:
      9 HISTSIZE=1000000
     10 SAVEHIST=1000000
     11 HISTFILE=~/.cache/zsh/history
     12 
     13 # don't add garbage to history
     14 function hist() {
     15     [[ "$#1" -lt 7 \
     16     || "$1" = "run-help "* \
     17     || "$1" = "cd "* \
     18     || "$1" = "man "* \
     19 	|| "$1" = "h "* \
     20     || "$1" = "~ "* ]]
     21     return $(( 1 - $? ))
     22 }
     23 # Load aliases and shortcuts if existent.
     24 [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/aliasrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/aliasrc"
     25 [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/zshnameddirrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/zshnameddirrc"
     26 
     27 # Basic auto/tab complete:
     28 autoload -U compinit
     29 zstyle ':completion:*' menu select
     30 zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
     31 
     32 zmodload zsh/complist
     33 compinit
     34 _comp_options+=(globdots)		# Include hidden files.
     35 
     36 # vi mode
     37 bindkey -v
     38 export KEYTIMEOUT=1
     39 
     40 # Enable searching through history
     41 bindkey '^R' history-incremental-pattern-search-backward
     42 
     43 # Use vim keys in tab complete menu:
     44 bindkey -M menuselect 'h' vi-backward-char
     45 bindkey -M menuselect 'k' vi-up-line-or-history
     46 bindkey -M menuselect 'l' vi-forward-char
     47 bindkey -M menuselect 'j' vi-down-line-or-history
     48 bindkey -v '^?' backward-delete-char
     49 
     50 # Change cursor shape for different vi modes.
     51 function zle-keymap-select {
     52   if [[ ${KEYMAP} == vicmd ]] ||
     53      [[ $1 = 'block' ]]; then
     54     echo -ne '\e[1 q'
     55   elif [[ ${KEYMAP} == main ]] ||
     56        [[ ${KEYMAP} == viins ]] ||
     57        [[ ${KEYMAP} = '' ]] ||
     58        [[ $1 = 'beam' ]]; then
     59     echo -ne '\e[5 q'
     60   fi
     61 }
     62 
     63 zle -N zle-keymap-select
     64 
     65 # ci", ci', ci`, di", etc
     66 autoload -U select-quoted
     67 zle -N select-quoted
     68 for m in visual viopp; do
     69   for c in {a,i}{\',\",\`}; do
     70     bindkey -M $m $c select-quoted
     71   done
     72 done
     73 
     74 # ci{, ci(, ci<, di{, etc
     75 autoload -U select-bracketed
     76 zle -N select-bracketed
     77 for m in visual viopp; do
     78   for c in {a,i}${(s..)^:-'()[]{}<>bB'}; do
     79     bindkey -M $m $c select-bracketed
     80   done
     81 done
     82 
     83 zle-line-init() {
     84     zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)
     85     echo -ne "\e[5 q"
     86 }
     87 
     88 zle -N zle-line-init
     89 
     90 echo -ne '\e[5 q' # Use beam shape cursor on startup.
     91 preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.
     92 
     93 bindkey -s '^o' 'lfcd\n'
     94 bindkey -s '^a' 'bc -l\n'
     95 bindkey -s '^f' 'cd "$(dirname "$(fzf)")"\n'
     96 bindkey '^[[P' delete-char
     97 
     98 # Edit line in vim with ctrl-e:
     99 autoload edit-command-line; zle -N edit-command-line
    100 bindkey '^e' edit-command-line
    101 
    102 # Load zsh-syntax-highlighting
    103 source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 2>/dev/null
    104 
    105 # Suggest aliases for commands
    106 source /usr/share/zsh/plugins/zsh-you-should-use/you-should-use.plugin.zsh 2>/dev/null
    107 
    108 # Search repos for programs that can't be found
    109 source /usr/share/doc/pkgfile/command-not-found.zsh 2>/dev/null
    110 
    111 # fix dircolors for Selenized
    112 export LS_COLORS="$LS_COLORS:ow=1;7;34:st=30;44:su=30;41"
    113 
    114 SPACESHIP_PROMPT_ADD_NEWLINE=false
    115 SPACESHIP_PROMPT_SEPARATE_LINE=false
    116 SPACESHIP_CHAR_SYMBOL=
    117 SPACESHIP_CHAR_SUFFIX=
    118 SPACESHIP_USER_SHOW=false
    119 SPACESHIP_HOST_SHOW=false
    120 SPACESHIP_GIT_SHOW=false
    121 
    122 SPACESHIP_DIR_SHOW=true
    123 SPACESHIP_DIR_COLOR=#777777
    124 SPACESHIP_CONDA_SHOW=true
    125 SPACESHIP_VENV_SHOW=true
    126 SPACESHIP_PYENV_SHOW=true
    127 
    128 SPACESHIP_HG_SHOW=false
    129 SPACESHIP_PACKAGE_SHOW=false
    130 SPACESHIP_NODE_SHOW=false
    131 SPACESHIP_RUBY_SHOW=false
    132 SPACESHIP_ELM_SHOW=false
    133 SPACESHIP_ELIXIR_SHOW=false
    134 SPACESHIP_XCODE_SHOW_LOCAL=false
    135 SPACESHIP_SWIFT_SHOW_LOCAL=false
    136 SPACESHIP_GOLANG_SHOW=false
    137 SPACESHIP_PHP_SHOW=false
    138 SPACESHIP_RUST_SHOW=false
    139 SPACESHIP_JULIA_SHOW=false
    140 SPACESHIP_DOCKER_SHOW=false
    141 SPACESHIP_DOCKER_CONTEXT_SHOW=false
    142 SPACESHIP_AWS_SHOW=false
    143 SPACESHIP_DOTNET_SHOW=false
    144 SPACESHIP_EMBER_SHOW=false
    145 SPACESHIP_KUBECONTEXT_SHOW=false
    146 SPACESHIP_TERRAFORM_SHOW=false
    147 SPACESHIP_TERRAFORM_SHOW=false
    148 SPACESHIP_VI_MODE_SHOW=false
    149 SPACESHIP_JOBS_SHOW=false
    150 
    151 # Spaceship Prompt
    152 autoload -U promptinit; promptinit
    153 prompt spaceship
    154