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.

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