-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.zshrc
232 lines (201 loc) · 5.53 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
#!/usr/bin/env zsh
# shellcheck shell=bash
# vim: foldmarker={,} foldmethod=marker
# This file contains all the configuration necessary for running a zsh shell.
# Setup {
export DOTFILE_FOLDER="${XDG_CONFIG_HOME:-${HOME:?}/.config}/dotfiles"
source "$DOTFILE_FOLDER/utils.zsh"
is_macos && { BREW_PREFIX="/usr/local/" }
is_linux && {
BREW_PREFIX="/home/linuxbrew/.linuxbrew"
source "${DOTFILE_FOLDER}/.zprofile" # TODO: why is this needed ?
}
# }
# zshoptions {
setopt ALWAYS_TO_END
setopt INTERACTIVE_COMMENTS
setopt APPEND_HISTORY
setopt AUTO_CD
setopt AUTO_LIST
setopt AUTO_MENU
setopt AUTO_PUSHD
setopt COMPLETE_IN_WORD
setopt EXTENDED_HISTORY
setopt HIST_EXPIRE_DUPS_FIRST
setopt HIST_FIND_NO_DUPS
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_SPACE
setopt HIST_VERIFY
setopt INC_APPEND_HISTORY
setopt NO_BEEP
setopt PROMPT_SUBST
setopt PUSHD_IGNORE_DUPS
setopt SHARE_HISTORY
# }
# Lang {
export LANG="en_US.UTF-8"
export LC_ALL="$LANG"
export LC_CTYPE="$LANG"
# }
# Colors {
export CLICOLOR=1
export LSCOLORS=exfxcxdxbxegedabagacad
autoload -U colors && colors
# }
# Functions {
# Load compinit and check the cache only once a day
autoload -Uz compinit
is_macos && {
if [ "$(find "$HOME/.zcompdump" -mtime +1)" ]; then
rm -f "$HOME/.zcompdump"
compinit -i
else
compinit -C
fi
}
is_linux && {
if [[ -n $HOME/.zcompdump(#qN.mh+24) ]]; then
rm -f "$HOME/.zcompdump"
compinit -i
else
compinit -C
fi
}
zmodload -i zsh/complist
# shellcheck disable=SC2086 # doesn't find the functions if quoted
autoload -U $DOTFILE_FOLDER/functions/*(:t)
# }
# Prompt {
# Default prompt is just current dir
# shellcheck disable=SC2154 # colors are loaded somewhere else
PROMPT="%{${fg[green]}%}%c%{${reset_color}%} "
# Add functions/prompt_precmd to the list of precmd_functions
typeset -a precmd_functions
precmd_functions+=(prompt_precmd)
# }
# }
# Completion {
# Enable completion from partial words
# e.g. ~/men<TAB> => ~/Documents
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*' list-colors
zstyle ':completion:*' menu select
# }
# Key Binding {
zle -N fancy-ctrl-z
bindkey -v # Use vi bindings
bindkey "^Z" fancy-ctrl-z
bindkey "^R" history-incremental-search-backward
bindkey "^A" beginning-of-line
bindkey "^E" end-of-line
# }
# Important {
alias rm='echo "use /bin/rm or trash"' # Don't use rm unless you know what you're doing.
# }
# Tmux {
# Start tmux with unicode support (prevent trailing witespace for the prompt)
alias tmux='tmux -u'
alias ta='tmux attach -t'
alias ts='tmux new-session -s'
alias tw='tmux switch -t'
# }
# Neovim {
alias vi="nvim"
alias vi="nvim"
alias vim="nvim"
alias vst='nvim +Git now' # Run Gstatus at vim startup
alias vih='nvim +help\ ' # Jump to vim help
alias vin='nvim -Nu NONE' # Vim without config
alias vit='nvim +tj\ ' # Jump to tag
alias vidir='nvim +":normal -"'
# }
# Git {
alias gd='git difftool'
alias ga='git add'
alias gb='git branch'
alias gbm='git branch -M'
alias gc='git commit'
alias gl='git pull'
alias glo='git lg'
alias grhh='git reset --hard HEAD'
alias gs='git switch'
alias gpf='git push --force-with-lease'
alias gsc='git switch -c'
alias gsm='git switch "$(git main)" && git pull && git sweep'
alias gss='git status'
alias gs-='git status -'
alias gst='git stash'
alias gcb='echo "DEPRECATED stop using git checkout for creating branch: use git switch for that (alias is gsc)"'
# }
# Docker {
alias dk="docker"
alias bbox="docker run -it --rm busybox"
alias dkclean="docker system prune --all --force --volumes"
alias dksh="docker-ssh"
alias dc="docker compose"
alias dcr="docker compose run"
alias dcsh="docker compose-ssh"
# }
# copy/paste{
is_linux && {
alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'
}
# }
# misc {
alias n="gh not"
alias nr="gh not --repl"
alias ns="gh not sync --verbosity 4"
alias tags="ctags -R --exclude=@$DOTFILE_FOLDER/.ctagsignore -o tags"
alias l="sling"
alias fex='$(fzf)'
alias wspec="find . -name '*.rb' | entr sh -c 'clear && bundle exec rspec'"
# }
# linuxbrew {
is_linux && {
eval "$(${BREW_PREFIX}/bin/brew shellenv)"
}
# }
# Kitty {
is_macos && {
alias kitty='${HOME}/Applications/kitty.app/Contents/MacOS/kitty'
}
# }
# Search {
alias todo="rg -i todo"
export FZF_DEFAULT_COMMAND="rg --files --follow"
# }
# Alias {
alias x509='openssl x509 -text -noout' # That's what I use all the time
alias re='exec zsh' # Reload .zshrc
alias als='alias | grep' # Search through aliases
alias reverse-link='find -L /dir/to/start -samefile' # Find what is linked to a file
alias ll='ls -la'
alias p8='ping -v 8.8.8.8' # Ping 8.8.8.8
alias pg='ps aux | grep' # ps and grep easily
alias kk='killall' # Quicker kill all
alias hmac='openssl rand -hex 32'
alias tmp='(cd `mktemp -d` && $SHELL)'
# GDB {
alias gdb='gdb -q' # Silent GDB
# ref: http://thexploit.com/secdev/turning-off-buffer-overflow-protections-in-gcc/
alias gccunsafe='gcc -fno-stack-protector -D_FORTIFY_SOURCE=0'
# }
is_macos && {
# Mac Catalina is breaking everything, thanks Tim Apple.
# from https://www.kvraudio.com/forum/viewtopic.php?t=530824&start=15
alias unlockvst='xattr -d com.apple.quarantine'
}
# }
# Misc {
alias gpg='GPG_TTY="$(tty)" gpg'
# Limit how many files can be used by the current session
ulimit -S -n 10240
eval "$(mise activate zsh)"
# Restart espanso
(&>/dev/null espanso restart &)
# }
# Private {
source "$DOTFILE_FOLDER/private/.zshrc"
# }