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.

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