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.

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