-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
179 lines (138 loc) · 4.96 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
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# Enable 256 colors in xfce4-terminal
if [ "$COLORTERM" = "xfce4-terminal" -a "$TERM" = "xterm" ]; then
TERM=xterm-256color
fi
# Add local completion path
fpath+=~/.zfunc
# Clone zplug if unavailable
if [ ! -f "$ZPLUG_HOME/init.zsh" ]; then
git clone https://github.com/zplug/zplug.git "$ZPLUG_HOME"
fi
# Load zplug and plugins
local my_path="$PATH"
source "$ZPLUG_HOME/init.zsh"
zplug 'zplug/zplug', hook-build:"zplug --self-manage"
zplug "olivierverdier/zsh-git-prompt", use:zshrc.sh, hook-build:"zplug clear"
zplug "zsh-users/zsh-completions"
zplug "jonmosco/kube-ps1", use:kube-ps1.sh
zplug "jeffreytse/zsh-vi-mode"
zplug "plugins/pip", from:oh-my-zsh
# Abuse zplug to keep track of weechat plugins
zplug "keith/urlview-weechat", use:
zplug "GermainZ/weechat-vimode", use:
zplug "wee-slack/wee-slack", use:
zplug "po5/mpv_sponsorblock", use:
zplug "soimort/translate-shell", at:develop, use:, hook-build:"make install PREFIX='$HOME/.local'"
zplug "trizen/pipe-viewer", at:main, hook-build:"perl Build.PL && ./Build install --install_base='$HOME/.local'"
zplug "spion/adbfs-rootless", hook-build:"make && make install INSTALL_DIR='$HOME/.local'"
zplug "carnager/rofi-pass", as:command, use:rofi-pass
zplug "harishkrupo/oauth2ms", at:main, as:command, use:oauth2ms
zplug "thameera/vimv", as:command, use:vimv
zplug "dunst-project/dunst", at:master, hook-build:"make && make install DESTDIR='$HOME/.local' PREFIX=''"
zplug "qutebrowser/qutebrowser", at:main, as:command, use:".venv-qt6/bin/qutebrowser", hook-build:"PIP_USER='no' python3 scripts/mkvenv.py --venv-dir .venv-qt6 --pyqt-type link --pyqt-version 6 --skip-docs"
zplug load
PATH="$my_path"
# Keep 1000 lines of history within the shell and save it to ~/.zsh_history:
setopt histignorealldups sharehistory histignorespace
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=~/.zsh_history
# Use modern completion system
zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _expand _complete _correct _approximate
zstyle ':completion:*' format 'Completing %d'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' menu select=2
eval "$(dircolors -b)"
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
# disable user completion for ssh
zstyle ':completion:*:(ssh|scp|rtmux):*:users' users
zstyle ':completion:*:(ssh|scp|rranger|rtmux):*:hosts' hosts
# use other commands as source for autocompletion
compdef tsocks=exec
compdef autossh=ssh
# autocompletion for rranger
_rranger() {
local service
service= _ssh
_ssh_hosts
}
compdef _rranger rranger
# just use url completion for mpc
_mpc_helper_files() {
_urls
}
# enable bash completions
autoload bashcompinit
bashcompinit
# autocompletion for pandoc
_pandoc() {
eval "$(pandoc --bash-completion)"
}
compdef _pandoc pandoc
# autocompletion for rtmux
compdef rtmux=ssh
# autocompletion for git flow on old Ubuntu and Debian versions
if (( ! $+functions[_git-flow])); then
if [ -f /usr/share/git-flow/git-flow-completion.zsh ]; then
. /usr/share/git-flow/git-flow-completion.zsh
fi
fi
if [ -f /usr/share/google-cloud-sdk/completion.zsh.inc ]; then
. /usr/share/google-cloud-sdk/completion.zsh.inc
fi
# Load aliases
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# Load gpg-agent variables
export GPG_TTY=$(tty)
# Don't quit zsh on C-d
setopt ignoreeof
# Set additional keybindings for vi-mode
zvm_bindkey viins '^d' delete-char
zvm_bindkey vicmd '/' history-incremental-search-backward
zvm_bindkey vicmd '?' history-incremental-search-forward
# Use similar word definition as vim
WORDCHARS="_"
# Enable report time
REPORTTIME=5
# Configure kube-ps1
autoload -U regexp-replace
function kubeps1_get_cluster_short() {
context="$1"
regexp-replace context '.*_' ''
echo "$context"
}
KUBE_PS1_SYMBOL_ENABLE=false
KUBE_PS1_CLUSTER_FUNCTION=kubeps1_get_cluster_short
KUBE_PS1_PREFIX="(%B"
KUBE_PS1_DIVIDER="%b:"
if ! hash kubectl > /dev/null 2>&1 ; then
alias kube_ps1='true'
fi
# Set up the prompt
autoload -Uz promptinit
promptinit
PROMPT='%K{blue}%n@%m%k %B%F{green}%147<...<%~%b%F{white} $(git_super_status) $(kube_ps1)
%}%F{white} %# %b%f%k'
# Set up terminal title
autoload -Uz add-zsh-hook
function xterm_title_precmd() {
print -n '\e]2;zsh\a'
}
function xterm_title_preexec() {
print -n "\e]2;$1\a"
}
if [[ "$TERM" == (xterm*|rxvt*|st*|alacritty) ]]; then
add-zsh-hook -Uz precmd xterm_title_precmd
add-zsh-hook -Uz preexec xterm_title_preexec
fi