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.

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