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.

378 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. 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. function gremotes() {
  206. git remote set-url --add --push origin $1
  207. git remote set-url --add --push origin $2
  208. }
  209. # gmrgr: 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. function gunc() { git update-index --assume-unchanged $1 ; }
  220. # pull all {{{ #
  221. function gpla() {
  222. cmds="lc snp 9r sch"
  223. for cmd in $cmds; do
  224. eval $cmd && gst && gpl && gstp && gclear
  225. done
  226. }
  227. # }}} pull all #
  228. # functions }}}
  229. # }}} git #
  230. # coding projs {{{ #
  231. cd_coding_dir="f ~/Documents/coding"
  232. alias ans="f /usr/local/android-studio/bin && ./studio.sh"
  233. alias cdn="$cd_coding_dir"
  234. alias tb="$cd_coding_dir/trapbot"
  235. alias vtb="$cd_coding_dir/trapbot && ni scan_reddit.py"
  236. alias ptb="python scan_reddit.py"
  237. alias rtb="$cd_coding_dir/trapbot && python scan_reddit.py"
  238. # }}} coding projs #
  239. # school {{{ #
  240. in_lab=false
  241. cd_school="f ~/Documents/School/notes"
  242. # general {{{
  243. alias sch="$cd_school"
  244. alias 236="$cd_school/236"
  245. alias rml="rm *.aux *.log *.pdf"
  246. # LaTeX {{{ #
  247. function pdl() { pdflatex $1 ; }
  248. function cptp() {
  249. cp *template.tex cp-template.tex
  250. chmod 600 cp-template.tex
  251. date=`date +%-m-%d`
  252. mv cp-template.tex "$date".tex
  253. }
  254. # }}} LaTeX #
  255. # }}}
  256. # 136 {{{
  257. alias clc="gcalccmd"
  258. alias mt="ok ~/Documents/School/calc-textbook.pdf"
  259. alias 136="$cd_school/136"
  260. alias 136l="$cd_school/136/lecture"
  261. alias pr3="$cd_school/136/par/3"
  262. # }}}
  263. # 209 {{{
  264. # dirs {{{
  265. cd_209="f ~/Documents/School/209";
  266. alias 209="$cd_209"
  267. alias 9r="$cd_209/mokkar"
  268. alias l7="$cd_209/mokkar/lab7"
  269. alias 9a="$cd_209/mokkar/a3"
  270. # }}}
  271. alias ll="ls -la"
  272. alias cdf="echo \". ./.bashrc\"&& ssh mokkar@cdf.utoronto.ca"
  273. function mkex() { chmod 777 $1 ; }
  274. # {{{ Compilation Functions
  275. # compile without running
  276. function c9() { gcc -Wall -std=gnu99 -g -o "${1%.*}.out" "$1" -lm ; }
  277. # compile all without running {{{ #
  278. function c9a() {
  279. for file in *; do
  280. if [[ $file = *.c ]]; then
  281. gcc -Wall -std=gnu99 -g -o "${file%.*}".out "$file"
  282. fi
  283. done
  284. }
  285. # }}} compile all without running #
  286. # compile and run
  287. function c9r() { c9 $1 && ./"${1%.*}.out" ; }
  288. # compile and run with input
  289. function c9i() { c9 $1 && ./"${1%.*}.out" < $2 ; }
  290. # compile and run with input file {{{ #
  291. function run() {
  292. while read line; do
  293. # ./$1.out $line
  294. echo ./$1.out $line
  295. done < $1.in
  296. }
  297. # }}} compile and run with input file #
  298. # temp {{{ #
  299. alias m7="make childcreates && ./childcreates 3"
  300. alias m3="make pfact && ./pfact 10"
  301. alias 35w="c9 3-5_wait.c && ./3-5_wait.out abc a"
  302. # }}} temp #
  303. # }}}
  304. # }}}
  305. alias 36a="$cd_school/236/a1"
  306. alias 6t="ok ~/Documents/School/236-textbook.pdf"
  307. # }}} school #