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.

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