-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
166 lines (145 loc) · 7.38 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
colorscript -r
if [ "$TERM" = "linux" ]; then
printf %b '\e[40m' '\e[8]' # set default background to color 0 'dracula-bg'
printf %b '\e[37m' '\e[8]' # set default foreground to color 7 'dracula-fg'
printf %b '\e]P0282a36' # redefine 'black' as 'dracula-bg'
printf %b '\e]P86272a4' # redefine 'bright-black' as 'dracula-comment'
printf %b '\e]P1ff5555' # redefine 'red' as 'dracula-red'
printf %b '\e]P9ff6e6e' # redefine 'bright-red' as '#ff6e6e'
printf %b '\e]P250fa7b' # redefine 'green' as 'dracula-green'
printf %b '\e]PA69ff94' # redefine 'bright-green' as '#69ff94'
printf %b '\e]P3f1fa8c' # redefine 'brown' as 'dracula-yellow'
printf %b '\e]PBffffa5' # redefine 'bright-brown' as '#ffffa5'
printf %b '\e]P4bd93f9' # redefine 'blue' as 'dracula-purple'
printf %b '\e]PCd6acff' # redefine 'bright-blue' as '#d6acff'
printf %b '\e]P5ff79c6' # redefine 'magenta' as 'dracula-pink'
printf %b '\e]PDff92df' # redefine 'bright-magenta' as '#ff92df'
printf %b '\e]P68be9fd' # redefine 'cyan' as 'dracula-cyan'
printf %b '\e]PEa4ffff' # redefine 'bright-cyan' as '#a4ffff'
printf %b '\e]P7f8f8f2' # redefine 'white' as 'dracula-fg'
printf %b '\e]PFffffff' # redefine 'bright-white' as '#ffffff'
clear
fi
# source ~/.config/zsh/powerlevel10k/powerlevel10k.zsh-theme
eval "$(starship init zsh)"
ZSH_CACHE_DIR=$HOME/.cache/zsh
if [[ ! -d $ZSH_CACHE_DIR ]]; then
mkdir $ZSH_CACHE_DIR
fi
# You may need to manually set your language environment
export LANG=en_GB.UTF-8
## History
HISTFILE=$ZSH_CACHE_DIR/zsh_history
HISTSIZE=10000
SAVEHIST=10000
## Options section
setopt auto_pushd
setopt autocd
setopt extended_glob # Extended globbing. Allows using regular expressions with *
setopt nocheckjobs # Don't warn about running processes when exiting
setopt nobeep # No beep
setopt append_history # Immediately append history instead of overwriting
setopt share_history
setopt hist_find_no_dups
setopt hist_ignore_all_dups # If a new command is a duplicate, remove the older one
setopt hist_reduce_blanks
setopt hist_save_no_dups
WORDCHARS=${WORDCHARS//\/[&.;]} # Don't consider certain characters part of the word
# Basic auto/tab complete
zmodload zsh/complist
zstyle ':completion:*' menu select
zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*' # Case insensitive tab completion
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" # Colored completion (different colors for dirs/files/etc)
zstyle ':completion:*' rehash true # automatically find new executables in path
zstyle ':completion:*' special-dirs true
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w"
# Speed up completions
zstyle ':completion:*' accept-exact '*(N)'
zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
zstyle ':completion:*' use-cache yes
zstyle ':completion:*' cache-path $ZSH_CACHE_DIR
zstyle ':completion:*:*:*:users' ignored-patterns \
adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna \
clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm \
gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm \
ldap lp mail mailman mailnull man messagebus mldonkey mysql nagios \
named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \
operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \
rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \
usbmux uucp vcsa wwwrun xfs '_*'
zstyle '*' single-ignored show
## Keybindings ##
bindkey -v
export KEYTIMEOUT=1
# Enable searching through history
bindkey '^R' history-incremental-pattern-search-backward
# 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 'left' vi-backward-char
bindkey -M menuselect 'down' vi-down-line-or-history
bindkey -M menuselect 'up' vi-up-line-or-history
bindkey -M menuselect 'right' vi-forward-char
bindkey '^[[7~' beginning-of-line # Home key
bindkey '^[[H' beginning-of-line # Home key
if [[ '${terminfo[khome]}' != '' ]]; then
bindkey '${terminfo[khome]}' beginning-of-line # [Home] - Go to beginning of line
fi
bindkey '^[[8~' end-of-line # End key
bindkey '^[[F' end-of-line # End key
if [[ '${terminfo[kend]}' != '' ]]; then
bindkey '${terminfo[kend]}' end-of-line # [End] - Go to end of line
fi
bindkey '^[[2~' overwrite-mode # Insert key
bindkey '^[[3~' delete-char # Delete key
bindkey '^[[C' forward-char # Right key
bindkey '^[[D' backward-char # Left key
bindkey '^[[5~' history-beginning-search-backward # Page up key
bindkey '^[[6~' history-beginning-search-forward # Page down key
# Navigate words with ctrl+arrow keys
bindkey '^[Oc' forward-word #
bindkey '^[Od' backward-word #
bindkey '^[[1;5D' backward-word #
bindkey '^[[1;5C' forward-word #
bindkey '^H' backward-kill-word # delete previous word with ctrl+backspace
bindkey '^[[Z' undo # Shift+tab undo last action
## Alias ##
. ~/.config/zsh/zsh_aliases
## Theming ##
autoload -U colors zcalc
colors
# Color man pages
export LESS_TERMCAP_mb=$'\E[01;32m'
export LESS_TERMCAP_md=$'\E[01;32m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;47;34m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;36m'
export LESS=-r
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
# [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
## Plugins ##
declare -A ZINIT
ZINIT[BIN_DIR]="$HOME/.config/zsh/zinit/bin"
ZINIT[HOME_DIR]="$HOME/.config/zsh/zinit"
source $ZINIT[BIN_DIR]/zinit.zsh
zinit ice wait"1" lucid atload"zmodload zsh/terminfo; \
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"
zinit light zsh-users/zsh-history-substring-search
zinit wait"1" lucid light-mode for \
djui/alias-tips \
hlissner/zsh-autopair
zinit wait lucid light-mode for \
atinit"ZINIT[COMPINIT_OPTS]=-C; zpcompinit; zpcdreplay" \
zdharma-continuum/fast-syntax-highlighting \
atload"_zsh_autosuggest_start" \
zsh-users/zsh-autosuggestions \
blockf \
zsh-users/zsh-completions