-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
258 lines (206 loc) · 7.58 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
# .zshrc
# If not chsh to zsh make sure the SHELL value is sane
export SHELL="$(which zsh)"
# Set XDG Base directory specificatins
export XDG_CONFIG_HOME="${HOME}/.config"
export XDG_CACHE_HOME="${HOME}/.cache"
export XDG_DATA_HOME="${HOME}/.local/share"
# XDG_RUNTIME_DIR should generally default to
[[ -z "${XDG_RUNTIME_DIR}" ]] && export XDG_RUNTIME_DIR="/run/user/$(id -u)/"
cmdExists() {
[[ -z "$1" ]] && echo "No argument supplied" && exit 1
command -v $1 &> /dev/null
}
# In case this fails: https://stackoverflow.com/a/48877084
# sudo ln -sf /usr/share/terminfo/x/xterm-color /usr/share/terminfo/x/xterm-256color
# or follow the terminfo steps for alacritty
if cmdExists tmux && [[ -z "${TMUX}" ]]; then
tmux attach 2> /dev/null || tmux
fi
# 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
# Node Version manager for managing node versions
export NVM_DIR="$HOME/.nvm"
[[ -s "$NVM_DIR/nvm.sh" ]] && . "$NVM_DIR/nvm.sh" # This loads nvm
[[ -s "$NVM_DIR/bash_completion" ]] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
#if you do a 'rm *', Zsh will give you a sanity check!
setopt RM_STAR_WAIT
# Zsh has a spelling corrector
setopt CORRECT
# Make sure job control is enabled (default yes for interactive shells)
setopt monitor
# Set our username so the prompt hides it
export DEFAULT_USER="$(whoami)"
# Set ssh-agent params
zstyle :omz:plugins:ssh-agent agent-forwarding yes
zstyle :omz:plugins:ssh-agent lifetime 1h
zstyle :omz:plugins:ssh-agent quiet yes # for Powerlevel10k instant prompt
zstyle :omz:plugins:ssh-agent lazy yes # prompt & load after first use of the key
# Add local bin directories to PATH
export PATH="${PATH}:${HOME}/.local/bin"
if [[ -d "${HOME}/.composer/vendor/bin" ]]; then
export PATH="${PATH}:${HOME}/.composer/vendor/bin"
fi
if cmdExists go; then
export GOPATH="${HOME}/.local/go"
export GOBIN="${GOPATH}/bin"
export PATH="${PATH}:${GOBIN}"
if [[ ! -d "${GOBIN}" ]]; then
mkdir -p "${GOBIN}"
fi
# TODO: Make an associative array and test if all the binaries exist
# Install go plugins
# for MOD in 'antonmedv/[email protected]' 'andreazorzetto/[email protected]' 'cpuguy83/go-md2man/[email protected]'
# do
# go install "github.com/${MOD}"
# done;
fi
if cmdExists java; then
# Get the symlink target from java executable in PATH, then calculate JAVA_HOME
# by removing '/bin/java' from the end of the path which readlink gives
export JAVA_HOME="$(dirname $(dirname $(readlink -f $(which java))))"
fi
if [[ -d "${HOME}/.poetry/bin" ]]; then
export PATH="${HOME}/.poetry/bin:$PATH"
fi
# Make VIM the default editor
export EDITOR=vim
# Use Docker BuildKit
export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1
# Always opt out of the .NET telemetry
export DOTNET_CLI_TELEMETRY_OPTOUT=1
# This messes up highlight
# zstyle :incremental list yes
# autoload -U incremental-complete-word
# zle -N incremental-complete-word
# bindkey '^X' incremental-complete-word
# Check if zplug is installed
if [[ ! -d ~/.zplug ]] && cmdExists gawk; then
git clone https://github.com/zplug/zplug ~/.zplug
fi
source ~/.zplug/init.zsh
##################################zsh plugins######################################
zplug 'zplug/zplug', hook-build:'zplug --self-manage'
zplug "romkatv/powerlevel10k", as:theme, depth:1
# TODO: Figure out a better solution for binaries
# Can't compile direnv without go
# if cmdExists go; then
# zplug "direnv/direnv", as:command, rename-to:direnv, use:"direnv", at:v2.23.3 hook-build:"make"
# fi
# Use oh my zsh defaults because we <3 it!
local omzLibs=(
clipboard
compfix
completion
correction
diagnostics
directories
functions
git
grep
history
key-bindings
misc
nvm
prompt_info_functions
spectrum
termsupport
theme-and-appearance
)
for lib in "${omzLibs[@]}"; do
zplug "lib/${lib}", from:oh-my-zsh, depth:1
done;
# Use cool oh my zsh plugins!
local omzPlugins=(
catimg
colored-man-pages
colorize
command-not-found
direnv
fancy-ctrl-z
fd
git-auto-fetch
kubectl
man
ssh-agent
# TODO: Figure out forwarding of GPG keys
# gpg-agent
sudo
z
zsh-interactive-cd
)
for PLUGIN in "${omzPlugins[@]}"; do
zplug "plugins/${PLUGIN}", from:oh-my-zsh, depth:1
done;
zplug 'junegunn/fzf', depth:1, hook-build:'./install --key-bindings --completion --no-update-rc --no-fish'
# Fish shell like autosuggestions
zplug "zsh-users/zsh-autosuggestions", depth:1
zplug "zsh-users/zsh-syntax-highlighting", depth:1
##################################plugins for others######################################
zplug "tmux-plugins/tpm", depth:1
# Install packages that have not been installed yet
if ! zplug check --verbose; then
printf "Install? [y/N]: "
if read -q; then
echo; zplug install
fi
fi
zplug load
##################################fix/config for plugins######################################
# For some reason some plugins put their completion list in
# $ZSH_CACHE_DIR/completion but that dir does not exist by default, so create it here
# Can't do this before zplug load because $ZSH & ZSH_CACHE_DIR is exported after load
# TODO: Put this in a custom plugin
mkdir -p "${ZSH_CACHE_DIR}completions"
if cmdExists direnv; then
# supress DIRENV messages for instant prompt, comment the line below for debugging DIRENV
export DIRENV_LOG_FORMAT=
eval "$(direnv hook zsh)"
fi
# Because fzf likes to make a file in the home directory, enable it manually here
if [[ -f ~/.fzf.zsh ]]; then
source ~/.fzf.zsh
if cmdExists fd; then
_fzf_compgen_path() {
fd --color=always --follow --hidden --exclude ".git" . "$1"
}
_fzf_compgen_dir() {
fd --type d --color=always --follow --hidden --exclude ".git" . "$1"
}
export FZF_DEFAULT_COMMAND="fd --type file --color=always --follow --hidden --exclude .git"
export FZF_DEFAULT_OPTS="--ansi"
export FZF_CTRL_T_COMMAND="${FZF_DEFAULT_COMMAND}"
export FZF_TMUX_OPTS="-p 95%,60%"
fi
fi
#Enable Asynchronous Mode for suggestions
export ZSH_AUSOSUGGEST_USE_ASYNC=true
# Override oh-my-zsh history size
export HISTSIZE=100000
export SAVEHIST=${HISTSIZE}
# Stop using pushd like a crazy person
unsetopt auto_pushd
# Only enable this once you have zsh 5.7 or greater
[[ "$COLORTERM" == (24bit|truecolor) || "${terminfo[colors]}" -eq '16777216' ]] || zmodload zsh/nearcolor
##################################Load custom files######################################
for file in vars aliases func; do
[[ ! -f "${HOME}/.shell/${file}.sh" ]] || source "${HOME}/.shell/${file}.sh"
done
##################################Custom function Configs######################################
#Set up proxy if in VPN or not
[[ "${ALWAYS_PROXY_PROBE}" == "true" ]] && proxyProbe
# Load Angular CLI autocompletion.
# source <(ng completion script)
##################################Misc######################################
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
PATH="/home/revan/perl5/bin${PATH:+:${PATH}}"; export PATH;
PERL5LIB="/home/revan/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
PERL_LOCAL_LIB_ROOT="/home/revan/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
PERL_MB_OPT="--install_base \"/home/revan/perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=/home/revan/perl5"; export PERL_MM_OPT;