-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_zshrc
305 lines (256 loc) · 8.38 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
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
293
294
295
296
297
298
299
300
301
302
303
304
export EDITOR="nvim"
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# # magisk
# export DYLD_LIBRARY_PATH="$(brew --prefix)/lib:$DYLD_LIBRARY_PATH"
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="robbyrussell"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
plugins=(
git
zsh-syntax-highlighting
zsh-autosuggestions
)
source $ZSH/oh-my-zsh.sh
source $HOME/.ani-cli.zsh
export LANG=en_US.UTF-8
# # Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='nvim'
# fi
#the fuck
eval $(thefuck --alias)
# NVM setup
export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
# place this after nvm initialization!
autoload -U add-zsh-hook
load-nvmrc() {
local nvmrc_path
nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version
nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [ "$nvmrc_node_version" = "N/A" ]; then
nvm install
elif [ "$nvmrc_node_version" != "$(nvm version)" ]; then
nvm use
fi
elif [ -n "$(PWD=$OLDPWD nvm_find_nvmrc)" ] && [ "$(nvm version)" != "$(nvm version default)" ]; then
echo "Reverting to nvm default version"
nvm use default
fi
}
add-zsh-hook chpwd load-nvmrc
load-nvmrc
#short cuts
alias 'lg'='lazygit'
# alias 'jsb'='js-beautify'
alias killnvim='ps -ef | grep "nvim" | grep -v grep | awk '{print $2}' | xargs kill -s KILL'
# spotx
alias spotx='bash <(curl -sSL https://spotx-official.github.io/run.sh)'
alias leet='nvim leetcode.nvim'
alias resume='~/mdtopdf/run.sh'
# alias upwas='curl -L https://github.com/yashvardhan-kukreja/whatsupstream/archive/v0.1.tar.gz | tar xvz && cd whatsupstream-* && sudo make install'
delete() {
for file in "$@"; do
if [ -e "$file" ]; then
base_name=$(basename "$file")
trash_path="$HOME/.Trash/$base_name"
counter=1
while [ -e "$trash_path" ]; do
trash_path="$HOME/.Trash/${base_name}_backup_$counter"
((counter++))
done
mv -v "$file" "$trash_path"
else
echo "File not found: $file"
fi
done
}
alias 'fcd'='cd $(find . -type d -print | fzf)'
alias 'fgc'='git checkout $(git branch | fzf)'
# bun completions
[ -s "/Users/haroonalbar/.bun/_bun" ] && source "/Users/haroonalbar/.bun/_bun"
# pnpm
export PNPM_HOME="/Users/haroonalbar/Library/pnpm"
case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
esac
# pnpm end
# color chekc #000
# yazi
function y() {
local tmp="$(mktemp -t "yazi-cwd.XXXXX")"
yazi "$@" --cwd-file="$tmp"
if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
cd -- "$cwd"
fi
rm -f -- "$tmp"
}
# =============================================================================
#
# Utility functions for zoxide.
#
# pwd based on the value of _ZO_RESOLVE_SYMLINKS.
function __zoxide_pwd() {
\builtin pwd -L
}
# cd + custom logic based on the value of _ZO_ECHO.
function __zoxide_cd() {
# shellcheck disable=SC2164
\builtin cd -- "$@"
}
# =============================================================================
#
# Hook configuration for zoxide.
#
# Hook to add new entries to the database.
function __zoxide_hook() {
# shellcheck disable=SC2312
\command zoxide add -- "$(__zoxide_pwd)"
}
# Initialize hook.
# shellcheck disable=SC2154
if [[ ${precmd_functions[(Ie)__zoxide_hook]:-} -eq 0 ]] && [[ ${chpwd_functions[(Ie)__zoxide_hook]:-} -eq 0 ]]; then
chpwd_functions+=(__zoxide_hook)
fi
# =============================================================================
#
# When using zoxide with --no-cmd, alias these internal functions as desired.
#
__zoxide_z_prefix='z#'
# Jump to a directory using only keywords.
function __zoxide_z() {
# shellcheck disable=SC2199
if [[ "$#" -eq 0 ]]; then
__zoxide_cd ~
elif [[ "$#" -eq 1 ]] && { [[ -d "$1" ]] || [[ "$1" = '-' ]] || [[ "$1" =~ ^[-+][0-9]$ ]]; }; then
__zoxide_cd "$1"
elif [[ "$@[-1]" == "${__zoxide_z_prefix}"?* ]]; then
# shellcheck disable=SC2124
\builtin local result="${@[-1]}"
__zoxide_cd "${result:${#__zoxide_z_prefix}}"
else
\builtin local result
# shellcheck disable=SC2312
result="$(\command zoxide query --exclude "$(__zoxide_pwd)" -- "$@")" &&
__zoxide_cd "${result}"
fi
}
# Jump to a directory using interactive search.
function __zoxide_zi() {
\builtin local result
result="$(\command zoxide query --interactive -- "$@")" && __zoxide_cd "${result}"
}
# Completions.
if [[ -o zle ]]; then
function __zoxide_z_complete() {
# Only show completions when the cursor is at the end of the line.
# shellcheck disable=SC2154
[[ "${#words[@]}" -eq "${CURRENT}" ]] || return 0
if [[ "${#words[@]}" -eq 2 ]]; then
_files -/
elif [[ "${words[-1]}" == '' ]] && [[ "${words[-2]}" != "${__zoxide_z_prefix}"?* ]]; then
\builtin local result
# shellcheck disable=SC2086,SC2312
if result="$(\command zoxide query --exclude "$(__zoxide_pwd)" --interactive -- ${words[2,-1]})"; then
result="${__zoxide_z_prefix}${result}"
# shellcheck disable=SC2296
compadd -Q "${(q-)result}"
fi
\builtin printf '\e[5n'
fi
return 0
}
\builtin bindkey '\e[0n' 'reset-prompt'
[[ "${+functions[compdef]}" -ne 0 ]] && \compdef __zoxide_z_complete __zoxide_z
fi
# =============================================================================
#
# Commands for zoxide. Disable these using --no-cmd.
#
\builtin alias z=__zoxide_z
\builtin alias zi=__zoxide_zi
# =============================================================================
#
# To initialize zoxide, add this to your configuration (usually ~/.zshrc):
#
eval "$(zoxide init zsh)"
# Created by `pipx` on 2024-03-19 05:30:37
export PATH="$PATH:/Users/haroonalbar/.local/bin"
# starship
eval "$(starship init zsh)"
# postgresql
export PATH="/opt/homebrew/Cellar/postgresql@16/16.3/share/postgresql@16/bin:$PATH"
export PATH="/opt/homebrew/opt/postgresql@15/bin:$PATH"
# mysql
export PATH=${PATH}:/usr/local/mysql/bin/
# golang
# export GOPATH=$HOME/go
# export GOROOT=/usr/local/go
# export GOBIN=$GOPATH/bin
# export PATH=$PATH:$GOPATH
# export PATH=$PATH:$GOROOT/bin
export PATH=$PATH:/Users/haroonalbar/go/bin
# for tailwind cli
export PATH=$PATH:/Users/haroonalbar/bin
# deno
. "/Users/haroonalbar/.deno/env"
# # Define the work function
# work() {
# echo "work" > ~/.current_mode
# }
#
# # Define the fun function
# fun() {
# cow_files=($(cowsay -l | tail -n +2 | tr ' ' '\n'))
#
# # Check if the cow_files array is not empty
# if [ ${#cow_files[@]} -eq 0 ]; then
# echo "No cow files found!"
# return 1
# fi
#
# # Select a random cow file
# random_cow=${cow_files[RANDOM % ${#cow_files[@]}]}
#
# # Check if the selected cow file exists
# if ! cowsay -f "$random_cow" < /dev/null &> /dev/null; then
# echo "Selected cow file '$random_cow' does not exist!"
# return 1
# fi
#
# # Run fortune with the selected cow file
# fortune | cowsay -f "$random_cow"
# echo "fun" > ~/.current_mode
# }
#
# # Check the current mode and run the appropriate function
# if [[ -f ~/.current_mode ]]; then
# current_mode=$(cat ~/.current_mode)
# if [[ $current_mode == "fun" ]]; then
# fun
# else
# work
# fi
# else
# # Default to work if no mode is set
# work
# fi
# Colourise go test
gotest() {
go test $* | sed ''/PASS/s//$(printf "\033[32mPASS\033[0m")/'' | sed ''/SKIP/s//$(printf "\033[34mSKIP\033[0m")/'' | sed ''/FAIL/s//$(printf "\033[31mFAIL\033[0m")/'' | sed ''/FAIL/s//$(printf "\033[31mFAIL\033[0m")/'' | GREP_COLOR="01;33" egrep --color=always '\s*[a-zA-Z0-9\-_.]+[:][0-9]+[:]|^'
}
# Mac setups alias
# Desktop clean
alias nodesk='defaults write com.apple.finder CreateDesktop false && killall Finder'
alias yesdesk='defaults write com.apple.finder CreateDesktop true && killall Finder'
# hide
alias hidet='tmux set-option status off'
alias showt='tmux set-option status on'