-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_zshrc
More file actions
143 lines (117 loc) · 3.52 KB
/
dot_zshrc
File metadata and controls
143 lines (117 loc) · 3.52 KB
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
# --------------------------------- antigen --------------------------------- #
# Activate antigen
source $HOME/.antigen/antigen.zsh
# Use OMZ repo
antigen use oh-my-zsh
# Add plugins
antigen bundle archlinux
antigen bundle aws
antigen bundle git
antigen bundle docker
antigen bundle docker-compose
antigen bundle fzf
antigen bundle gcloud
antigen bundle golang
antigen bundle helm
antigen bundle kubectl
antigen bundle kubectl-autocomplete
antigen bundle kubectx
antigen bundle pip
antigen bundle python
antigen bundle uv
antigen bundle vscode
antigen bundle poetry
antigen bundle terraform
# Add syntax highlight and suggestion
antigen bundle zsh-users/zsh-autosuggestions
antigen bundle zsh-users/zsh-syntax-highlighting
# Antigen apply
antigen apply
# Create completion folder if missing, see: https://github.com/zsh-users/antigen/issues/688
# mkdir -p $HOME/.antigen/bundles/robbyrussell/oh-my-zsh/cache/completions
# ---------------------------------- shell ---------------------------------- #
# Starship
eval "$(starship init zsh)"
# fnm
eval "$(fnm env --use-on-cd --version-file-strategy=recursive --shell zsh)"
# I'm so clumsy
alias celar="echo door"
# xclip
alias to-clip="xclip -selection clipboard"
# zoxide
eval "$(zoxide init zsh)"
alias cd="z"
# OSX like file explorer command
function open(){
nohup nautilus $1 >/dev/null 2>&1 &
}
# ------------------------------- kubernetes -------------------------------- #
compdef kubecolor=kubectl
alias k="kubecolor"
alias kctx="kubectx"
# --------------------------------- python ---------------------------------- #
# Poetry util
function poetry-fix-lock(){
if [[ ! -d $1 ]]; then
echo "No folder passed as argument"
return 1
fi
poetry_projects=()
find_poetry_projects=$(find $1 -name "*pyproject.toml" -not -path "./.git/*" -exec dirname {} \;)
# Read each line into the array
while IFS= read -r file; do
poetry_projects+=("$file")
done <<< "$find_poetry_projects"
# User input for safeguard
echo "Found ${#poetry_projects[@]} poetry projects in $(readlink -f $1)"
echo "Proceed ? [y/n]"
read -r ANS
clean_ans=$(echo "$ANS" | tr '[:upper:]' '[:lower:]')
if [[ ${clean_ans:0:1} == "y" ]]; then
# Check and fix poetry projects
for poetry_project in ${poetry_projects[@]}; do
poetry_project_full=$(readlink -f $poetry_project)
echo "> checking ${poetry_project}"
poetry check --directory=$poetry_project_full || poetry lock --no-update --directory=$poetry_project_full
done
else
return 0
fi
}
# --------------------------------- docker ---------------------------------- #
docker() {
case $1 in
ps)
shift
command dops "$@"
;;
*)
command docker "$@";;
esac
}
# ----------------------------------- git ----------------------------------- #
function git-list-untracked() {
git fetch --prune && git branch -r | awk "{print \$1}" | grep -E -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk "{print \$1}"
}
function git-remove-untracked(){
case $1 in
-f)
shift
git_branch_arg="-D"
;;
*)
git_branch_arg="-d";;
esac
git-list-untracked | xargs git branch $git_branch_arg
}
function glab-export-env(){
case $1 in
--help | -h)
glab variable export --help
;;
*)
esac
glab variable export "$@" | jq -r '.[] | "\(.key)=\"\(.value)\""' 1> .env
}
# ---------------------------------- local ---------------------------------- #
source ~/.zshrc.local