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.

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