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.

396 lines
9.0 KiB

  1. # system {{{ #
  2. setopt extendedglob
  3. # vim mode {{{ #
  4. bindkey -v
  5. function zle-line-init zle-keymap-select {
  6. VIM_PROMPT="%{$fg_bold[yellow]%} [% NORMAL]% %{$reset_color%}"
  7. RPS1="${${KEYMAP/vicmd/$VIM_PROMPT}/(main|viins)/} $EPS1"
  8. zle reset-prompt
  9. }
  10. zle -N zle-line-init
  11. zle -N zle-keymap-select
  12. export KEYTIMEOUT=1
  13. # }}} vim mode #
  14. # directory-related {{{ #
  15. alias l='ls -a'
  16. alias ll='ls -alF'
  17. function f() { cd $1 && pwd > ~/.last_dir && ls -a ; }
  18. # restore last dir
  19. if [ -f ~/.last_dir ]
  20. then cd `cat ~/.last_dir`
  21. fi
  22. # todo: fix
  23. # function f.() { f $(printf "%0.s../" $(seq 1 $1 )) ; }
  24. alias "f."="f .."
  25. alias "f.2"="f ..."
  26. alias dd="f ~/Downloads"
  27. alias doc="f ~/Documents"
  28. alias cfg="f ~/.config"
  29. # }}} directory-related #
  30. # command line related {{{ #
  31. alias cs='printf "\033c"'
  32. alias hst="history"
  33. alias nf="neofetch"
  34. alias rur="xrdb ~/.Xresources"
  35. function gvx() { urxvt --help 2>&1 | grep $1 ; }
  36. function cld() { colordiff -y --suppress-common-lines $1 $2 ; }
  37. alias grep='grep --color=auto'
  38. function rfnd() { find . -name "$1" ; }
  39. function rgrp() { grep -r $1 * ; }
  40. function cpd() { cp -avr $1 $2 ; }
  41. # }}} command line related #
  42. # power options {{{ #
  43. alias s="systemctl suspend"
  44. alias sd="sudo shutdown 0"
  45. alias reb="sudo shutdown -r 0"
  46. alias lo="i3-msg exit"
  47. # }}} power options #
  48. function apti() { sudo apt install $1 ; }
  49. function aptr() { sudo apt remove $1 ; }
  50. # }}} system #
  51. # config files {{{ #
  52. alias lc="f ~/linux-config/"
  53. alias lca="f ~/linux-config/aliases"
  54. alias vv="ni ~/.vimrc"
  55. alias vu="ni ~/.Xresources"
  56. alias vzb="ni ~/.zshrc"
  57. alias vz="ni ~/linux-config/aliases/zsh_aliases"
  58. alias vr="ni ~/.config/ranger/rc.conf"
  59. # i3 {{{ #
  60. alias v3="ni ~/.config/i3/config"
  61. alias v3b="ni ~/.config/i3blocks/i3blocks.conf"
  62. alias i3b="f /usr/share/i3blocks"
  63. alias pipes="pipes.sh -t 2"
  64. alias bgs="nemo ~/Pictures/Backgrounds"
  65. # }}} i3 #
  66. # UltiSnips {{{ #
  67. usnp_dir="~/.vim/plugged/vim-snippets/UltiSnips"
  68. alias snp="f $usnp_dir"
  69. function vsnp() { ni ~/.vim/plugged/vim-snippets/UltiSnips/"$1".snippets ; }
  70. alias tm="ni $usnp_dir/texmath.snippets"
  71. # }}} #
  72. # }}} config files #
  73. # applications {{{ #
  74. alias rg="ranger"
  75. function ok() { okular $1 ; }
  76. function chr() { google-chrome $1 ; }
  77. function ni() { nvim $1 ; }
  78. # function mrk() { pandoc -o ${1%.*}.html $1 && chr ${1%.*}.html ; }
  79. function mrk() { pandoc -o ${1%.*}.html $1 ; }
  80. alias vbn="cvlc --loop --alsa-gain 1 ~/Downloads/brown-noise.mp3"
  81. alias vlm="alsamixer -c 1"
  82. alias rmsw="rm .sw*"
  83. function rs(){ redshift -O $(echo "scale=2;$1*1000" | bc) ; }
  84. alias rx="redshift -x"
  85. # python related {{{ #
  86. function grpy() { grep $1 *.py ; }
  87. function p3() { python3 $1 ; }
  88. function py() { python $1 ; }
  89. # }}} python related #
  90. # }}} applications #
  91. # device specific {{{ #
  92. # NZXT {{{
  93. if [ "$(hostname)" = "NZXT" ]; then
  94. # rotate monitor {{{ #
  95. function rt() {
  96. output="HDMI-0"
  97. if [ "$1" = "s" ]
  98. # if [ "${1:0:1}" = "s" ]
  99. then
  100. output="DVI-I-1"
  101. fi
  102. dir="normal"
  103. if [ "$2" = "r" ]
  104. # if [ "${1:1:2}" = "r" ]
  105. then
  106. dir="right"
  107. fi
  108. if [ "$2" = "l" ]
  109. then
  110. dir="left"
  111. fi
  112. # echo "xrandr --output \"$output\" --rotate \"$dir\""
  113. xrandr --output "$output" --rotate "$dir"
  114. }
  115. # }}} rotate monitor #
  116. # audio {{{ #
  117. # was for transferring sink inputs between DAC and speakers but not
  118. # necessary if not using
  119. alias alsi="pactl list short sink-inputs"
  120. alias als="pactl list short sinks"
  121. function amsih() { pactl move-sink-input $1 0 ; }
  122. function amsis() { pactl move-sink-input $1 1 ; }
  123. # }}} audio #
  124. # apps {{{ #
  125. alias nem="nemo ."
  126. alias spt="speedtest"
  127. alias pg="ping -c 5 google.ca"
  128. alias w7="VBoxManage startvm W7 --type headless"
  129. # }}} apps #
  130. # various coding projs {{{ #
  131. alias sfa="f ~/Documents/self-authoring"
  132. alias rcg="$cd_coding_dir/random-color-generator"
  133. alias dcr="$cd_coding_dir/dcr-logger"
  134. alias pf="$cd_coding_dir/ParsaFood"
  135. # swbot {{{ #
  136. alias sb="$cd_coding_dir/swbot"
  137. # alias psb="p3 create_skills_dict.py"
  138. # alias psbo="p3 create_skills_dict.py > output.py"
  139. alias psb="p3 create_monster_dict.py"
  140. alias psbo="p3 create_monster_dict.py > output.py"
  141. # }}} swbot #
  142. # resume {{{ #
  143. alias cv="f ~/Documents/resume/examples"
  144. alias cvf="f ~/Documents/resume/examples/cv"
  145. alias vcv="ni ~/Documents/resume/examples/cv.tex"
  146. alias okcv="ok ~/Documents/resume/examples/cv.pdf"
  147. # https://stackoverflow.com/a/6605085/8811872
  148. function pdftojpg() {
  149. convert \
  150. -verbose \
  151. -density 150 \
  152. -trim \
  153. $1.pdf \
  154. -quality 100 \
  155. -flatten \
  156. -sharpen 0x1.0 \
  157. $1.jpg
  158. }
  159. # }}} resume #
  160. # }}} various coding projs #
  161. fi
  162. # NZXT }}}
  163. # laptop {{{
  164. if [[ "$(hostname)" = "X1-Carbon" ]]; then
  165. # key swaps {{{ #
  166. xmodmap -e "keycode 9 = Escape"
  167. xmodmap -e "keycode 22 = Home"
  168. xmodmap -e "keycode 119 = End"
  169. xmodmap -e "keycode 110 = Delete"
  170. xmodmap -e "keycode 115 = BackSpace"
  171. # }}} key swaps #
  172. alias gbl="xbacklight -get"
  173. function sbl() { xbacklight -set $(echo "scale=2;$1*10" | bc) ; }
  174. alias thn="thunar ."
  175. alias plz="f ~/platterz2018/ocr-reader/app/src/main/java/com/google/android/gms/samples/vision/ocrreader"
  176. alias ans="f /usr/local/android-studio/bin/"
  177. fi
  178. # laptop }}}
  179. # }}} device specific #
  180. # git {{{ #
  181. # aliases {{{
  182. alias gstore="git config credential.helper store"
  183. # add {{{ #
  184. alias ga="git add -A . && gs"
  185. alias gac="git add -A . && git commit"
  186. # }}} add #
  187. # diff/log {{{ #
  188. alias gd="git diff -w"
  189. alias gdc="git diff --cached"
  190. alias gl="git log"
  191. alias gsl="git shortlog"
  192. # }}} diff/log #
  193. # update {{{ #
  194. alias gs="git status -u"
  195. alias gchm="git checkout master"
  196. alias gchnw="git checkout -b wip"
  197. alias gchw="git checkout wip"
  198. # push {{{ #
  199. alias egc="nvim -c \"set syn=gitcommit\" -c \"set tw=72\" commit-msg.txt"
  200. alias gst="git stash"
  201. alias gstp="git stash pop"
  202. alias gc="git commit"
  203. # todo: fix
  204. function gcm(){ echo git commit -m \""$1"\" ; }
  205. alias gps="git push"
  206. alias gdwip="git push -d origin wip && git branch -d wip"
  207. alias gclear="git stash clear"
  208. # }}} push #
  209. # pull {{{ #
  210. alias gpl="git pull --rebase"
  211. alias grbc="git rebase --continue"
  212. # }}} pull #
  213. # }}} update #
  214. # edit {{{ #
  215. alias vig="ni .gitignore"
  216. alias vir="ni README.md"
  217. alias crm="mrk README.md"
  218. # }}} edit #
  219. # aliases }}}
  220. # functions {{{
  221. function gcho() { git checkout $1 ; }
  222. function gcln() { git clone $1 ; }
  223. function gremotes() {
  224. git remote set-url --add --push origin $1
  225. git remote set-url --add --push origin $2
  226. }
  227. # gmrgr: merge repos {{{ #
  228. function gmrgr() {
  229. # 1 = remote name, 2 = remote path
  230. git remote add $1 $2
  231. git fetch $1
  232. # whichever branch you want to merge
  233. git merge --allow-unrelated-histories $1/master
  234. git remote remove $1
  235. }
  236. # }}} merge repos #
  237. function gunc() { git update-index --assume-unchanged $1 ; }
  238. # pull all {{{ #
  239. function gpla() {
  240. cmds="lc snp 9r sch"
  241. for cmd in $cmds; do
  242. eval $cmd && gst && gpl && gstp && gclear
  243. done
  244. }
  245. # }}} pull all #
  246. # functions }}}
  247. # }}} git #
  248. # coding projs {{{ #
  249. cd_coding_dir="f ~/Documents/coding"
  250. alias ans="f /usr/local/android-studio/bin && ./studio.sh"
  251. alias cdn="$cd_coding_dir"
  252. alias tb="$cd_coding_dir/trapbot"
  253. alias vtb="$cd_coding_dir/trapbot && ni scan_reddit.py"
  254. alias ptb="python scan_reddit.py"
  255. alias rtb="$cd_coding_dir/trapbot && python scan_reddit.py"
  256. # }}} coding projs #
  257. # school {{{ #
  258. in_lab=false
  259. cd_school="f ~/Documents/School/notes"
  260. # general {{{
  261. alias sch="$cd_school"
  262. alias 236="$cd_school/236"
  263. alias rml="rm *.aux *.log *.pdf"
  264. # LaTeX {{{ #
  265. function pdl() { pdflatex $1 ; }
  266. function cptp() {
  267. cp *template.tex cp-template.tex
  268. chmod 600 cp-template.tex
  269. date=`date +%-m-%d`
  270. mv cp-template.tex "$date".tex
  271. }
  272. # }}} LaTeX #
  273. # }}}
  274. # 136 {{{
  275. alias clc="gcalccmd"
  276. alias mt="ok ~/Documents/School/calc-textbook.pdf"
  277. alias 136="$cd_school/136"
  278. alias 136l="$cd_school/136/lecture"
  279. alias pr3="$cd_school/136/par/3"
  280. # }}}
  281. # 209 {{{
  282. # dirs {{{
  283. cd_209="f ~/Documents/School/209";
  284. alias 209="$cd_209"
  285. alias 9r="$cd_209/mokkar"
  286. alias l7="$cd_209/mokkar/lab7"
  287. alias 9a="$cd_209/mokkar/a3"
  288. # }}}
  289. alias ll="ls -la"
  290. alias cdf="echo \". ./.bashrc\"&& ssh mokkar@cdf.utoronto.ca"
  291. function mkex() { chmod 777 $1 ; }
  292. # {{{ Compilation Functions
  293. # compile without running
  294. function c9() { gcc -Wall -std=gnu99 -g -o "${1%.*}.out" "$1" -lm ; }
  295. # compile all without running {{{ #
  296. function c9a() {
  297. for file in *; do
  298. if [[ $file = *.c ]]; then
  299. gcc -Wall -std=gnu99 -g -o "${file%.*}".out "$file"
  300. fi
  301. done
  302. }
  303. # }}} compile all without running #
  304. # compile and run
  305. function c9r() { c9 $1 && ./"${1%.*}.out" ; }
  306. # compile and run with input
  307. function c9i() { c9 $1 && ./"${1%.*}.out" < $2 ; }
  308. # compile and run with input file {{{ #
  309. function run() {
  310. while read line; do
  311. # ./$1.out $line
  312. echo ./$1.out $line
  313. done < $1.in
  314. }
  315. # }}} compile and run with input file #
  316. # temp {{{ #
  317. alias m7="make childcreates && ./childcreates 3"
  318. alias m3="make pfact && ./pfact 10"
  319. alias 35w="c9 3-5_wait.c && ./3-5_wait.out abc a"
  320. # }}} temp #
  321. # }}}
  322. # }}}
  323. alias 36a="$cd_school/236/a1"
  324. alias 6t="ok ~/Documents/School/236-textbook.pdf"
  325. # }}} school #