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.

383 lines
9.8 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  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. # search history
  16. bindkey '\e[A' history-beginning-search-backward
  17. bindkey '\e[B' history-beginning-search-forward
  18. function src() { source $1 ; }
  19. alias cs='printf "\033c"'
  20. alias hst="history"
  21. alias nf="neofetch"
  22. alias rur="xrdb ~/.Xresources"
  23. function gvx() { urxvt --help 2>&1 | grep $1 ; }
  24. # list file sizes in megabytes with depth 1
  25. alias dum="sudo du -d 1 -B M"
  26. alias grbm="sudo grub-mkconfig -o /boot/grub/grub.cfg"
  27. # install deb files
  28. function ideb() { sudo dpkg -i $1 ; }
  29. function cld() { colordiff -y --suppress-common-lines $1 $2 ; }
  30. alias grep='grep --color=auto'
  31. # for finding files by name
  32. function rf() { find . -name '$1' ; }
  33. # find text inside files
  34. function rg() { grep -nr $1 * ; }
  35. function cpd() { cp -avr $1 $2 ; }
  36. # extract tar archive
  37. function untar() { tar -xzvf $1 && rm $1; }
  38. function rzip() { unzip $1 && rm $1; }
  39. function lzip() { unzip -l $1 | less; }
  40. function mkex() { chmod 777 $1 ; }
  41. # }}} command line related #
  42. # directory-related {{{ #
  43. alias l='ls -a'
  44. alias ll='ls -alF'
  45. function f() { cd $1 && pwd > ~/.last_dir && ls -a ; }
  46. # restore last dir
  47. if [ -f ~/.last_dir ]
  48. then cd `cat ~/.last_dir`
  49. fi
  50. function rmr() { rm -rf $1 ; }
  51. # todo: fix
  52. # function f.() { f $(printf "%0.s../" $(seq 1 $1 )) ; }
  53. alias "f."="f .."
  54. alias "f.."="f ..."
  55. alias fd="f ~/Downloads"
  56. function mvd() { mv $1 ~/Downloads ; }
  57. alias fds="f ~/Downloads/sch"
  58. alias doc="f ~/Documents"
  59. alias wo="f ~/Documents/workout-logs/11"
  60. alias cfg="f ~/.config"
  61. # }}} directory-related #
  62. # power options {{{ #
  63. alias s="systemctl suspend"
  64. alias sd="sudo shutdown 0"
  65. alias reb="sudo shutdown -r 0"
  66. alias lo="i3-msg exit"
  67. # }}} power options #
  68. # rotate monitor {{{ #
  69. function rt() {
  70. output="HDMI-0"
  71. if [ "$1" = "s" ]
  72. # if [ "${1:0:1}" = "s" ]
  73. then
  74. output="DVI-I-1"
  75. fi
  76. dir="normal"
  77. if [ "$2" = "r" ]
  78. # if [ "${1:1:2}" = "r" ]
  79. then
  80. dir="right"
  81. fi
  82. if [ "$2" = "l" ]
  83. then
  84. dir="left"
  85. fi
  86. # echo "xrandr --output \"$output\" --rotate \"$dir\""
  87. xrandr --output "$output" --rotate "$dir"
  88. }
  89. # }}} rotate monitor #
  90. # sound
  91. alias vlm="alsamixer -c 0"
  92. alias vlh="alsamixer -c 2"
  93. # apt
  94. function apti() { sudo apt install $1 ; }
  95. function aptr() { sudo apt remove $1 ; }
  96. alias aptu="sudo apt upgrade"
  97. # }}} system #
  98. # config files {{{ #
  99. alias lc="f ~/linux-config/"
  100. function glc() { grep $1 ~/linux-config/aliases/zsh_aliases ; }
  101. alias lca="f ~/linux-config/aliases"
  102. alias vv="ni ~/.vimrc"
  103. alias vu="ni ~/.Xresources"
  104. alias vzb="ni ~/.zshrc"
  105. alias vz="ni ~/linux-config/aliases/zsh_aliases"
  106. alias vr="ni ~/.config/ranger/rc.conf"
  107. # i3 {{{ #
  108. alias v3="ni ~/.config/i3/config"
  109. alias v3b="ni ~/.config/i3blocks/i3blocks.conf"
  110. alias i3b="f ~/i3blocks"
  111. alias pipes="pipes.sh -t 2"
  112. alias bg="f ~/Pictures/Backgrounds"
  113. # }}} i3 #
  114. # UltiSnips {{{ #
  115. usnp_dir="~/.vim/plugged/vim-snippets/UltiSnips"
  116. alias snp="f $usnp_dir"
  117. function vsnp() { ni ~/.vim/plugged/vim-snippets/UltiSnips/"$1".snippets ; }
  118. alias tm="ni $usnp_dir/texmath.snippets"
  119. # }}} #
  120. # }}} config files #
  121. # applications {{{ #
  122. silent="> /dev/null 2>&1& "
  123. alias ran="ranger"
  124. # okular
  125. function ok() { nohup okular $1 > /dev/null 2>&1& ; }
  126. # xviewer
  127. function xv() { nohup xviewer $1 > /dev/null 2>&1& ; }
  128. function chr() { google-chrome $1 ; }
  129. function ni() { nvim $1 ; }
  130. function sni() { sudo nvim $1 ; }
  131. alias nisw="f ~/.local/share/nvim/swap"
  132. # function mrk() { pandoc -o ${1%.*}.html $1 && chr ${1%.*}.html ; }
  133. function mrk() { pandoc -o ${1%.*}.html $1 ; }
  134. function auc() { xdotool click --repeat 1000000 --delay $1 1 ; }
  135. # alias auc1="xdotool click --repeat 1000000 --delay 1 1"
  136. # alias auc3="xdotool click --repeat 1000000 --delay 300 1"
  137. # alias auc5="xdotool click --repeat 1000000 --delay 500 1"
  138. # alias kauc="pkill -f xdotool"
  139. # alias rsl="java -jar ~/Downloads/RuneLite.jar"
  140. alias swex="sudo nohup ~/Downloads/swex.appimage $silent"
  141. alias vbn="cvlc --loop --alsa-gain 1 ~/Music/brown-noise.mp3"
  142. alias rmsw="rm .sw*"
  143. function rs(){ redshift -O $(echo "scale=2;$1*1000" | bc) ; }
  144. # function rds(){ redshift -O $1 ; }
  145. alias rx="redshift -x"
  146. # python related {{{ #
  147. function grpy() { grep $1 *.py ; }
  148. function p3() { python3 $1 ; }
  149. function py() { python $1 ; }
  150. # }}} python related #
  151. # }}} applications #
  152. # git {{{ #
  153. # aliases {{{
  154. alias gstr="git config credential.helper store"
  155. # add {{{ #
  156. alias ga="git add -A . && gs"
  157. alias gac="git add -A . && git commit"
  158. # }}} add #
  159. # diff/log {{{ #
  160. alias gd="git diff -w"
  161. alias gdc="git diff --cached"
  162. alias gds="git diff --stat"
  163. alias gdt="git difftool --tool=vimdiff"
  164. alias gl="git log"
  165. alias gsl="git shortlog"
  166. # }}} diff/log #
  167. # update {{{ #
  168. alias gs="git status -u"
  169. alias gchom="git checkout master"
  170. alias gchnw="git checkout -b wip"
  171. alias gchw="git checkout wip"
  172. alias gheadm1="git reset --hard HEAD~1"
  173. alias glstf="git ls-tree -r HEAD --name-only"
  174. # push {{{ #
  175. alias egc="nvim -c \"set syn=gitcommit\" -c \"set tw=72\" commit-msg.txt"
  176. alias gst="git stash"
  177. alias gstp="git stash pop"
  178. alias gc="git commit"
  179. alias gcam="ga && git commit --amend"
  180. # todo: fix
  181. function gcm(){ echo git commit -m \""$1"\" ; }
  182. function psg() {
  183. git add .
  184. git commit -m '.'
  185. git push
  186. }
  187. alias gps="git push"
  188. alias gpsi="git push --set-upstream origin master"
  189. alias gpsf="git push --force"
  190. alias gclear="git stash clear"
  191. # }}} push #
  192. # pull {{{ #
  193. alias gpl="git pull --rebase"
  194. alias grbc="git rebase --continue"
  195. # }}} pull #
  196. # }}} update #
  197. # edit {{{ #
  198. alias vig="ni .gitignore"
  199. alias vir="ni README.md"
  200. alias crm="mrk README.md"
  201. # }}} edit #
  202. # aliases }}}
  203. # functions {{{
  204. function gcho() { git checkout $1 ; }
  205. function gchon() { git checkout -b $1 ; }
  206. function gchof() { git checkout $1 $2 ; }
  207. function gcln() { git clone $1 ; }
  208. function gchp() { git cherry-pick $1 ; }
  209. alias gchpc="git cherry-pick --continue"
  210. # add multiple push repos
  211. function gremotes() {
  212. git remote set-url --add --push origin $1
  213. git remote set-url --add --push origin $2
  214. git remote -v
  215. }
  216. # gmrgr: merge repos {{{ #
  217. function gmrgr() {
  218. # 1 = remote name, 2 = remote path
  219. git remote add $1 $2
  220. git fetch $1
  221. # whichever branch you want to merge
  222. git merge --allow-unrelated-histories $1/master
  223. git remote remove $1
  224. }
  225. # }}} merge repos #
  226. # assume file unchanged
  227. function gunc() { git update-index --assume-unchanged $1 ; }
  228. # delete branch locally and on server
  229. function grmb() { git push origin --delete $1 && git branch -D $1 ; }
  230. # functions }}}
  231. # }}} git #
  232. # coding projs {{{ #
  233. coding_dir="~/coding"
  234. cd_coding_dir="f $coding_dir"
  235. alias cdn="$cd_coding_dir"
  236. alias ans="f /usr/local/android-studio/bin && ./studio.sh"
  237. alias gx="ni ~/Documents/csgo-config/autoexec.cfg"
  238. alias jnd="f ~/Documents/journal"
  239. alias jn="ni ~/Documents/journal/todo/11.md"
  240. alias jnt="ni ~/Documents/journal/todo/todo.md"
  241. # alias rs="f ~/Documents/runescape"
  242. # ideas {{{ #
  243. # ideas_dir="$coding_dir""/ideas"
  244. # alias ids="f $ideas_dir"
  245. # alias lci="f $ideas_dir/general"
  246. # alias vli="ni $ideas_dir/general/ideas.md"
  247. # alias fyn="f $ideas_dir/yes-no"
  248. # }}} ideas #
  249. # trapbot {{{ #
  250. alias tb="$cd_coding_dir/trapbot"
  251. alias vtb="$cd_coding_dir/trapbot && ni scan_reddit.py"
  252. alias ptb="python scan_reddit.py"
  253. alias rtb="$cd_coding_dir/trapbot && python scan_reddit.py"
  254. # }}} trapbot #
  255. # spotify-lib-vis {{{ #
  256. spv_dir="$coding_dir""/spotify-lib-vis"
  257. alias sv="f $spv_dir/src"
  258. alias svl="f $spv_dir/src/login"
  259. alias sva="f $spv_dir/src/api"
  260. alias svg="f $spv_dir/src/graphs"
  261. alias svscs="f $spv_dir/src/static/scss"
  262. alias svcss="f $spv_dir/src/spotifyvis/static/scss"
  263. source ~/coding/spotify-lib-vis/src/api-keys.sh
  264. # source "$spv_dir""/src/api-keys.sh"
  265. function ssv() {
  266. source ../bin/activate
  267. python manage.py runserver
  268. }
  269. alias spvdb="psql -d spotifyvis -U django"
  270. function mig() {
  271. python manage.py makemigrations
  272. python manage.py migrate --run-syncdb
  273. ssv
  274. }
  275. alias cldb="python manage.py flush --no-input && ssv"
  276. alias djs="python manage.py shell"
  277. alias upip="pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U"
  278. alias ureq="pip freeze > requirements.txt"
  279. # scan history
  280. alias slh="f ~/Music/spotify-history"
  281. alias hlg="cat $spv_dir/src/api/management/commands/update-history.log | tail -n 1"
  282. alias hlgf="ni $spv_dir/src/api/management/commands/update-history.log"
  283. alias crnl="grep \"(kevin) CMD\" /var/log/syslog | tail -n 1 && hlg"
  284. alias hs="$spv_dir/src/update-history.sh && hlg"
  285. # removes all but newest file
  286. # alias rmol="ls -t | tail -n +2 | xargs rm -- && l"
  287. # }}} spotify-lib-vis #
  288. # Stardew Valley {{{
  289. sdv_save_dir=~/Documents/sdv-save
  290. alias sdv="f $sdv_save_dir"
  291. alias smp="~/Downloads/sdv/smapi/install\ on\ Linux.sh"
  292. alias imc="sdv && source import-save.sh coop"
  293. function ucf() { f ~/Documents/StardewMods/UncaughtFish ; }
  294. function svmd() { f ~/.local/share/Steam/steamapps/common/Stardew\ Valley/Mods ; }
  295. function svm() { mv $1 ~/.local/share/Steam/steamapps/common/Stardew\ Valley/Mods ; }
  296. # }}}
  297. # }}} coding projs #
  298. # school {{{ #
  299. alias sch="f ~/Documents/school"
  300. alias sta="f ~/Documents/school/sta"
  301. # 236
  302. alias 236="f ~/Documents/school/236"
  303. alias a3="f ~/Documents/school/latex-notes/236/a3"
  304. # 343
  305. alias 343="f ~/Documents/school/343"
  306. # alias a1="f ~/Documents/school/latex-notes/343/a1"
  307. alias ij="sudo ~/Downloads/idea/bin/idea.sh $silent"
  308. alias a2="f ~/Documents/school/343/a2"
  309. alias a2j="f ~/Documents/school/343/a2/java/src"
  310. alias q2="psql -U postgres -d 343-a2 -f q2-test.sql"
  311. alias q2o="psql -U postgres -d 343-a2 -f q2-test.sql -o q2.out"
  312. alias q2a="psql -U postgres -d 343-a2 -f q2.sql"
  313. alias q4="psql -U postgres -d 343-a2 -f q4-test.sql"
  314. alias q4a="psql -U postgres -d 343-a2 -f q4.sql"
  315. # }}} school #