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.

384 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. alias vbn="cvlc --loop --alsa-gain 1 ~/Downloads/brown-noise.mp3"
  79. alias vlm="alsamixer -c 1"
  80. alias rmsw="rm .sw*"
  81. function rs(){ redshift -O $(echo "scale=2;$1*1000" | bc) ; }
  82. alias rx="redshift -x"
  83. # python related {{{ #
  84. function grpy() { grep $1 *.py ; }
  85. function p3() { python3 $1 ; }
  86. function py() { python $1 ; }
  87. # }}} python related #
  88. # }}} applications #
  89. # device specific {{{ #
  90. # NZXT {{{
  91. if [ "$(hostname)" = "NZXT" ]; then
  92. # rotate monitor {{{ #
  93. function rt() {
  94. output="HDMI-0"
  95. if [ "$1" = "s" ]
  96. # if [ "${1:0:1}" = "s" ]
  97. then
  98. output="DVI-I-1"
  99. fi
  100. dir="normal"
  101. if [ "$2" = "r" ]
  102. # if [ "${1:1:2}" = "r" ]
  103. then
  104. dir="right"
  105. fi
  106. if [ "$2" = "l" ]
  107. then
  108. dir="left"
  109. fi
  110. # echo "xrandr --output \"$output\" --rotate \"$dir\""
  111. xrandr --output "$output" --rotate "$dir"
  112. }
  113. # }}} rotate monitor #
  114. # audio {{{ #
  115. # was for transferring sink inputs between DAC and speakers but not
  116. # necessary if not using
  117. alias alsi="pactl list short sink-inputs"
  118. alias als="pactl list short sinks"
  119. function amsih() { pactl move-sink-input $1 0 ; }
  120. function amsis() { pactl move-sink-input $1 1 ; }
  121. # }}} audio #
  122. # apps {{{ #
  123. alias nem="nemo ."
  124. alias spt="speedtest"
  125. alias pg="ping -c 5 google.ca"
  126. alias w7="VBoxManage startvm W7 --type headless"
  127. # }}} apps #
  128. # various coding projs {{{ #
  129. alias sfa="f ~/Documents/self-authoring"
  130. alias rcg="$cd_coding_dir/random-color-generator"
  131. alias dcr="$cd_coding_dir/dcr-logger"
  132. alias pf="$cd_coding_dir/ParsaFood"
  133. # swbot {{{ #
  134. alias sb="$cd_coding_dir/swbot"
  135. # alias psb="p3 create_skills_dict.py"
  136. # alias psbo="p3 create_skills_dict.py > output.py"
  137. alias psb="p3 create_monster_dict.py"
  138. alias psbo="p3 create_monster_dict.py > output.py"
  139. # }}} swbot #
  140. # resume {{{ #
  141. alias cv="f ~/Documents/resume/examples"
  142. alias cvf="f ~/Documents/resume/examples/cv"
  143. alias vcv="ni ~/Documents/resume/examples/cv.tex"
  144. alias okcv="ok ~/Documents/resume/examples/cv.pdf"
  145. # }}} resume #
  146. # }}} various coding projs #
  147. fi
  148. # NZXT }}}
  149. # laptop {{{
  150. if [[ "$(hostname)" = "X1-Carbon" ]]; then
  151. # key swaps {{{ #
  152. xmodmap -e "keycode 9 = Escape"
  153. xmodmap -e "keycode 22 = Home"
  154. xmodmap -e "keycode 119 = End"
  155. xmodmap -e "keycode 110 = Delete"
  156. xmodmap -e "keycode 115 = BackSpace"
  157. # }}} key swaps #
  158. alias gbl="xbacklight -get"
  159. function sbl() { xbacklight -set $(echo "scale=2;$1*10" | bc) ; }
  160. alias thn="thunar ."
  161. alias plz="f ~/platterz2018/ocr-reader/app/src/main/java/com/google/android/gms/samples/vision/ocrreader"
  162. alias ans="f /usr/local/android-studio/bin/"
  163. fi
  164. # laptop }}}
  165. # }}} device specific #
  166. # git {{{ #
  167. # aliases {{{
  168. alias gstore="git config credential.helper store"
  169. # add {{{ #
  170. alias ga="git add -A . && gs"
  171. alias gac="git add -A . && git commit"
  172. # }}} add #
  173. # diff/log {{{ #
  174. alias gd="git diff -w"
  175. alias gdc="git diff --cached"
  176. alias gl="git log"
  177. alias gsl="git shortlog"
  178. # }}} diff/log #
  179. # update {{{ #
  180. alias gs="git status -u"
  181. alias gchom="git checkout master"
  182. # push {{{ #
  183. alias egc="nvim -c \"set syn=gitcommit\" -c \"set tw=72\" commit-msg.txt"
  184. alias gst="git stash"
  185. alias gstp="git stash pop"
  186. alias gc="git commit"
  187. function gcm(){ git commit -m "$1" ; }
  188. alias gps="git push"
  189. alias gclear="git stash clear"
  190. # }}} push #
  191. # pull {{{ #
  192. alias gpl="git pull --rebase"
  193. alias grbc="git rebase --continue"
  194. # }}} pull #
  195. # }}} update #
  196. # edit {{{ #
  197. alias vig="ni .gitignore"
  198. alias vir="ni README.md"
  199. alias crm="mrk README.md"
  200. # }}} edit #
  201. # aliases }}}
  202. # functions {{{
  203. function gcho() { git checkout $1 ; }
  204. function gcln() { git clone $1 ; }
  205. # assume file is changed
  206. function gunc() { git update-index --assume-unchanged $1 ; }
  207. # only take certain commit from branch
  208. function gchp() { git cherry-pick $1 ; }
  209. # merge repos {{{ #
  210. function gmrgr() {
  211. # 1 = remote name, 2 = remote path
  212. git remote add $1 $2
  213. git fetch $1
  214. # whichever branch you want to merge
  215. git merge --allow-unrelated-histories $1/master
  216. git remote remove $1
  217. }
  218. # }}} merge repos #
  219. # add multiple remotes {{{ #
  220. function gremotes() {
  221. git remote set-url --add --push origin $1
  222. git remote set-url --add --push origin $2
  223. }
  224. # }}} add multiple remotes #
  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 #