-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathzshrc
292 lines (248 loc) · 10.1 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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# load zgen -*- mode: sh; -*-
# These lines needs to be before loading oh-my-zsh
# zstyle :omz:plugins:keychain options --quiet
# zstyle :omz:plugins:keychain agents gpg,ssh
source "${HOME}/.dotfiles/zgen/zgen.zsh"
# check if there's no init script
if ! zgen saved; then
echo "Creating a zgen save"
zgen oh-my-zsh
# plugins
zgen oh-my-zsh plugins/git
zgen oh-my-zsh plugins/adb
zgen oh-my-zsh plugins/aws
# zgen oh-my-zsh plugins/deno
zgen oh-my-zsh plugins/direnv
zgen oh-my-zsh plugins/tig
zgen oh-my-zsh plugins/systemd
zgen oh-my-zsh plugins/fzf
zgen oh-my-zsh plugins/asdf
# zgen oh-my-zsh plugins/gpg-agent
zgen oh-my-zsh plugins/npm
zgen oh-my-zsh plugins/asdf
# zgen oh-my-zsh plugins/npx
# zgen oh-my-zsh plugins/keychain
zgen oh-my-zsh plugins/pass
zgen oh-my-zsh plugins/archlinux
zgen oh-my-zsh plugins/vi-mode
zgen oh-my-zsh plugins/extract
zgen oh-my-zsh plugins/golang
zgen oh-my-zsh plugins/gradle
zgen oh-my-zsh plugins/sudo
zgen oh-my-zsh plugins/docker
zgen oh-my-zsh plugins/docker-compose
zgen oh-my-zsh plugins/fasd
zgen oh-my-zsh plugins/nmap
zgen oh-my-zsh plugins/last-working-dir
# zgen oh-my-zsh plugins/themes
zgen oh-my-zsh plugins/mosh
zgen oh-my-zsh plugins/cp
zgen oh-my-zsh plugins/common-aliases
zgen oh-my-zsh plugins/history-substring-search
zgen oh-my-zsh plugins/pip
zgen oh-my-zsh plugins/python
# zgen oh-my-zsh plugins/poetry
zgen load zsh-users/zsh-syntax-highlighting
zgen load zsh-users/zaw
zgen load zsh-users/zsh-completions src
zgen load zsh-users/zsh-autosuggestions
zgen load changyuheng/zsh-interactive-cd
# zgen load marzocchi/zsh-notify
zgen load joel-porquet/zsh-dircolors-solarized
zgen load djui/alias-tips
zgen load Tarrasch/zsh-bd
zgen load larkery/zsh-histdb
# zgen load lukechilds/zsh-nvm
# zgen load ~/.zgen/deno
# zgen load marlonrichert/zsh-autocomplete
# zgen load chisui/zsh-nix-shell
# zgen load spwhitt/nix-zsh-completions
zgen load Aloxaf/fzf-tab fzf-tab.zsh master
# zgen load olets/zsh-abbr zsh-abbr.zsh
# theme
# zgen oh-my-zsh themes/agnoster
zgen load romkatv/powerlevel10k powerlevel10k
# save all to init script
zgen save
fi
export FZF_BASE="/usr/bin/fzf"
_zsh_autosuggest_strategy_histdb_top_here() {
local query="select commands.argv from
history left join commands on history.command_id = commands.rowid
left join places on history.place_id = places.rowid
where places.dir LIKE '$(sql_escape $PWD)%'
and commands.argv LIKE '$(sql_escape $1)%'
group by commands.argv order by count(*) desc limit 1"
suggestion=$(_histdb_query "$query")
}
ZSH_AUTOSUGGEST_STRATEGY=histdb_top_here
# Zaw
zstyle ':filter-select' max-lines 6 # use $LINES - 4 for filter-select
zstyle ':filter-select' case-insensitive yes # enable case-insensitive search
bindkey '^R' zaw-history
bindkey -M filterselect '^[j' down-line-or-history
bindkey -M filterselect '^[k' up-line-or-history
bindkey -M filterselect '^E' accept-search
bindkey '^P' zaw-process
bindkey '^F' zaw-open-file
bindkey '^[^M' autosuggest-execute
bindkey '^[begin' autosuggest-execute
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
bindkey -M vicmd 'k' history-substring-search-up
bindkey -M vicmd 'j' history-substring-search-down
export JAVA_HOME=/usr/lib/jvm/default
export DEFAULT_USER="samim"
export GOPATH="$HOME/.go"
export ANDROID_HOME="/home/samim/Android/Sdk"
export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1
export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=242"
export PYENV_ROOT="$HOME/.pyenv"
export LEDGER_FILE="$HOME/Notes/accounting/ledger.ledger"
export LEDGER_PRICE_DB="$HOME/Notes/accounting/price-db.ledger"
export TOMBS="$HOME/tombs"
export PASSWORD_STORE_TOMB_FILE="$TOMBS/pass.tomb" # for pass-tomb
export PASSWORD_STORE_TOMB_KEY="$TOMBS/pass.tomb.key" # for pass-tomb
export BORG_CONFIG_DIR="/home/samim/borg"
export BORG_CACHE_DIR="/home/samim/borg/cache"
export PIPENV_VENV_IN_PROJECT=1
# export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --preview '[[ \$(file --mime {}) =~ binary ]] && echo {} is a binary file || (highlight -O ansi -l {} || cat {}) 2> /dev/null | head -500' "
# export FZF_DEFAULT_COMMAND='ag --hidden --ignore .git -g ""'
alias nvim='nvim --listen /tmp/nvim-server.pipe'
alias vim=nvim
alias vi=nvim
export VISUAL="nvim"
export EDITOR="nvim"
alias pnpm-check='pnpm exec nx affected --target=lint && pnpm exec nx affected --target=type-check && pnpm exec nx affected --target=test'
alias cat=bat
alias down="aria2c --conf-path=${HOME}/.aria2/down.conf"
alias bdown="aria2c --conf-path=${HOME}/.aria2/bersam.conf"
alias tdown="aria2c --all-proxy=http://127.0.0.1:7777 --conf-path=${HOME}/.aria2/down.conf"
alias rdown="aria2c --enable-rpc --rpc-listen-port=6800 --rpc-listen-all=true --conf-path=${HOME}/.aria2/down.conf"
alias fly='sshuttle --dns -r 52565751e0b8cd99d30001ba@private-psamim.rhcloud.com 0/0'
alias o='xdg-open'
alias xclip='xclip -selection clipboard'
alias j='fasd_cd -d'
alias jj='fasd_cd -d -i'
alias tmux='TERM=screen-256color-bce direnv exec / tmux'
alias magit='emacsclient -nw -e \(magit-status\)'
alias tags="grep -orh '@.*' ~/Notes/journal | sort | uniq -c"
alias ledger="ledger --pedantic --explicit --strict"
# alias hledger="~/.local/bin/hledger --strict"
alias org-csv="emacs -batch -l ~/.emacs.d/core/core.el -l ~/.emacs.d/core/core-packages.el -l "~/.emacs.d/init.el" -f org-clock-csv-batch-and-exit ~/Notes/todo.org"
alias nmup="nmcli con up"
alias nmdown="nmcli con down"
alias nord="sudo --user=nordvpnteams nordvpnteams"
alias ledger-import-main='env LEDGER_ACCOUNT="Assets:Bank:Mellat" ledger-autosync /home/samim/mellat.csv -a assets:bank --unknown-account Expenses:Adjustment -L >> Notes/accounting/ledger.ledger'
alias ledger-import-shared='env LEDGER_ACCOUNT="Assets:Bank:Shared" ledger-autosync /home/samim/mellat.csv -a assets:bank --unknown-account Expenses:Adjustment -L >> Notes/accounting/ledger.ledger'
export PATH=$PATH:$HOME/.cabal/bin
export PATH=$HOME/.bin:$PATH
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools
export PATH=$PATH:$JAVA_HOME/bin
export PATH=$PYENV_ROOT/bin:$PATH
export PATH=$PATH:$HOME/.local/bin
export PATH=$PATH:$HOME/.cargo/bin
export PATH=$PATH:$HOME/.emacs.d/bin
export PATH=$PATH:$HOME/.doom.d/bin
export WORKON_HOME=~/.virtualenvs
export PATH="/opt/brew/bin:$PATH"
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
export TERM=xterm
# if [ -e /home/samim/.nix-profile/etc/profile.d/nix.sh ]; then . /home/samim/.nix-profile/etc/profile.d/nix.sh; fi # added by Nix installer
export MANPAGER='nvim +Man!'
export MANWIDTH=999
# [ -f "/home/samim/.ghcup/env" ] && source "/home/samim/.ghcup/env" # ghcup-env
# eval "$(pyenv init -)"
tmb() {
local WHERE=$TOMBS/$1
tomb open "$TOMBS/$1.tomb" $WHERE -k "$TOMBS/$1.tomb.key" -g
}
function vpn {
env ID="$1" bash -c 'nmcli con down id "$ID"; sleep 1; nmcli con up id "$ID"'
}
function cpr() {
rsync --archive -hh --partial --info=stats1,progress2 --modify-window=1 "$@"
}
function connect() {
systemctl --user stop gpg-agent.service gpg-agent.socket gpg-agent-extra.socket gpg-agent-browser.socket gpg-agent-ssh.socket
sleep 4
sudo swapoff -a
tmb pass && tmb mozilla && tmb backups && tmb other
sleep 2
systemctl --user start http.service
systemctl --user stop sync-agenda-svg.service && systemctl --user start sync-agenda-svg.timer
}
export POWERLEVEL9K_LEGACY_ICON_SPACING=true
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
function kc() {
echo "Changing to $1 k8s context"
kubectl-ctx $1;
echo "Changing to $1 k8s namespace"
kubectl-ns $1;
}
function os {
case "$(uname -s)" in
Darwin)
echo 'OSX'
;;
Linux)
echo 'Linux'
;;
CYGWIN*|MINGW32*|MSYS*|MINGW*)
echo 'MS Windows'
;;
*)
echo 'Other OS'
;;
esac
}
verify_os () {
myos=$(os)
if [[ $myos == "OSX" ]]
then
tmux set -g @thumbs-command "echo {} | tr -d '[:cntrl:]' | pbcopy"
FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
export GPG_TTY=`tty`
export GPG_TTY=`tty`
# tabtab source for packages
# uninstall by removing these lines
[[ -f ~/.config/tabtab/zsh/__tabtab.zsh ]] && . ~/.config/tabtab/zsh/__tabtab.zsh || true
if [ -f $(brew --prefix)/etc/brew-wrap ];then
source $(brew --prefix)/etc/brew-wrap
fi
export HOMEBREW_BREWFILE=~/.dotfiles/homebrew/Brewfile
export XDG_CONFIG_HOME="$HOME/.config"
# Configure Colima as Docker Host for applications which don't respect Docker Contexts
export DOCKER_HOST=unix://${HOME}/.colima/default/docker.sock
# Testcontainers should use the default Docker Socket
export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock
source <(kubectl completion zsh)
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
elif [[ $myos == "Linux" ]] then
# GPG Agent
unset SSH_AGENT_PID
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
fi
export GPG_TTY=$(tty)
# gpg-connect-agent updatestartuptty /bye >/dev/null&
source /usr/bin/virtualenvwrapper_lazy.sh
eval "$(devbox completion zsh)"
# eval "$(devbox global shellenv)"
fi
}
verify_os
source "${XDG_CONFIG_HOME:-$HOME/.config}/asdf-direnv/zshrc"
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"
source "${XDG_CONFIG_HOME:-$HOME/.config}/asdf-direnv/zshrc"
# eval "$(devbox global shellenv)"