2017-11-15 23:06:29 +00:00
|
|
|
# Config and cache directory paths
|
2020-08-10 20:58:23 +00:00
|
|
|
ZSH_DIR="$XDG_CONFIG_HOME/zsh"
|
|
|
|
LOG_DIR="$XDG_DATA_HOME/logs"
|
|
|
|
HISTFILE="$XDG_DATA_HOME/zsh/history"
|
2017-11-15 23:06:29 +00:00
|
|
|
HISTSIZE=999999
|
|
|
|
SAVEHIST=999999
|
2016-03-31 02:03:55 +00:00
|
|
|
|
2020-08-10 20:58:23 +00:00
|
|
|
mkdir -p "$LOG_DIR" "$(dirname "$HISTFILE")"
|
|
|
|
|
2018-03-29 10:15:56 +00:00
|
|
|
exists() { which $@ 0<&- 1>/dev/null 2>/dev/null; }
|
|
|
|
|
2017-10-03 09:15:34 +00:00
|
|
|
# Only set tty if running interactively
|
2020-03-21 23:24:34 +00:00
|
|
|
if exists tty && tty -s; then
|
2017-10-03 09:15:34 +00:00
|
|
|
# Resolve at shell runtime
|
|
|
|
export GPG_TTY="$(tty)"
|
|
|
|
fi
|
|
|
|
|
2020-03-21 12:49:59 +00:00
|
|
|
# Configure less and add colours
|
2020-03-22 10:28:14 +00:00
|
|
|
export LESS="-RI --mouse --wheel-lines=3"
|
2020-03-21 12:49:59 +00:00
|
|
|
export PAGER="less"
|
|
|
|
export MANPAGER="less -+N"
|
2020-03-22 10:28:14 +00:00
|
|
|
export SYSTEMD_PAGER="less $LESS"
|
2020-03-21 12:49:59 +00:00
|
|
|
# Disable histfile
|
|
|
|
export LESSHISTFILE=-
|
2020-08-10 20:27:13 +00:00
|
|
|
# Use .local/share for z instead of ~/.z
|
|
|
|
export _Z_DATA="$XDG_DATA_HOME/z"
|
2020-03-21 12:49:59 +00:00
|
|
|
|
|
|
|
if exists tput; then
|
|
|
|
export LESS_TERMCAP_mb=$(tput bold; tput setaf 2) # green
|
|
|
|
export LESS_TERMCAP_md=$(tput bold; tput setaf 6) # cyan
|
|
|
|
export LESS_TERMCAP_me=$(tput sgr0)
|
|
|
|
export LESS_TERMCAP_so=$(tput bold; tput setaf 4) # blue
|
|
|
|
export LESS_TERMCAP_se=$(tput rmso; tput sgr0)
|
|
|
|
export LESS_TERMCAP_us=$(tput smul; tput bold; tput setaf 7) # white
|
|
|
|
export LESS_TERMCAP_ue=$(tput rmul; tput sgr0)
|
|
|
|
export LESS_TERMCAP_mr=$(tput rev)
|
|
|
|
export LESS_TERMCAP_mh=$(tput dim)
|
|
|
|
export LESS_TERMCAP_ZN=$(tput ssubm)
|
|
|
|
export LESS_TERMCAP_ZV=$(tput rsubm)
|
|
|
|
export LESS_TERMCAP_ZO=$(tput ssupm)
|
|
|
|
export LESS_TERMCAP_ZW=$(tput rsupm)
|
|
|
|
fi
|
|
|
|
|
2017-11-15 23:06:29 +00:00
|
|
|
# Set some useful ZSH/Bash options
|
2020-08-19 11:28:13 +00:00
|
|
|
setopt sharehistory extendedhistory histignorealldups histignorespace histreduceblanks
|
2018-10-01 15:22:03 +00:00
|
|
|
setopt pathdirs autocd autopushd extendedglob nullglob alwaystoend interactivecomments dvorak
|
2017-11-15 23:06:29 +00:00
|
|
|
|
2017-11-15 23:46:28 +00:00
|
|
|
zstyle ':completion:*:sudo|_::' environ PATH="/sbin:/usr/sbin:$PATH" HOME="/root"
|
|
|
|
zstyle ':completion:*' matcher-list '' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'r:|[._-]=** r:|=**' 'l:|=* r:|=*'
|
|
|
|
zstyle ':completion:*' rehash true
|
|
|
|
zstyle ':completion:*' menu select
|
|
|
|
zstyle ':completion:*' list-colors "${(@s.:.)LS_COLORS}"
|
2018-07-30 08:26:31 +00:00
|
|
|
zstyle ':compinstall' filename "${ZDOTDIR:-~}/.zshrc"
|
2017-11-15 23:46:28 +00:00
|
|
|
|
2018-10-01 15:22:03 +00:00
|
|
|
# Pre-load vi-mode edit-command-line before antigen plugins are loaded
|
|
|
|
autoload -z edit-command-line
|
|
|
|
zle -N edit-command-line
|
|
|
|
|
|
|
|
export WORDCHARS='*?_[]~=&;!#$%^(){}'
|
|
|
|
x-bash-backward-kill-word(){ WORDCHARS='' zle kill-word; }
|
|
|
|
zle -N x-bash-backward-kill-word
|
2017-11-15 23:46:28 +00:00
|
|
|
|
2017-11-15 23:06:29 +00:00
|
|
|
# Load antigen & plugins
|
2020-08-10 20:58:23 +00:00
|
|
|
ANTIGEN_LOG="$LOG_DIR/antigen-$(date -u --iso-8601=seconds | cut -d+ -f1).log"
|
2018-03-31 12:46:04 +00:00
|
|
|
antigen_src="$ADOTDIR/antigen.zsh"
|
2017-11-15 23:14:30 +00:00
|
|
|
if [ ! -f "$antigen_src" ]; then
|
2018-03-31 12:46:04 +00:00
|
|
|
git clone https://github.com/zsh-users/antigen.git "$ADOTDIR"
|
2017-11-15 23:14:30 +00:00
|
|
|
fi
|
|
|
|
source "$antigen_src"
|
2017-11-15 23:06:29 +00:00
|
|
|
|
|
|
|
antigen bundle zsh-users/zsh-completions
|
2018-10-01 15:22:03 +00:00
|
|
|
antigen bundle zsh-users/zsh-autosuggestions
|
2020-08-18 12:29:07 +00:00
|
|
|
antigen bundle zsh-users/zsh-syntax-highlighting
|
2018-04-11 15:42:01 +00:00
|
|
|
antigen bundle mafredri/zsh-async
|
2020-08-10 20:27:13 +00:00
|
|
|
antigen bundle agkozak/zsh-z
|
2017-11-15 23:06:29 +00:00
|
|
|
|
|
|
|
antigen apply
|
|
|
|
|
2018-07-30 08:28:27 +00:00
|
|
|
# Vim mode!
|
|
|
|
bindkey -v
|
|
|
|
export KEYTIMEOUT=25
|
2017-11-15 23:06:29 +00:00
|
|
|
|
|
|
|
# Set some key-binds
|
|
|
|
bindkey "^[[1;3C" forward-word
|
2017-11-16 00:02:58 +00:00
|
|
|
bindkey "^[[1;5C" forward-word
|
2017-11-15 23:06:29 +00:00
|
|
|
bindkey "^[[1;3D" backward-word
|
2017-11-16 00:02:58 +00:00
|
|
|
bindkey "^[[1;5D" backward-word
|
2016-03-31 02:03:55 +00:00
|
|
|
bindkey "^[[7~" beginning-of-line
|
|
|
|
bindkey "^[[8~" end-of-line
|
2017-12-26 15:42:32 +00:00
|
|
|
bindkey "^[[3~" delete-char
|
|
|
|
bindkey "^[[3;3~" delete-word
|
2016-03-31 02:03:55 +00:00
|
|
|
bindkey '^[^[[3~' x-bash-backward-kill-word
|
|
|
|
bindkey '^[^[[3^' x-bash-backward-kill-word
|
2018-07-12 09:58:15 +00:00
|
|
|
bindkey '^[[A' fzf-history-widget # Up (fzf)
|
|
|
|
bindkey '^[[B' fzf-history-widget # Down (fzf)
|
2019-09-15 10:35:50 +00:00
|
|
|
bindkey '^F' fzf-file-widget # Ctrl+F file search (fzf)
|
2018-10-19 13:45:52 +00:00
|
|
|
|
2020-03-21 23:25:02 +00:00
|
|
|
bindkey "^F" fzf-file-widget
|
2020-03-21 23:25:48 +00:00
|
|
|
bindkey -M vicmd "^W" backward-delete-word
|
2018-10-19 13:45:52 +00:00
|
|
|
|
|
|
|
bindkey -M vicmd d vi-backward-char
|
|
|
|
bindkey -M vicmd h vi-down-line-or-history
|
|
|
|
bindkey -M vicmd t vi-up-line-or-history
|
|
|
|
bindkey -M vicmd n vi-forward-char
|
|
|
|
bindkey -M vicmd k vi-delete
|
|
|
|
bindkey -M vicmd K vi-kill-eol
|
|
|
|
bindkey -M vicmd j vi-find-next-char-skip
|
|
|
|
bindkey -M vicmd l vi-repeat-search
|
|
|
|
|
2020-03-21 23:26:07 +00:00
|
|
|
# Backspace across newlines when in vi-mode
|
|
|
|
bindkey -v '^?' backward-delete-char
|
2016-03-31 02:03:55 +00:00
|
|
|
|
2018-10-19 13:46:19 +00:00
|
|
|
ZSH_AUTOSUGGEST_USE_ASYNC=true
|
2019-12-15 11:43:49 +00:00
|
|
|
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=128
|
2018-07-12 09:58:15 +00:00
|
|
|
ZSH_AUTOSUGGEST_CLEAR_WIDGETS=("${(@)ZSH_AUTOSUGGEST_CLEAR_WIDGETS:#(up|down)-line-or-history}")
|
2017-10-10 09:59:25 +00:00
|
|
|
|
2018-10-19 13:46:36 +00:00
|
|
|
default='fg=12'
|
|
|
|
prog='fg=blue'
|
2018-10-31 16:47:19 +00:00
|
|
|
ZSH_HIGHLIGHT_STYLES=()
|
2018-10-01 15:22:03 +00:00
|
|
|
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets root line)
|
2018-10-19 13:46:36 +00:00
|
|
|
ZSH_HIGHLIGHT_STYLES[root]='bg=red'
|
|
|
|
ZSH_HIGHLIGHT_STYLES[default]=$default
|
|
|
|
ZSH_HIGHLIGHT_STYLES[arg0]=$prog
|
2016-03-31 02:03:55 +00:00
|
|
|
ZSH_HIGHLIGHT_STYLES[unknown-token]='fg=red,bold'
|
|
|
|
ZSH_HIGHLIGHT_STYLES[reserved-word]='fg=yellow'
|
2018-10-19 13:46:36 +00:00
|
|
|
ZSH_HIGHLIGHT_STYLES[alias]=$prog
|
|
|
|
ZSH_HIGHLIGHT_STYLES[suffix-alias]='fg=green'
|
|
|
|
ZSH_HIGHLIGHT_STYLES[builtin]='fg=4'
|
|
|
|
ZSH_HIGHLIGHT_STYLES[function]=$prog
|
|
|
|
ZSH_HIGHLIGHT_STYLES[command]=$prog
|
|
|
|
ZSH_HIGHLIGHT_STYLES[precommand]='fg=4'
|
2017-11-15 23:06:29 +00:00
|
|
|
ZSH_HIGHLIGHT_STYLES[commandseparator]='fg=cyan'
|
2016-03-31 02:03:55 +00:00
|
|
|
ZSH_HIGHLIGHT_STYLES[hashed-command]='fg=green'
|
2018-10-19 13:46:36 +00:00
|
|
|
ZSH_HIGHLIGHT_STYLES[path]='fg=cyan'
|
|
|
|
ZSH_HIGHLIGHT_STYLES[path_separator]='fg=cyan'
|
|
|
|
ZSH_HIGHLIGHT_STYLES[path_prefix]='fg=208'
|
2016-03-31 02:03:55 +00:00
|
|
|
ZSH_HIGHLIGHT_STYLES[globbing]='fg=red'
|
2017-11-15 23:06:29 +00:00
|
|
|
ZSH_HIGHLIGHT_STYLES[comment]='fg=7'
|
2018-10-19 13:46:36 +00:00
|
|
|
ZSH_HIGHLIGHT_STYLES[history-expansion]=$default
|
|
|
|
ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=$default
|
|
|
|
ZSH_HIGHLIGHT_STYLES[double-hyphen-option]=$default
|
2017-11-15 23:06:29 +00:00
|
|
|
ZSH_HIGHLIGHT_STYLES[back-quoted-argument]='fg=magenta'
|
2016-03-31 02:03:55 +00:00
|
|
|
ZSH_HIGHLIGHT_STYLES[single-quoted-argument]='fg=yellow'
|
|
|
|
ZSH_HIGHLIGHT_STYLES[double-quoted-argument]='fg=yellow'
|
|
|
|
ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]='fg=yellow'
|
|
|
|
ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]='fg=cyan'
|
|
|
|
ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]='fg=cyan'
|
|
|
|
ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]='fg=cyan'
|
2017-11-15 23:06:29 +00:00
|
|
|
ZSH_HIGHLIGHT_STYLES[assign]='fg=green'
|
2018-10-19 13:46:36 +00:00
|
|
|
ZSH_HIGHLIGHT_STYLES[redirection]='fg=cyan,bold'
|
2016-03-31 02:03:55 +00:00
|
|
|
|
2020-08-11 10:45:48 +00:00
|
|
|
source "$XDG_CONFIG_HOME/aliases"
|
2017-11-16 00:24:10 +00:00
|
|
|
|
|
|
|
# Load some manual plugins
|
|
|
|
source "$ZSH_DIR/plugins/sudo.zsh"
|
|
|
|
source "$ZSH_DIR/plugins/fish-theme.zsh"
|
2018-10-20 12:42:18 +00:00
|
|
|
source "$ZSH_DIR/plugins/git-rprompt.zsh"
|
2020-08-23 11:07:09 +00:00
|
|
|
|
|
|
|
trysource() { [ -f "$1" ] && source "$1"; }
|
|
|
|
trysource /usr/share/fzf/key-bindings.zsh 2>&1 # Arch/sensible distros
|
|
|
|
trysource /usr/share/doc/fzf/examples/key-bindings.zsh 2>&1 # Debian, because Debian
|
|
|
|
trysource /usr/share/doc/pkgfile/command-not-found.zsh 2>&1 # pkgfile on Arch
|
|
|
|
trysource /usr/share/z/z.sh
|
2020-05-17 11:39:39 +00:00
|
|
|
|
|
|
|
# Completion initialisation
|
|
|
|
autoload -U compinit bashcompinit
|
|
|
|
compinit
|
|
|
|
bashcompinit
|
|
|
|
|
|
|
|
# gopass completion
|
|
|
|
if exists gopass; then
|
|
|
|
source <(gopass completion bash)
|
|
|
|
fi
|