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.

390 lines
9.5 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
  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 ctle="systemctl enable"
  43. alias ctls="systemctl start"
  44. # mounting {{{ #
  45. alias udm="udisksctl mount -b"
  46. alias udmb="udisksctl mount -b /dev/sdc2"
  47. alias udu="udisksctl unmount -b"
  48. alias udub="udisksctl unmount -b /dev/sdc2"
  49. # }}} mounting #
  50. alias tc="touch"
  51. shrm() {
  52. for file in "$@"; do
  53. shred "$file" && rm "$file"
  54. done
  55. }
  56. # }}} command line related #
  57. # directory-related {{{ #
  58. alias l='ls -a'
  59. alias ll='ls -alFh'
  60. # alias f="cd"
  61. function f() { cd $1 && pwd > ~/.last_dir ; }
  62. # function f() { cd $1 && pwd > ~/.last_dir && ls -a ; }
  63. # restore last dir
  64. if [ -f ~/.last_dir ]
  65. # then cd `cat ~/.last_dir`
  66. then f `cat ~/.last_dir`
  67. fi
  68. alias rmr="rm -rf"
  69. alias mdp="mkdir -p"
  70. alias "f."="f .."
  71. alias "f.."="f ..."
  72. function mvd() { mv $1 ~/Downloads ; }
  73. alias lhd="sudo fdisk -l"
  74. alias ds="df -h | grep sd"
  75. alias nbu="f /run/media/kevin/pc-backup/backups/nzxt && ll | grep gz"
  76. # }}} directory-related #
  77. # power options {{{ #
  78. alias p="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 za() { 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. # python related {{{ #
  166. function grpy() { grep $1 *.py ; }
  167. alias p3="python3"
  168. alias py="python"
  169. # }}} python related #
  170. # }}} applications #
  171. # git {{{ #
  172. # aliases {{{
  173. alias gstr="git config credential.helper store"
  174. # add {{{ #
  175. alias ga="git add -A . && gs"
  176. alias gac="git add -A . && git commit -S"
  177. alias gacu="git add -A . && git commit"
  178. # }}} add #
  179. # diff/log {{{ #
  180. alias gd="git diff -w"
  181. function gde() { git diff --cached -- ':(exclude)'$1 ; }
  182. alias gdc="git diff --cached"
  183. alias gds="git diff --stat"
  184. alias gdt="git difftool --tool=vimdiff"
  185. alias gl="git log"
  186. alias gsl="git shortlog"
  187. # }}} diff/log #
  188. # update {{{ #
  189. alias gs="git status -u"
  190. alias gchom="git checkout master"
  191. alias gchnw="git checkout -b wip"
  192. alias gchw="git checkout wip"
  193. alias gheadm1="git reset --hard HEAD~1"
  194. alias gls="git ls-tree -r HEAD --name-only"
  195. # push {{{ #
  196. alias vcm="ni commit-msg.txt"
  197. alias gst="git stash"
  198. alias gstp="git stash pop"
  199. alias gc="git commit -S"
  200. alias gcu="git commit"
  201. alias gcam="ga && git commit --amend --no-edit -S"
  202. alias gcamp="ga && git commit --amend --no-edit -S && gpsf"
  203. # todo: fix
  204. function gcm(){ echo git commit -m \""$1"\" ; }
  205. function psgi() {
  206. git add .
  207. git commit -m '.'
  208. git push
  209. }
  210. alias gps="git push"
  211. alias gpsi="git push --set-upstream origin master"
  212. alias gpsf="git push --force"
  213. alias gclear="git stash clear"
  214. # }}} push #
  215. # pull {{{ #
  216. alias gpl="git pull --rebase"
  217. alias grbc="git rebase --continue"
  218. # }}} pull #
  219. # }}} update #
  220. # edit {{{ #
  221. alias vre="ni README.md"
  222. alias crm="mrk README.md"
  223. # }}} edit #
  224. # aliases }}}
  225. # functions {{{
  226. alias gcho="git checkout"
  227. alias gchon="git checkout -b"
  228. function gchof() { git checkout $1 $2 ; }
  229. alias gcln="git clone"
  230. alias gchp="git cherry-pick"
  231. alias gchpc="git cherry-pick --continue"
  232. # add multiple push repos
  233. function gremotes() {
  234. git remote set-url --add --push origin $1
  235. git remote set-url --add --push origin $2
  236. git remote -v
  237. }
  238. # gmrgr: merge repos {{{ #
  239. function gmrgr() {
  240. # 1 = remote name, 2 = remote path
  241. git remote add $1 $2
  242. git fetch $1
  243. # whichever branch you want to merge
  244. git merge --allow-unrelated-histories $1/master
  245. git remote remove $1
  246. }
  247. # }}} merge repos #
  248. # assume file unchanged
  249. alias gunc="git update-index --assume-unchanged"
  250. # delete branch locally and on server
  251. function grmb() { git push origin --delete $1 && git branch -D $1 ; }
  252. # functions }}}
  253. # }}} git #
  254. # coding projs {{{ #
  255. coding_dir="~/coding"
  256. alias cdn="$cd_coding_dir"
  257. alias gx="ni ~/Documents/csgo-config/autoexec.cfg"
  258. # trapbot {{{ #
  259. alias tb="$cd_coding_dir/trapbot"
  260. alias vtb="$cd_coding_dir/trapbot && ni scan_reddit.py"
  261. alias ptb="python scan_reddit.py"
  262. alias rtb="$cd_coding_dir/trapbot && python scan_reddit.py"
  263. # }}} trapbot #
  264. # spotify-lib-vis {{{ #
  265. spv_dir="$coding_dir""/spotify-lib-vis"
  266. alias svl="f $spv_dir/src/login"
  267. alias sva="f $spv_dir/src/api"
  268. alias svg="f $spv_dir/src/graphs"
  269. alias svscs="f $spv_dir/src/static/scss"
  270. alias svcss="f $spv_dir/src/spotifyvis/static/scss"
  271. # source ~/coding/spotify-lib-vis/src/api-keys.sh
  272. # source "$spv_dir""/src/api-keys.sh"
  273. function ssv() {
  274. source ../bin/activate
  275. python manage.py runserver
  276. }
  277. alias spvdb="psql -d spotifyvis -U django"
  278. function mig() {
  279. python manage.py makemigrations
  280. python manage.py migrate --run-syncdb
  281. ssv
  282. }
  283. alias cldb="python manage.py flush --no-input && ssv"
  284. alias djs="python manage.py shell"
  285. alias upip="pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U"
  286. alias ureq="pip freeze > requirements.txt"
  287. # scan history
  288. alias hlg="cat $spv_dir/src/api/management/commands/update-history.log | tail -n 1"
  289. alias crnl="grep \"(kevin) CMD\" /var/log/syslog | tail -n 1 && hlg"
  290. alias hs="$spv_dir/src/update-history.sh && hlg"
  291. # removes all but newest file
  292. # alias rmol="ls -t | tail -n +2 | xargs rm -- && l"
  293. # }}} spotify-lib-vis #
  294. # # Stardew Valley {{{
  295. # sdv_save_dir=~/Documents/sdv-save
  296. # alias sdv="f $sdv_save_dir"
  297. # alias smp="~/Downloads/sdv/smapi/install\ on\ Linux.sh"
  298. # # alias imc="sdv && source import-save.sh coop"
  299. # function ucf() { f ~/Documents/StardewMods/UncaughtFish ; }
  300. # function svmd() { f ~/.local/share/Steam/steamapps/common/Stardew\ Valley/Mods ; }
  301. # function svm() { mv $1 ~/.local/share/Steam/steamapps/common/Stardew\ Valley/Mods ; }
  302. # # }}}
  303. alias s="cs && shellcheck"
  304. # }}} coding projs #
  305. # school {{{ #
  306. alias pdl="pdflatex"
  307. alias tcl="tex-clean"
  308. # 343
  309. alias ij="sudo ~/Downloads/idea/bin/idea.sh $silent"
  310. alias a2="f ~/Documents/school/343/a2"
  311. alias a2j="f ~/Documents/school/343/a2/java/src"
  312. alias q2="psql -U postgres -d 343-a2 -f q2-test.sql"
  313. alias q2o="psql -U postgres -d 343-a2 -f q2-test.sql -o q2.out"
  314. alias q2a="psql -U postgres -d 343-a2 -f q2.sql"
  315. alias q4="psql -U postgres -d 343-a2 -f q4-test.sql"
  316. alias q4a="psql -U postgres -d 343-a2 -f q4.sql"
  317. # }}} school #