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.

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