-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_zshrc
202 lines (148 loc) · 4.87 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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/usr/bin/zsh
#
# Environment variables
#
WORDCHARS='~!#$%^&*(){}[]<>?.+;-_'
# Loading ~/.profile file if exists
if [[ -f ~/.profile ]]; then
source ~/.profile
fi
#
# Starship
#
eval "$(starship init zsh)"
#
# Zap
#
if [[ ! -d "${XDG_DATA_HOME:-$HOME/.local/share}/zap" ]]; then
zsh <(curl -s https://raw.githubusercontent.com/zap-zsh/zap/master/install.zsh) --branch release-v1 --keep
fi
source "${XDG_DATA_HOME:-$HOME/.local/share}/zap/zap.zsh"
# Plugins
plug "zap-zsh/supercharge"
plug "zsh-users/zsh-autosuggestions"
plug "zsh-users/zsh-syntax-highlighting"
plug "zsh-users/zsh-history-substring-search"
# source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
# source /usr/share/doc/pkgfile/command-not-found.zsh
# Load and initialise completion system
autoload -Uz compinit
compinit
#
# Aliases
#
alias zshrc='$EDITOR ~/.zshrc && source ~/.zshrc'
alias fonts='fc-list'
alias hlsblk='lsblk --output NAME,PARTLABEL,FSTYPE,UUID,MAJ:MIN,RM,SIZE,RO,MOUNTPOINT'
alias nvrun='env __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME="nvidia" __VK_LAYER_NV_optimus="NVIDIA_only" __GL_SHOW_GRAPHICS_OSD=1'
alias open='xdg-open'
alias mime='file --mime-type'
function mime-default {
xdg-mime query default "$(xdg-mime query filetype "$1")"
}
function mime-set-default {
xdg-mime default "$1" "$(xdg-mime query filetype "$2")"
}
alias rg='rg --hidden --smart-case'
alias fd='fd --hidden --ignore-case --follow'
alias rm='trash -r'
alias cp='cp -r'
alias mkdir='mkdir -p'
alias grep='grep -i'
alias l='exa --long --header --git --icons'
alias ll='exa --long --header --git --icons --all'
alias tree='exa --tree --long --level 2'
alias tree='exa --tree --long --all --level 2'
alias dockerc="docker compose"
function dockerd() {
systemctl "$1" docker.service
}
if [[ "$TERM" == "xterm-kitty" ]]; then
alias diff='kitty +kitten diff'
alias ssh='kitty +kitten ssh'
fi
alias cz='chezmoi'
#
# Keys
#
# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html
# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Builtins
# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Standard-Widgets
# Use "showkey -a" to find key codes
# Make sure that the terminal is in application mode when zle is active, since
# only then values from $terminfo are valid
if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
function zle-line-init() {
echoti smkx
}
function zle-line-finish() {
echoti rmkx
}
zle -N zle-line-init
zle -N zle-line-finish
fi
# Use emacs key bindings
bindkey -e
# [PageUp] - Up a line of history
bindkey '^[[5~' up-line-or-history
# [PageDown] - Down a line of history
bindkey '^[[6~' down-line-or-history
# Start typing + [Up-Arrow] - fuzzy find history forward
# if [[ -n "${terminfo[kcuu1]}" ]]; then
autoload -U up-line-or-beginning-search
zle -N up-line-or-beginning-search
bindkey "${terminfo[kcuu1]}" history-substring-search-up
# fi
# Start typing + [Down-Arrow] - fuzzy find history backward
# if [[ -n "${terminfo[kcud1]}" ]]; then
autoload -U down-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey "${terminfo[kcud1]}" history-substring-search-down
# fi
# [Home] - Go to beginning of line
bindkey "${terminfo[khome]}" beginning-of-line
# [End] - Go to end of line
bindkey "${terminfo[kend]}" end-of-line
# [Shift-Tab] - move through the completion menu backwards
bindkey '^[[Z' reverse-menu-complete
# [Ctrl-RightArrow] - move forward one word
bindkey '^[[1;5C' forward-word
# [Ctrl-LeftArrow] - move backward one word
bindkey '^[[1;5D' backward-word
# [Ctrl-Backspace] - delete whole line
bindkey '^H' kill-region
# [Delete] - delete forward char
bindkey "^[[3~" delete-char
# [Alt-Delete] - delete whole forward-word
bindkey '^[[3;3~' kill-word
# [Ctrl-Delete] - delete whole forward-line
bindkey '^[[3;5~' kill-line
# # [Esc-l] - run command: ls
# bindkey -s '\el' 'ls\n'
# # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line.
# bindkey '^r' history-incremental-search-backward
# # [Space] - dont do history expansion
# bindkey ' ' magic-space
# # 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
# # file rename magick
# bindkey "^[m" copy-prev-shell-word
# consider emacs keybindings:
#bindkey -e ## emacs key bindings
#
#bindkey '^[[A' up-line-or-search
#bindkey '^[[B' down-line-or-search
#bindkey '^[^[[C' emacs-forward-word
#bindkey '^[^[[D' emacs-backward-word
#
#bindkey -s '^X^Z' '%-^M'
#bindkey '^[e' expand-cmd-path
#bindkey '^[^I' reverse-menu-complete
#bindkey '^X^N' accept-and-infer-next-history
#bindkey '^W' kill-region
#bindkey '^I' complete-word
## Fix weird sequence that rxvt produces
#bindkey -s '^[[Z' '\t'