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