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. 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="ni ~/.vimrc"
  52. alias vu="ni ~/.Xresources"
  53. alias vzb="ni ~/.zshrc"
  54. alias vz="ni ~/linux-config/aliases/zsh_aliases"
  55. # i3 {{{ #
  56. alias v3="ni ~/.config/i3/config"
  57. alias v3b="ni ~/.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() { ni ~/.vim/plugged/vim-snippets/UltiSnips/"$1".snippets ; }
  66. alias tm="ni $usnp_dir/texmath.snippets"
  67. # }}} #
  68. # }}} config files #
  69. # applications {{{ #
  70. function ok() { okular $1 ; }
  71. function chr() { google-chrome $1 ; }
  72. function ni() { nvim $1 ; }
  73. function mrk() { pandoc -o ${1%.*}.html $1 && chr ${1%.*}.html ; }
  74. alias vbn="cvlc --loop --alsa-gain 1 ~/Downloads/brown-noise.mp3"
  75. alias vlm="alsamixer -c 1"
  76. alias rmsw="rm .sw*"
  77. function rs(){ redshift -O $(echo "scale=2;$1*1000" | bc) ; }
  78. alias rx="redshift -x"
  79. # python related {{{ #
  80. function grpy() { grep $1 *.py ; }
  81. function p3() { python3 $1 ; }
  82. function py() { python $1 ; }
  83. # }}} python related #
  84. # }}} applications #
  85. # device specific {{{ #
  86. # NZXT {{{
  87. if [ "$(hostname)" = "NZXT" ]; then
  88. # rotate monitor {{{ #
  89. function rt() {
  90. output="HDMI-0"
  91. if [ "$1" = "s" ]
  92. # if [ "${1:0:1}" = "s" ]
  93. then
  94. output="DVI-I-1"
  95. fi
  96. dir="normal"
  97. if [ "$2" = "r" ]
  98. # if [ "${1:1:2}" = "r" ]
  99. then
  100. dir="right"
  101. fi
  102. if [ "$2" = "l" ]
  103. then
  104. dir="left"
  105. fi
  106. # echo "xrandr --output \"$output\" --rotate \"$dir\""
  107. xrandr --output "$output" --rotate "$dir"
  108. }
  109. # }}} rotate monitor #
  110. # audio {{{ #
  111. # was for transferring sink inputs between DAC and speakers but not
  112. # necessary if not using
  113. alias alsi="pactl list short sink-inputs"
  114. alias als="pactl list short sinks"
  115. function amsih() { pactl move-sink-input $1 0 ; }
  116. function amsis() { pactl move-sink-input $1 1 ; }
  117. # }}} audio #
  118. # apps {{{ #
  119. alias nem="nemo ."
  120. alias spt="speedtest"
  121. alias pg="ping -c 5 google.ca"
  122. alias w7="VBoxManage startvm W7 --type headless"
  123. function gvx() { urxvt --help 2>&1 | grep $1 ; }
  124. alias rur="xrdb ~/.Xresources"
  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 #