-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.zshrc
324 lines (277 loc) · 8.66 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
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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
export ZSH=~/.oh-my-zsh
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
#ZSH_THEME="robbyrussell"
ZSH_THEME="bira"
#ZSH_THEME="agnostar"
# ZSH_THEME_RANDOM_CANDIDATES=( "bira" "agnoster" )
# CASE_SENSITIVE="true"
# HYPHEN_INSENSITIVE="true"
# DISABLE_AUTO_UPDATE="true"
# export UPDATE_ZSH_DAYS=13
# DISABLE_LS_COLORS="true"
# DISABLE_AUTO_TITLE="true"
# ENABLE_CORRECTION="true"
COMPLETION_WAITING_DOTS="true"
# DISABLE_UNTRACKED_FILES_DIRTY="true"
DISABLE_UPDATE_PROMPT=true
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"
# ZSH_CUSTOM=/path/to/new-custom-folder
plugins=(
git
colorize
colored-man-pages
cp
# tmux
# tmuxinator
repo
pip
vundle
# battery
command-not-found
zsh-syntax-highlighting
zsh-autosuggestions
# nmap
python
rsync
rand-quote
systemd
man
screen
pyenv
)
source $ZSH/oh-my-zsh.sh
BROWSER=/usr/bin/chromium
EDITOR=/usr/bin/vim
# export MANPATH="/usr/local/man:$MANPATH"
# export LANG=en_US.UTF-8
#
# Auto update path for completion
# zstyle ':completion:*' rehash true
function findpacbin () {pacman -Ql "$@" | cut -d ' ' -f2- | grep -v "/$" | grep --color=never -P "/(bin|sbin)/"}
function b64d () {base64 -d <(echo "$@")}
function mimeopen () {nohup mimeopen "$@" &>/dev/null & disown}
function libreoffice () {nohup libreoffice "$@" &>/dev/null & disown}
function firefox () {nohup firefox "$@" &>/dev/null & disown}
function ida () {nohup ida "$@" &>/dev/null & disown}
function newpy () {echo "#!/usr/bin/env python3" > "$@" && chmod +x "$@"}
function newpyvenv () {
if [ ! -d .venv ]; then
pyenv exec python -m venv .venv
fi
}
# using some functions from the archwiki
# https://wiki.archlinux.org/index.php/Bash/Functions
function extract () {
local c e i
(($#)) || return
for i; do
c=''
e=1
if [[ ! -r $i ]]; then
echo "$0: file is unreadable: \`$i'" >&2
continue
fi
case $i in
*.t*(gz|lz|xz|b*(2|z?(2))|a*(z|r?(.*(Z|bz?(2)|gz|lzma|xz)))))
c=(bsdtar xvf);;
*.7z) c=(7z x);;
*.Z) c=(uncompress);;
*.bz2) c=(bunzip2);;
*.exe) c=(cabextract);;
*.gz) c=(gunzip);;
*.rar) c=(unrar x);;
*.xz) c=(unxz);;
*.zip) c=(unzip);;
*) echo "$0: unrecognized file extension: \`$i'" >&2
continue;;
esac
command "${c[@]}" "$i"
((e = e || $?))
done
return "$e"
}
function findfileextensions () {
# find all file extensions
# default to current directory, but support more
if [ $# -lt 1 ]; then
POSITIONAL=(".")
else
POSITIONAL=("${@}")
fi
# for ignoring test files
# find ${POSITIONAL[@]} -path '**test**' -prune -false -o -name '*.*' |
find ${POSITIONAL[@]} -name '*.*' | grep --color=never -Po '(?<=\.)[^/.]+$' | sort | uniq
}
# this doesnt work on zsh
# function todo () {
# if [[ ! -f $HOME/.todo ]]; then
# touch "$HOME/.todo"
# fi
#
# if ! (($#)); then
# cat "$HOME/.todo"
# elif [[ "$1" == "-l" ]]; then
# nl -b a "$HOME/.todo"
# elif [[ "$1" == "-c" ]]; then
# > $HOME/.todo
# elif [[ "$1" == "-r" ]]; then
# nl -b a "$HOME/.todo"
# eval printf %.0s- '{1..'"${COLUMNS:-$(tput cols)}"\}
# read "number?Type a number to remove: "
# sed -i ${number}d $HOME/.todo "$HOME/.todo"
# else
# printf "%s\n" "$*" >> "$HOME/.todo"
# fi
# }
function getmaketargets () {
make -q -p $@ 2>/dev/null | grep -Pv '^#' | grep --color=never -Po '^[^:\t]+:'
# make -q -p -f /dev/null 2>/dev/null | awk -F':' '/^[.a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ {split($1,A,/ /);for(i in A)print A[i]}' | sort | uniq
}
function getzshfunctionnames () {
# should be obvious, but only works for zsh
functions | grep -Po --color=never '^[a-zA-Z]+(?= \(\))'
}
function gencppctags () {
ctags -R --c++-kinds=+p --fields=+iaS --extras=+q .
}
function build_cscope_db () {
local PROJDIR=$PWD
cd /
find $PROJDIR -regextype posix-egrep -iregex '.+\.(asm|S|h|c(c|pp|xx)*)' -type f > $PROJDIR/cscope.files
cd $PROJDIR
cscope -Rbkq
}
function lddlibs () {
ldd "$1" | grep --color=never -Po '[^ \t]+(?= \()'
}
function cfind () {
# default to current directory, but support more
if [ $# -lt 1 ]; then
POSITIONAL=(".")
else
POSITIONAL=("${@}")
fi
find ${POSITIONAL[@]} -iname '*.c' -o -iname '*.h' -o -iname '*.cc' -o -iname '*.hh' -o -iname '*.cpp' -o -iname '*.hpp' -o -iname '*.cxx' \
-o -iname '*.c.inc'
}
function cfindgp () {
# default to current directory, but support more
# TODO: handle -- here so that both commands can be provided input
# if [ $# -lt 1 ]; then
# POSITIONAL=(".")
# else
# POSITIONAL=("${@}")
# fi
find . -iname '*.c' -o -iname '*.h' -o -iname '*.cc' -o -iname '*.hh' -o -iname '*.cpp' -o -iname '*.hpp' -o -iname '*.cxx' \
-o -iname '*.c.inc' | xargs -d '\n' grep -P ${@}
}
function findclassdefs () {
# need to specify the full class name
PATTERN='class\s+(\S+\s+)*'
PATTERN+="${@}"
PATTERN+='(\s*|[:{]|\n|\r|$)'
find . -iname '*.c' -o -iname '*.h' -o -iname '*.cc' -o -iname '*.hh' -o -iname '*.cpp' -o -iname '*.hpp' -o -iname '*.cxx' \
-o -iname '*.c.inc' | xargs -d '\n' grep -P ${PATTERN}
}
function cstruct () {
if [ $# -lt 1 ]; then
echo "must provide a struct to search for"
return
fi
cfind . | xargs -d '\n' grep -P "struct\s+${@}\s*{"
}
function cdefine () {
if [ $# -lt 1 ]; then
echo "must provide a macro to search for"
return
fi
cfind . | xargs -d '\n' grep -P "define\s+${@}"
}
function ctypedef () {
if [ $# -lt 1 ]; then
echo "must provide a type to search for"
return
fi
cfind . | xargs -d '\n' grep -P "${@};"
}
function javafind () {
# default to current directory, but support more
if [ $# -lt 1 ]; then
POSITIONAL=(".")
else
POSITIONAL=("${@}")
fi
find ${POSITIONAL[@]} -type f -iname '*.java'
}
function tagsum () {
# dump out a summary of what is in the file using ctags
if [ $# -lt 1 ]; then
echo "Usage: tagsum <c-file-path>"
return
else
POSITIONAL=("${@}")
fi
CTAGS_OUTPUT=$(ctags --c++-kinds=+p --fields=+iaS --extras=+q -x ${POSITIONAL[@]})
LAST_RETURNCODE=$?
if [ $LAST_RETURNCODE -ne 0 ]; then
CTAGS_OUTPUT=$(ctags -x ${POSITIONAL[@]})
fi
echo "$CTAGS_OUTPUT" | tr -s ' ' | cut -d ' ' -f2,5- | sort -r
}
function gen_vmlinux_h () {
bpftool btf dump file /sys/kernel/btf/vmlinux format c
}
function qdisasm () {
r2 -q $1 <<<'pdi
qq'
}
function find_urls () {
find . -type f | xargs -d '\n' grep -Paio '://[a-z0-9./&+?#=%_-]+'
}
if [ -d "/opt/ghidra/support" ];then
export PATH="/opt/ghidra/support:$PATH"
fi
if [ -d "/opt/riscv/bin" ];then
export PATH="/opt/riscv/bin:$PATH"
fi
alias ll='ls -Ahl --color=auto --group-directories-first'
alias la='cat ~/.zshrc | grep -P -o "(?<=^alias\ ).+"'
alias ls='ls --color=auto'
alias eb='vim ~/.bashrc'
alias pacrepo='sudo reflector -l 20 -f 10 --save /etc/pacman.d/mirrorlist'
alias pacu='sudo pacman -Syu --noconfirm'
#alias se='ls /usr/bin /bin /sbin | sort | uniq | grep -i'
alias se='ls -1 $(echo $PATH | tr ":" "\n") | grep -vP "(^|:)$" | sort | uniq | grep -i'
alias calc='gnome-calculator &>/dev/null & disown'
alias steam='steam &>/dev/null & disown'
alias disks='ls -Ahl --color=auto /dev/disks/by-label/'
alias ev='vim ~/.vimrc'
alias show-tree='systemd-cgls / pstree'
alias ez='vim ~/.zshrc'
# alias pwsh='env TERM=xterm pwsh'
alias rake='noglob rake'
alias meow='lolcat'
command -v fortune >/dev/null && command -v cowthink >/dev/null && alias cowtune='fortune -e | cowthink -n'
alias inet4='ip addr | grep -P "inet[^6]"'
alias list-bindsyms='cat ~/.config/i3/config | grep -P "^bindsym" --color=never'
alias ei3='vim ~/.config/i3/config'
alias quickswap='mkdir -p /mnt/ram; mount -t tmpfs tmpfs /mnt/ram -o size=4096'
alias ccat='highlight'
# alias ssh='TERM=linux ssh'
alias sshpass='TERM=linux sshpass'
alias ansible-vault="EDITOR=$EDITOR ansible-vault"
alias gb='git branch -a | cat -'
alias gbv='git branch -vv'
alias calcurse='calcurse -D ~/.config/calcurse'
alias glggv='git log --graph --full-history --all --color --pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s"'
alias yeet='yay -Rsn'
alias reload='source ~/.zshrc'
alias qrun='export AFL_PATH="$HOME/cloned/AFLplusplus/"; export AFL_USE_QASAN=1; $AFL_PATH/qemu_mode/qemuafl/build/qemu-x86_64 '
command -v pypy3 >/dev/null && alias ipypy3='pypy3 -mIPython'
command -v pypy3 >/dev/null && alias pypy3pip='pypy3 -mpip'
cowtune 2>/dev/null
# command -v virtualenvwrapper.sh >/dev/null && source $(whereis virtualenvwrapper.sh | cut -f2- -d ' ')'
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
#export PATH="$PATH:$HOME/.rvm/bin"
source "$HOME/.zshenv"