-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdot_zshrc
206 lines (176 loc) · 6.68 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
203
204
205
206
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.zgenom/sources/ohmyzsh/ohmyzsh/___"
# Aliases
alias aui="sudo apt-get update; sudo apt-get upgrade; sudo apt-get dist-upgrade"
alias kb="keybase"
# alias gpg="gpg2"
alias cls="clear"
# load zgenom
source "${HOME}/.zgenom/zgenom.zsh"
# before oh-my-zsh runs (and thus runs compinit), enable homebrew completions
# see https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh
if type brew &>/dev/null; then
FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH
autoload -Uz compinit
compinit
fi
# plugin time
if ! zgenom saved; then
echo "Creating a zgenom save"
zgenom ohmyzsh
# plugins
zgenom ohmyzsh plugins/git
zgenom ohmyzsh plugins/sudo
zgenom ohmyzsh plugins/brew
zgenom ohmyzsh plugins/emoji
zgenom ohmyzsh plugins/common-aliases
zgenom ohmyzsh plugins/systemd
if [[ -f /etc/lsb-release ]] then
zgenom ohmyzsh plugins/debian
fi
if [[ -f /etc/arch-release ]] then
zgenom ohmyzsh plugins/archlinux
fi
if [[ -f /etc/redhat-release ]] && [[ $(cat /etc/redhat-release | awk -F'[^0-9]+' '{ print $2 }') -lt 8 ]] then
zgenom ohmyzsh plugins/yum
elif [[ -f /etc/redhat-release ]] && [[ $(cat /etc/redhat-release | awk -F'[^0-9]+' '{ print $2 }') -ge 8 ]] then
zgenom ohmyzsh plugins/dnf
fi
if [[ $(uname) == "Darwin" ]] then
zgenom ohmyzsh plugins/macos
zgenom load unixorn/tumult.plugin.zsh
fi
zgenom load zsh-users/zsh-syntax-highlighting
zgenom load MichaelAquilina/zsh-you-should-use
zgenom load unixorn/git-extra-commands
zgenom load peterhurford/git-it-on.zsh
# below plugin is meant for solarized-dark themed terminals
zgenom load zlsun/solarized-man
# theme
zgenom load subnixr/minimal
# save all to init script
zgenom save
fi
# For a complete refresh of rc files, with an opportunity to see update info
alias shrefresh="zgenom update; chezmoi update; vim +PlugInstall +qall; vim +PlugUpdate"
# For the same, but silent (e.g., to set as a cron job)
alias shrefresh_quiet="zgenom update; chezmoi update; vim +PlugInstall +qall; vim +PlugUpdate +qall"
# if using iTerm2 on mac
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
# PATH additions
if [[ -d $HOME/.gnupg ]]; then
export PATH="$PATH:$HOME/.gnupg"
fi
if [[ -d /home/linuxbrew ]] && ([[ -f /etc/lsb-release ]] || [[ -f /etc/os-release ]]); then
export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
export MANPATH="/home/linuxbrew/.linuxbrew/share/man:$MANPATH"
export INFOPATH="/home/linuxbrew/.linuxbrew/share/info:$INFOPATH"
export PATH="/home/linuxbrew/.linuxbrew/opt/python/libexec/bin:$PATH"
export PATH=$PATH:/home/linuxbrew/.linuxbrew/opt/go/libexec/bin
export PATH="/home/linuxbrew/.linuxbrew/sbin:$PATH"
export PATH"=/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/current/bin:$PATH"
fi
# theme config
MNML_RPROMPT=('mnml_cwd 2' mnml_git)
# If using Microsoft Terminal, default to ~ rather than /mnt/c/Users/[username]
# and also alias clip.exe to clip
## WSL1
if [[ "$(uname -a)" == *"Microsoft"* ]]; then
cd ~
alias clip="clip.exe"
fi
## WSL2
if [[ "$(uname -a)" == *"microsoft"* ]]; then
cd ~
alias clip="clip.exe"
fi
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# fzf sourcing
## setup
if [[ ! "$PATH" == *${HOME}/.fzf/bin* ]]; then
export PATH="${PATH:+${PATH}:}${HOME}/.fzf/bin"
fi
## autocompletion
[[ $- == *i* ]] && source "~/.fzf/shell/completion.zsh" 2> /dev/null
## keybindings
source "${HOME}/.fzf/shell/key-bindings.zsh"
# personal bin folder
if [[ ! "$PATH" == *${HOME}/bin* ]]; then
export PATH="${PATH:+${PATH}:}${HOME}/bin"
fi
# similar to the above but to satisfy a particular install
if [[ ! "$PATH" == *${HOME}/.local/bin* ]]; then
export PATH="${PATH:+${PATH}:}${HOME}/.local/bin"
fi
# theming for sharkdp/bat
export BAT_THEME="Solarized (dark)"
# if neovim is present, make that the editor; if not, vim
if [[ `which nvim &>/dev/null && echo $?` == 0 ]]; then
export EDITOR="nvim"
export VISUAL="$(which nvim)"
else
export EDITOR="vim"
fi
# path addition for corbindavenport/nexus-tools
if [[ -d $HOME/.nexustools ]] && [[ ! "$PATH" == *${HOME}/.nexustools* ]]; then
export PATH="${PATH:+${PATH}:}${HOME}/.nexustools"
fi
# annoying workaround for macFUSE issues on macOS
if [[ $(uname) == "Darwin" ]]; then
alias macfuse_reset="sudo kextunload -b io.macfuse.filesystems.macfuse"
fi
# detect WSL and if used, add some aliases to make the below easier
## WSL1
if [[ "$(uname -a)" == *"Microsoft"* ]]; then
alias ssh="ssh.exe"
alias ssh-add="ssh-add.exe"
alias op="op.exe"
fi
## WSL2
if [[ "$(uname -a)" == *"microsoft"* ]]; then
alias ssh="ssh.exe"
alias ssh-add="ssh-add.exe"
alias op="op.exe"
fi
# if 1Password CLI is present, add completions
if [[ `which op &>/dev/null && echo $?` == 0 ]]; then
eval "$(op completion zsh)"; compdef _op op
fi
# deal with annoying tab-completion issue and enforce complete-on-first
## (not sure how this issue popped up, but... https://imgur.com/U1CqMH8)
zstyle '*' single-ignored complete
# fix homebrew version issues on macOS?
if [ -d "/opt/homebrew" ]; then
alias vim="/opt/homebrew/bin/vim"
fi
# if cantino/mcfly is present, initialize it
if [[ `which mcfly &>/dev/null && echo $?` == 0 ]]; then
eval "$(mcfly init zsh)"
fi
# for shodan CLI
if [ -d "${HOME}/Library/Python/3.11/bin" ]; then
export PATH="${PATH}:${HOME}/Library/Python/3.11/bin"
fi
# if on macOS, create some aliases to ease starting and exiting GlobalProtect
if [[ $(uname) == "Darwin" && `ls -1 /Library/LaunchAgents/com.paloaltonetworks.gp.pangp* 2>/dev/null | wc -l ` -gt 0 ]]; then
alias pangpon="launchctl load /Library/LaunchAgents/com.paloaltonetworks.gp.pangp*"
alias pangpoff="launchctl unload /Library/LaunchAgents/com.paloaltonetworks.gp.pangp*"
fi
# if on WSL, determine winhome; if a certain tool isn't available, prompt to install
#{{- if eq .chezmoi.os "linux" -}}
# {{- if (and (.chezmoi.kernel.osrelease | lower | contains "microsoft") (lookPath "wslvar")) -}}
if [[ "$(uname -a)" == *"microsoft"* || "$(uname -a)" == *"Microsoft"* && `which wslvar &>/dev/null && echo $?` == 0 ]]; then
winhome="$(wslpath "$(wslvar USERPROFILE 2>/dev/null)")"
export winhome
elif [[ "$(uname -a)" == *"microsoft"* || "$(uname -a)" == *"Microsoft"* && `which wslvar &>/dev/null && echo $?` -ne 0 ]]; then
echo "looks like you don't have wslu yet. you should probably install that"
fi
# if terraform is present, enable its provided completion
if [[ `which terraform &>/dev/null && echo $?` == 0 ]]; then
autoload -U +X bashcompinit && bashcompinit
complete -o nospace -C $(which terraform) terraform
fi
# if opentofu is present, enable its provided completion
if [[ `which tofu &>/dev/null && echo $?` == 0 ]]; then
complete -o nospace -C $(which tofu) tofu
fi