Dotfiles for my tiling window manager + terminal workflow.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

392 lines
9.7 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. # system {{{ #
  2. # # vim mode {{{ #
  3. # bindkey -v
  4. # function zle-line-init zle-keymap-select {
  5. # VIM_PROMPT="%{$fg_bold[yellow]%} [% NORMAL]% %{$reset_color%}"
  6. # RPS1="${${KEYMAP/vicmd/$VIM_PROMPT}/(main|viins)/} $EPS1"
  7. # zle reset-prompt
  8. # }
  9. # zle -N zle-line-init
  10. # zle -N zle-keymap-select
  11. # export KEYTIMEOUT=1
  12. # # }}} vim mode #
  13. # command line related {{{ #
  14. # search history
  15. bindkey '\e[A' history-beginning-search-backward
  16. bindkey '\e[B' history-beginning-search-forward
  17. alias cs='printf "\033c"'
  18. alias hst="history"
  19. alias nf="cs && neofetch | lolcat"
  20. # nf
  21. alias ru="xrdb ~/.Xresources"
  22. # list file sizes in megabytes with depth 1
  23. alias dum="sudo du -d 1 -B M"
  24. alias grbm="sudo grub-mkconfig -o /boot/grub/grub.cfg"
  25. function cld() { colordiff -y --suppress-common-lines $1 $2 ; }
  26. alias grep='grep --color=auto'
  27. function gpdf() {
  28. pdfgrep -n -e $1 $2
  29. }
  30. # for finding files by name
  31. export FZF_DEFAULT_COMMAND='ag --hidden --ignore .git -g ""'
  32. # find text inside files
  33. function rg() { grep -nr $1 ; }
  34. function cpd() { cp -avr $1 $2 ; }
  35. alias pk="pkill -f"
  36. # extract tar archive
  37. function utar() { tar -xzvf $1 && rm $1; }
  38. function rzip() { unzip $1 && rm $1; }
  39. function lzip() { unzip -l $1 | less; }
  40. alias mkpk="makepkg -sri"
  41. alias mkex="chmod 777"
  42. alias ctl="systemctl"
  43. alias ctle="systemctl enable"
  44. alias ctld="systemctl disable"
  45. alias ctls="systemctl start"
  46. alias wm="sudo wifi-menu"
  47. # mounting {{{ #
  48. alias udm="udisksctl mount -b"
  49. alias udmb="udisksctl mount -b /dev/sdc2"
  50. alias udu="udisksctl unmount -b"
  51. alias udub="udisksctl unmount -b /dev/sdc2"
  52. # }}} mounting #
  53. alias tc="touch"
  54. shrm() {
  55. for file in "$@"; do
  56. shred "$file" && rm "$file"
  57. done
  58. }
  59. # }}} command line related #
  60. # directory-related {{{ #
  61. alias l='ls -a'
  62. alias ll='ls -alFh'
  63. alias f="cd"
  64. f `cat /home/kevin/.oh-my-zsh/cache/last-working-dir`
  65. # alias w="cd $(cat /home/kevin/.oh-my-zsh/cache/last-working-dir)"
  66. alias rmr="rm -rf"
  67. alias mdp="mkdir -p"
  68. alias "f."="f .."
  69. alias "f.."="f ..."
  70. function mvd() { mv $1 ~/Downloads ; }
  71. alias lhd="sudo fdisk -l"
  72. alias ds="df -h | grep sd"
  73. alias chownw="sudo chown -R kevin:wheel"
  74. alias chwnm="sudo chown -R kevin:wheel /run/media/kevin"
  75. alias nbu="f /run/media/kevin/pc-backup/backups/nzxt && ll | grep gz"
  76. # }}} directory-related #
  77. # power options {{{ #
  78. alias su="systemctl suspend"
  79. alias sd="sudo shutdown 0"
  80. alias reb="sudo shutdown -r 0"
  81. alias lo="i3-msg exit"
  82. # }}} power options #
  83. # rotate monitor {{{ #
  84. function rt() {
  85. output="HDMI-0"
  86. if [ "$1" = "s" ]
  87. # if [ "${1:0:1}" = "s" ]
  88. then
  89. output="DVI-I-1"
  90. fi
  91. dir="normal"
  92. if [ "$2" = "r" ]
  93. # if [ "${1:1:2}" = "r" ]
  94. then
  95. dir="right"
  96. fi
  97. if [ "$2" = "l" ]
  98. then
  99. dir="left"
  100. fi
  101. # echo "xrandr --output \"$output\" --rotate \"$dir\""
  102. xrandr --output "$output" --rotate "$dir"
  103. }
  104. # }}} rotate monitor #
  105. # sound
  106. alias vlm="alsamixer -c 0"
  107. alias vlh="alsamixer -c 2"
  108. # apt
  109. # function apti() { sudo apt install $1 ; }
  110. # function aptr() { sudo apt remove $1 ; }
  111. # alias aptu="sudo apt upgrade"
  112. alias pc="sudo pacman -S"
  113. alias pcr="sudo pacman -Rs"
  114. alias xpc="pacman -Qqe > ~/linux-config/txt/pacman-pkgs/nzxt-pkgs.txt"
  115. # alias tri="trizen -S --noconfirm"
  116. alias tri="trizen -S"
  117. # }}} system #
  118. # config files {{{ #
  119. function gz() { grep $1 ~/linux-config/aliases/zsh_aliases ; }
  120. alias rz="source ~/linux-config/aliases/zsh_aliases"
  121. alias lca="f ~/linux-config/aliases"
  122. # i3
  123. alias i3b="f ~/i3blocks"
  124. alias pipes="pipes.sh -t 3"
  125. # UltiSnips {{{ #
  126. urnp_dir="~/.vim/plugged/vim-snippets/UltiSnips"
  127. function vsnp() { nvim ~/.vim/plugged/vim-snippets/UltiSnips/"$1".snippets ; }
  128. # }}} #
  129. # }}} config files #
  130. # applications {{{ #
  131. silent="> /dev/null 2>&1& "
  132. alias h="htop -s PERCENT_MEM"
  133. alias hc="htop -s PERCENT_CPU"
  134. alias r="ranger"
  135. alias mr="man ranger"
  136. alias clc="cloc ."
  137. function z() { nohup zathura $1 > /dev/null 2>&1& ; }
  138. function ev() { nohup evince $1 > /dev/null 2>&1& ; }
  139. function chr() { google-chrome $1 ; }
  140. alias ni="nvim"
  141. alias sni="sudo nvim"
  142. function mrk() { pandoc -o ${1%.*}.html $1 ; }
  143. # auto-clicker {{{ #
  144. function auc() { xdotool click --repeat 1000000 --delay $1 1 ; }
  145. # alias auc1="xdotool click --repeat 1000000 --delay 1 1"
  146. # alias auc3="xdotool click --repeat 1000000 --delay 300 1"
  147. # alias auc5="xdotool click --repeat 1000000 --delay 500 1"
  148. # alias kauc="pkill -f xdotool"
  149. # }}} auto-clicker #
  150. # alias rsl="java -jar ~/Downloads/RuneLite.jar"
  151. alias swex="sudo nohup ~/Downloads/swex.appimage $silent"
  152. alias vbn="cvlc --loop --alsa-gain 1 ~/Music/brown-noise.mp3"
  153. alias rmsw="rm .sw*"
  154. function rs(){ redshift -P -O $(echo "scale=2;$1*1000" | bc) ; }
  155. alias rx="redshift -x"
  156. alias gpe="gpg --encrypt --recipient"
  157. alias gpd="gpg --decrypt"
  158. alias ps="pass"
  159. alias psc="pass -c"
  160. alias pse="pass edit"
  161. alias psi="pass insert -m"
  162. alias psg="pass generate -c"
  163. alias yh="echo 'kevin.mok@live.ca' | xclip -selection clipboard"
  164. alias yg="xclip -selection clipboard ~/.password-store/social/gmail"
  165. alias yu="echo 'kevin.mok@mai.utoronto.ca' | xclip -selection clipboard"
  166. # python related {{{ #
  167. function grpy() { grep $1 *.py ; }
  168. alias p3="python3"
  169. alias py="python"
  170. # }}} python related #
  171. # }}} applications #
  172. # git {{{ #
  173. # aliases {{{
  174. alias gstr="git config credential.helper store"
  175. # add {{{ #
  176. alias ga="git add -A . && gs"
  177. alias gac="git add -A . && git commit -S"
  178. alias gacu="git add -A . && git commit"
  179. # }}} add #
  180. # diff/log {{{ #
  181. alias gd="git diff -w"
  182. function gde() { git diff --cached -- ':(exclude)'$1 ; }
  183. alias gdc="git diff --cached"
  184. alias gds="git diff --stat"
  185. alias gdt="git difftool --tool=vimdiff"
  186. alias gl="git log"
  187. alias gsl="git shortlog"
  188. # }}} diff/log #
  189. # update {{{ #
  190. alias gs="git status -u"
  191. alias gchom="git checkout master"
  192. alias gchnw="git checkout -b wip"
  193. alias gchw="git checkout wip"
  194. alias gheadm1="git reset --hard HEAD~1"
  195. alias gls="git ls-tree -r HEAD --name-only"
  196. # push {{{ #
  197. alias vcm="ni commit-msg.txt"
  198. alias gst="git stash"
  199. alias gstp="git stash pop"
  200. alias gc="git commit -S"
  201. alias gcu="git commit"
  202. alias gcam="ga && git commit --amend --no-edit -S"
  203. alias gcamp="ga && git commit --amend --no-edit -S && gpsf"
  204. # todo: fix
  205. function gcm(){ echo git commit -m \""$1"\" ; }
  206. function psgi() {
  207. git add .
  208. git commit -m -S '.'
  209. git push
  210. }
  211. alias gps="git push"
  212. alias gpsi="git push --set-upstream origin master"
  213. alias gpsf="git push --force"
  214. alias gclear="git stash clear"
  215. # }}} push #
  216. # pull {{{ #
  217. alias gpl="git pull --rebase"
  218. alias grbc="git rebase --continue"
  219. # }}} pull #
  220. # }}} update #
  221. # edit {{{ #
  222. alias vre="ni README.md"
  223. alias crm="mrk README.md"
  224. # }}} edit #
  225. # aliases }}}
  226. # functions {{{
  227. alias gcho="git checkout"
  228. alias gchon="git checkout -b"
  229. function gchof() { git checkout $1 $2 ; }
  230. alias gcln="git clone"
  231. alias gchp="git cherry-pick"
  232. alias gchpc="git cherry-pick --continue"
  233. # add multiple push repos
  234. function gremotes() {
  235. git remote set-url --add --push origin $1
  236. git remote set-url --add --push origin $2
  237. git remote -v
  238. }
  239. # gmrgr: merge repos {{{ #
  240. function gmrgr() {
  241. # 1 = remote name, 2 = remote path
  242. git remote add $1 $2
  243. git fetch $1
  244. # whichever branch you want to merge
  245. git merge --allow-unrelated-histories $1/master
  246. git remote remove $1
  247. }
  248. # }}} merge repos #
  249. # assume file unchanged
  250. alias gunc="git update-index --assume-unchanged"
  251. # delete branch locally and on server
  252. function grmb() { git push origin --delete $1 && git branch -D $1 ; }
  253. # functions }}}
  254. # }}} git #
  255. # coding projs {{{ #
  256. coding_dir="~/coding"
  257. alias cdn="$cd_coding_dir"
  258. alias gx="ni ~/Documents/csgo-config/autoexec.cfg"
  259. # trapbot {{{ #
  260. alias tb="$cd_coding_dir/trapbot"
  261. alias vtb="$cd_coding_dir/trapbot && ni scan_reddit.py"
  262. alias ptb="python scan_reddit.py"
  263. alias rtb="$cd_coding_dir/trapbot && python scan_reddit.py"
  264. # }}} trapbot #
  265. # spotify-lib-vis {{{ #
  266. spv_dir="$coding_dir""/spotify-lib-vis"
  267. alias svl="f $spv_dir/src/login"
  268. alias sva="f $spv_dir/src/api"
  269. alias svg="f $spv_dir/src/graphs"
  270. alias svscs="f $spv_dir/src/static/scss"
  271. alias svcss="f $spv_dir/src/spotifyvis/static/scss"
  272. source /home/kevin/coding/spotify-lib-vis/src/api-keys.sh
  273. function ssv() {
  274. source ../bin/activate
  275. python manage.py runserver
  276. }
  277. alias sssv="sv && ssv"
  278. alias spvdb="psql -d spotifyvis -U django"
  279. function mig() {
  280. python manage.py makemigrations
  281. python manage.py migrate --run-syncdb
  282. ssv
  283. }
  284. alias cldb="python manage.py flush --no-input && ssv"
  285. alias djs="python manage.py shell"
  286. alias upip="pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U"
  287. alias ureq="pip freeze > requirements.txt"
  288. # scan history
  289. alias hlg="cat $spv_dir/src/api/management/commands/update-history.log | tail -n 1"
  290. alias crnl="grep \"(kevin) CMD\" /var/log/syslog | tail -n 1 && hlg"
  291. alias hs="$spv_dir/src/update-history.sh && hlg"
  292. # removes all but newest file
  293. # alias rmol="ls -t | tail -n +2 | xargs rm -- && l"
  294. # }}} spotify-lib-vis #
  295. # # Stardew Valley {{{
  296. # sdv_save_dir=~/Documents/sdv-save
  297. # alias sdv="f $sdv_save_dir"
  298. # alias smp="~/Downloads/sdv/smapi/install\ on\ Linux.sh"
  299. # # alias imc="sdv && source import-save.sh coop"
  300. # function ucf() { f ~/Documents/StardewMods/UncaughtFish ; }
  301. # function svmd() { f ~/.local/share/Steam/steamapps/common/Stardew\ Valley/Mods ; }
  302. # function svm() { mv $1 ~/.local/share/Steam/steamapps/common/Stardew\ Valley/Mods ; }
  303. # # }}}
  304. alias s="cs && shellcheck"
  305. # }}} coding projs #
  306. # school {{{ #
  307. alias pdl="pdflatex"
  308. alias tcl="tex-clean"
  309. # 343
  310. alias ij="sudo ~/Downloads/idea/bin/idea.sh $silent"
  311. alias a2="f ~/Documents/school/343/a2"
  312. alias a2j="f ~/Documents/school/343/a2/java/src"
  313. alias q2="psql -U postgres -d 343-a2 -f q2-test.sql"
  314. alias q2o="psql -U postgres -d 343-a2 -f q2-test.sql -o q2.out"
  315. alias q2a="psql -U postgres -d 343-a2 -f q2.sql"
  316. alias q4="psql -U postgres -d 343-a2 -f q4-test.sql"
  317. alias q4a="psql -U postgres -d 343-a2 -f q4.sql"
  318. # }}} school #