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.

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