-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
104 lines (86 loc) · 3.73 KB
/
.zshrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# Include shell functions
source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/functions.sh"
# Report the current working directory to the terminal when the directory is changed
autoload add-zsh-hook
add-zsh-hook chpwd update_terminal_cwd
update_terminal_cwd
# Data dir
mkdir -p "${XDG_STATE_HOME:-$HOME/.local/state}/zsh"
# History size, location and settings
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=${XDG_STATE_HOME:-$HOME/.local/state}/zsh/zsh_history
setopt histignorealldups sharehistory histignorespace
# Directory history
DIRSTACKSIZE=10
setopt autopushd pushdsilent pushdignoredups pushdminus
# Don't remove a space before the pipe symbol
ZLE_REMOVE_SUFFIX_CHARS=$' \t\n;&)'
# Set up the prompt
if [[ $(tty) =~ tty[0-9]$ ]]; then
export PROMPT_SEPARATOR=''
export PROMPT_ELLIPSIS='...'
export PROMPT_BRANCH=''
export PROMPT_CONTEXT_BG=white
fi
source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/theme.zsh"
# Use emacs keybindings even if our EDITOR is set to vi
bindkey -e
bindkey '^[[1;5C' emacs-forward-word # Ctrl+Right
bindkey '^[[1;5D' emacs-backward-word # Ctrl+Left
bindkey '^[[3;5~' kill-word # Ctrl+Delete
bindkey '^U' backward-kill-line # Ctrl+U
bindkey '^[W' kill-region # Alt+W
bindkey '\C-]' vi-find-next-char # Ctrl+]
bindkey '\e\C-]' vi-find-prev-char # Alt+Ctrl+]
bindkey '\e[3~' delete-char # Delete
backward-kill-word-ctrl-bs() {
local WORDCHARS=${WORDCHARS/\/}
zle backward-kill-word
}
zle -N backward-kill-word-ctrl-bs
bindkey '^H' backward-kill-word-ctrl-bs # Ctrl+Backspace
# Edit the current command line in $EDITOR
autoload -U edit-command-line
zle -N edit-command-line
bindkey '\C-x\C-e' edit-command-line
# Make sure the following completion dirs are in fpath
fpath[(i)/usr/local/share/zsh/site-functions]=()
fpath[(i)/usr/share/zsh/site-functions]=()
fpath=("/usr/local/share/zsh/site-functions" "/usr/share/zsh/site-functions" $fpath)
# Use modern completion system
autoload -Uz compinit
zstyle ':completion:*' menu select
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' matcher-list '' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
zmodload zsh/complist
compinit -d "${XDG_STATE_HOME:-$HOME/.local/state}/zsh/zcompdump"
_comp_options+=(globdots) # Include hidden files
# Initialize zoxide
command -v zoxide &> /dev/null && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zoxide-init-cd.zsh"
# Use vim keys in tab complete menu
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 'j' vi-down-line-or-history
bindkey -M menuselect 'k' vi-up-line-or-history
bindkey -M menuselect 'l' vi-forward-char
bindkey -M menuselect '^[[Z' reverse-menu-complete # Shift+Tab
# Aliases
source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliases.sh"
# Set up lf key binding
command -v lf &> /dev/null && bindkey -s '^o' '^u^klf\n'
# Set up fzf key bindings and fuzzy completion
command -v fzf &> /dev/null && eval "$(fzf --zsh)"
command -v fzf-alt-c &> /dev/null && export FZF_ALT_C_COMMAND="fzf-alt-c"
command -v fzf-ctrl-t &> /dev/null && export FZF_CTRL_T_COMMAND="fzf-ctrl-t"
# Plugins
typeset -gA ZSH_HIGHLIGHT_STYLES
source "${XDG_DATA_HOME:-$HOME/.local/share}/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
source "${XDG_DATA_HOME:-$HOME/.local/share}/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh"
bindkey "$terminfo[kcuu1]" history-substring-search-up
bindkey "$terminfo[kcud1]" history-substring-search-down
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
bindkey -M emacs '^P' history-substring-search-up
bindkey -M emacs '^N' history-substring-search-down