-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_zshrc
148 lines (124 loc) · 5.05 KB
/
dot_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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
###########
# General #
###########
_zdir=${ZDOTDIR:-$HOME}
# emacs-like bindings for insert mode
bindkey -e
# push visited dirs on the stack
setopt AUTO_PUSHD
# don't store duplicated dirs
setopt PUSHD_IGNORE_DUPS
# edit command line with $EDITOR
autoload -Uz edit-command-line
zle -N edit-command-line
bindkey '^X^E' edit-command-line
###########
# History #
###########
HISTFILE=${_zdir}/.histfile
HISTSIZE=10000
SAVEHIST=10000
# don't save when prefixed with space
setopt HIST_IGNORE_SPACE
# don't save duplicate lines
setopt HIST_SAVE_NO_DUPS
setopt HIST_IGNORE_DUPS
#############
# Variables #
#############
export LS_COLORS='rs=0:di=38;5;27:ln=38;5;51:mh=44;38;5;15:pi=40;38;5;11:so=38;5;13:do=38;5;5:bd=48;5;232;38;5;11:cd=48;5;232;38;5;3:or=48;5;232;38;5;9:mi=05;48;5;232;38;5;15:su=48;5;196;38;5;15:sg=48;5;11;38;5;16:ca=48;5;196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;10;38;5;21:st=48;5;21;38;5;15:ex=38;5;34:*.tar=38;5;9:*.tgz=38;5;9:*.arc=38;5;9:*.arj=38;5;9:*.taz=38;5;9:*.lha=38;5;9:*.lzh=38;5;9:*.lzma=38;5;9:*.tlz=38;5;9:*.txz=38;5;9:*.tzo=38;5;9:*.t7z=38;5;9:*.zip=38;5;9:*.z=38;5;9:*.Z=38;5;9:*.dz=38;5;9:*.gz=38;5;9:*.lrz=38;5;9:*.lz=38;5;9:*.lzo=38;5;9:*.xz=38;5;9:*.zst=38;5;9:*.bz2=38;5;9:*.bz=38;5;9:*.tbz=38;5;9:*.tbz2=38;5;9:*.tz=38;5;9:*.deb=38;5;9:*.rpm=38;5;9:*.jar=38;5;9:*.war=38;5;9:*.ear=38;5;9:*.sar=38;5;9:*.rar=38;5;9:*.alz=38;5;9:*.ace=38;5;9:*.zoo=38;5;9:*.cpio=38;5;9:*.7z=38;5;9:*.rz=38;5;9:*.cab=38;5;9:*.jpg=38;5;13:*.JPG=38;5;13:*.jpeg=38;5;13:*.gif=38;5;13:*.bmp=38;5;13:*.pbm=38;5;13:*.pgm=38;5;13:*.ppm=38;5;13:*.tga=38;5;13:*.xbm=38;5;13:*.xpm=38;5;13:*.tif=38;5;13:*.tiff=38;5;13:*.png=38;5;13:*.svg=38;5;13:*.svgz=38;5;13:*.mng=38;5;13:*.pcx=38;5;13:*.mov=38;5;13:*.mpg=38;5;13:*.mpeg=38;5;13:*.m2v=38;5;13:*.mkv=38;5;13:*.ogm=38;5;13:*.mp4=38;5;13:*.m4v=38;5;13:*.mp4v=38;5;13:*.vob=38;5;13:*.qt=38;5;13:*.nuv=38;5;13:*.wmv=38;5;13:*.asf=38;5;13:*.rm=38;5;13:*.rmvb=38;5;13:*.flc=38;5;13:*.avi=38;5;13:*.fli=38;5;13:*.flv=38;5;13:*.webm=38;5;13:*.gl=38;5;13:*.dl=38;5;13:*.xcf=38;5;13:*.xwd=38;5;13:*.yuv=38;5;13:*.cgm=38;5;13:*.emf=38;5;13:*.axv=38;5;13:*.anx=38;5;13:*.ogv=38;5;13:*.ogx=38;5;13:*.aac=38;5;45:*.au=38;5;45:*.flac=38;5;45:*.mid=38;5;45:*.midi=38;5;45:*.mka=38;5;45:*.mp3=38;5;45:*.m4a=38;5;45:*.mpc=38;5;45:*.ogg=38;5;45:*.opus=38;5;45:*.vorbis=38;5;45:*.3gp=38;5;45:*.ra=38;5;45:*.wav=38;5;45:*.axa=38;5;45:*.oga=38;5;45:*.spx=38;5;45:*.xspf=38;5;45:*~=38;5;244:'
#############
# Functions #
#############
# prefix command with sudo by hitting Esc-Esc
sudo-command-line() {
[[ -z $BUFFER ]] && zle up-history
[[ $BUFFER != sudo\ * && $UID -ne 0 ]] && {
typeset -a bufs
bufs=(${(z)BUFFER})
while (( $+aliases[$bufs[1]] )); do
local expanded=(${(z)aliases[$bufs[1]]})
bufs[1,1]=($expanded)
if [[ $bufs[1] == $expanded[1] ]]; then
break
fi
done
bufs=(sudo $bufs)
BUFFER=$bufs
}
zle end-of-line
}
zle -N sudo-command-line
bindkey "\e\e" sudo-command-line
###############
# Completions #
###############
# use hjlk in menu selection (during completion)
zmodload zsh/complist
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 'k' vi-up-line-or-history
bindkey -M menuselect 'j' vi-down-line-or-history
bindkey -M menuselect 'l' vi-forward-char
# enable reverse cycling using shift-tab
bindkey -M menuselect '^[[Z' reverse-menu-complete
autoload -Uz compinit
compinit
# include hidden files
_comp_options+=(globdots)
# define completers
zstyle ':completion:*' completer _extensions _complete _approximate
# indicate current selection
zstyle ':completion:*' menu select
# cache results
zstyle ':completion:*' use-cache on
_cache_dir=${XDG_CACHE_HOME:-$HOME/.cache}/zsh
zstyle ':completion:*' cache-path ${_cache_dir}
unset _cache_dir
# suppress case if match failed
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}'
# format the display
zstyle ':completion:*:*:*:*:descriptions' format '%F{green}-- %d --%f'
zstyle ':completion:*:*:*:*:corrections' format '%F{yellow}!- %d (errors: %e) -!%f'
zstyle ':completion:*:messages' format ' %F{purple} -- %d --%f'
zstyle ':completion:*:warnings' format ' %F{red}-- no matches found --%f'
# group results
zstyle ':completion:*' group-name ''
# colorful file list
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
##########
# Prompt #
##########
# use starship's prompt
eval "$(starship init zsh)"
###########
# Plugins #
###########
zsh_plugins=(zsh-autosuggestions zsh-syntax-highlighting)
for zsh_plugin ($zsh_plugins); do
source /usr/share/zsh/plugins/$zsh_plugin/$zsh_plugin.zsh
done
###########
# Aliases #
###########
alias v='nvim'
alias ls='ls --color=auto'
alias ll='ls -lh'
alias la='ls -A'
alias grep='grep --color=auto'
alias sysuser='systemctl --user'
alias cm='VISUAL="emacsclient -c" chezmoi'
# git
alias gs='git status'
alias ga='git add'
alias gp='git push'
alias gb='git branch'
alias gc='git commit'
alias gd='git diff'
# directory stack
alias d='dirs -v'
for index ({1..9}) alias "$index"="cd +${index}"; unset index
###############
# Integration #
###############
# direnv
eval "$(direnv hook zsh)"