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.

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