-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
197 lines (170 loc) · 5.31 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
#Author: Vaibhav Bhandari, Jan 2, 2022
echo "Loading ~/.zshrc - Vaibhav's homescript"
#pick visual studio code for editing
export EDITOR='nvim'
### Program truths
show-info(){ ##show all home-page logic, short-cut is t
cat <<< "
- day file is $DAY_FILE
- digital locker (identity documents, insurances, wills, etal.)
- for home script, backup in google drive
- photos are in google photos
- code is in github
- password are in google passwords
"
}
OBS_DIR="$HOME/Library/Mobile Documents/iCloud~md~obsidian/Documents/Personal-Data"
local todayfileDir="$OBS_DIR/data/content/daily"
local todayfile=`date "+%Y-%m-%d"`".md"
DAY_FILE="$todayfileDir/$todayfile"
dashboard(){ ##show dashbaord information, short-cut is d
cat $DAY_FILE
}
### Help
help() ##this help file
{
echo "Commands:"
echo "help | h | ?"
echo "e -- edit homescript"
echo "l -- load homescript"
echo "c -- commit homescript locally as well as to origin (uses yadm)"
echo "me -- go to me directory"
echo "cdcyber -- go to cyber defenders www directory"
list-fn-docs
}
list-fn-docs() { ## List all function documentation from ~/.zshrc
grep -E '^[a-zA-Z_-]+\(\)\{.*?##.*$' ~/.zshrc | \
sort | \
awk 'BEGIN {FS="[\(\) ]*{[ ]*##"} {print $1 " -- " $2}'
}
alias 'cdcyber'='cd /Users/vaibhavb/Documents/GitHub/cyberdefenders/www-homepage'
alias '?'='help'
alias 'h'='help'
alias 't'='show-info'
alias 'd'='dashboard'
###
### Software to Install
programs=(yadm tmux iTerm2 gdrive adobe-illustrator burp-suite sslscan)
install-tools(){ ##list programs to install on this computer
for i in ${programs[@]}; do
echo $i
done;
}
### BASE STRUCTURE
export PROJECTS=("gcal" "github - vaibhavb, cyberdefenders" "gdrive" "adobe" "..this machine>>")
export CURR_PROJECT_DIR="$HOME/Desktop/Current-Projects/"
list-projects(){ ##list all projects on this computer
for i in ${PROJECTS[@]}; do
echo $i
done;
for e in `ls $CURR_PROJECT_DIR`; do
echo $e
done;
}
export CURR_DIR="$HOME/Documents/GitHub/"
export CURR_DATA_DIR="$HOME/Documents/Data"
export THIS_FILE=~/.zshrc
which-projects(){ ##current projects use it before cdc
ls -l $CURR_DIR
}
cdt() {
local base_dir=$1
local dir
dir=$(find $base_dir -type d -name "*$2*" -print -quit 2>/dev/null)
if [ -n "$dir" ]; then
cd "$dir"
else
echo "Not found"
fi
}
cdc(){ ##special cd command e.g cdc tools
cdt $CURR_DIR $1
}
cdd(){ ##special cd command for data e.g cdd tools
cdt $CURR_DATA_DIR $1
}
get-date(){ ##get date in iso 8601 format
date -u +"%Y-%m-%dT%H:%M:%SZ"
}
alias l='source $THIS_FILE'
alias e='$EDITOR $THIS_FILE'
# commit to yadm and push to github
alias c='yadm add $THIS_FILE; EDITOR="vi" yadm commit; yadm push origin main'
#### DOMAINS
alias learn='cd $CURR_DIR/learn/'
alias me='cd $CURR_DIR/me/'
alias tools='cd $CURR_DIR/tools/'
#### PROJECTS
# CyberSecurity Bootcamp
alias cdcb='cd $CURR_DIR/learn/cyber-bootcamp'
# Round Feather
alias cdrf='cd $CURR_DIR/round-feather'
# alias cdj='cd $CURR_DIR/jasper'
alias cdnfx-vuln='cd $CURR_DIR/nfx/vuln-project'
# alias listen inn
alias cdli='cd $CURR_DIR/art/listeninn'
alias cdttt='cd $CURR_DIR/learn/javascript/tictactoe'
### TOOLS
export PATH="$PATH:/Users/vaibhavb/Documents/Tools/"
show-today() {
cat <<< "
- Today is `get-date`
- Day file is $DAY_FILE
"
}
# show it!
show-today
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/vaibhavb/Downloads/google-cloud-sdk/path.zsh.inc' ]; then . '/Users/vaibhavb/Downloads/google-cloud-sdk/path.zsh.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/Users/vaibhavb/Downloads/google-cloud-sdk/completion.zsh.inc' ]; then . '/Users/vaibhavb/Downloads/google-cloud-sdk/completion.zsh.inc'; fi
eval "$(starship init zsh)"
alias z="zellij"
#vim in zsh
bindkey -v
# git commands
alias g='git'
alias gcm='git commit -m'
alias gcam='git commit -a -m'
alias n='nvim'
export PATH=$PATH:/usr/local/opt/riscv-gnu-toolchain/bin
export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"
export PYTHONDONTWRITEBYTECODE=1
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
alias cdo='cd /Users/vaibhavb/Library/Mobile\ Documents/iCloud~md~obsidian/Documents/Personal-Data'
alias cdmd='cd /Users/vaibhavb/Library/Mobile\ Documents/iCloud\~md\~obsidian/Documents/'
get-md(){ ## get markdown from a URL
local url=$1
if [ -z "$url" ]; then
echo "Usage: get-md <url>"
return 1
fi
curl "https://md.dhr.wtf/?url=$url"
}
export PATH=$HOME/.venvs/gensh/bin:$PATH
_gensh_complete() {
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments -C \
'-p[Select a pattern]: :->patterns'
case $state in
patterns)
local -a patterns
patterns=( $(gensh -c list_patterns | awk '{print $2}' | awk -F'-' '{print $1}' | tr -d ':') )
_describe 'patterns' patterns
;;
esac
}
compdef _gensh_complete gensh
if [[ -z "$ZELLIJ" ]]; then
exec zellij
fi
alias copy_patterns='cp -r ~/.config/gensh/patterns/ ~/.config/gensh/fabric/patterns/'
add-pattern(){ ## add the pattern to gensh repo
local dir="$HOME/.config/gensh/patterns/$1"
mkdir -p "$dir" && nvim "$dir/user.md"
}