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.

352 lines
8.5 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
  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 rfnd() { 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 runzip() { unzip $1 && rm $1; }
  39. function mkex() { chmod 777 $1 ; }
  40. # }}} command line related #
  41. # directory-related {{{ #
  42. alias l='ls -a'
  43. alias ll='ls -alF'
  44. function f() { cd $1 && pwd > ~/.last_dir && ls -a ; }
  45. # restore last dir
  46. if [ -f ~/.last_dir ]
  47. then cd `cat ~/.last_dir`
  48. fi
  49. function rmr() { rm -rf $1 ; }
  50. # todo: fix
  51. # function f.() { f $(printf "%0.s../" $(seq 1 $1 )) ; }
  52. alias "f."="f .."
  53. alias "f.2"="f ..."
  54. alias fd="f ~/Downloads"
  55. function mvd() { mv $1 ~/Downloads ; }
  56. alias fds="f ~/Downloads/sch"
  57. alias doc="f ~/Documents"
  58. alias wo="f ~/Documents/workout-logs/9"
  59. alias cfg="f ~/.config"
  60. # }}} directory-related #
  61. # power options {{{ #
  62. alias s="systemctl suspend"
  63. alias sd="sudo shutdown 0"
  64. alias reb="sudo shutdown -r 0"
  65. alias lo="i3-msg exit"
  66. # }}} power options #
  67. # rotate monitor {{{ #
  68. function rt() {
  69. output="HDMI-0"
  70. if [ "$1" = "s" ]
  71. # if [ "${1:0:1}" = "s" ]
  72. then
  73. output="DVI-I-1"
  74. fi
  75. dir="normal"
  76. if [ "$2" = "r" ]
  77. # if [ "${1:1:2}" = "r" ]
  78. then
  79. dir="right"
  80. fi
  81. if [ "$2" = "l" ]
  82. then
  83. dir="left"
  84. fi
  85. # echo "xrandr --output \"$output\" --rotate \"$dir\""
  86. xrandr --output "$output" --rotate "$dir"
  87. }
  88. # }}} rotate monitor #
  89. # sound
  90. alias vlm="alsamixer -c 0"
  91. alias vlmh="alsamixer -c 3"
  92. # apt
  93. function apti() { sudo apt install $1 ; }
  94. function aptr() { sudo apt remove $1 ; }
  95. # }}} system #
  96. # config files {{{ #
  97. alias lc="f ~/linux-config/"
  98. function glc() { grep $1 ~/linux-config/aliases/zsh_aliases ; }
  99. alias lca="f ~/linux-config/aliases"
  100. alias vv="ni ~/.vimrc"
  101. alias vu="ni ~/.Xresources"
  102. alias vzb="ni ~/.zshrc"
  103. alias vz="ni ~/linux-config/aliases/zsh_aliases"
  104. alias vr="ni ~/.config/ranger/rc.conf"
  105. # i3 {{{ #
  106. alias v3="ni ~/.config/i3/config"
  107. alias v3b="ni ~/.config/i3blocks/i3blocks.conf"
  108. alias i3b="f ~/i3blocks"
  109. alias pipes="pipes.sh -t 2"
  110. alias bg="f ~/Pictures/Backgrounds"
  111. # }}} i3 #
  112. # UltiSnips {{{ #
  113. usnp_dir="~/.vim/plugged/vim-snippets/UltiSnips"
  114. alias snp="f $usnp_dir"
  115. function vsnp() { ni ~/.vim/plugged/vim-snippets/UltiSnips/"$1".snippets ; }
  116. alias tm="ni $usnp_dir/texmath.snippets"
  117. # }}} #
  118. # }}} config files #
  119. # applications {{{ #
  120. alias ran="ranger"
  121. # okular
  122. function ok() { nohup okular $1 > /dev/null 2>&1& ; }
  123. # xviewer
  124. function xv() { nohup xviewer $1 > /dev/null 2>&1& ; }
  125. function chr() { google-chrome $1 ; }
  126. function ni() { nvim $1 ; }
  127. function sni() { sudo nvim $1 ; }
  128. alias nisw="f ~/.local/share/nvim/swap"
  129. # function mrk() { pandoc -o ${1%.*}.html $1 && chr ${1%.*}.html ; }
  130. function mrk() { pandoc -o ${1%.*}.html $1 ; }
  131. function auc() { xdotool click --repeat 1000000 --delay $1 1 ; }
  132. # alias auc1="xdotool click --repeat 1000000 --delay 1 1"
  133. # alias auc3="xdotool click --repeat 1000000 --delay 300 1"
  134. # alias auc5="xdotool click --repeat 1000000 --delay 500 1"
  135. # alias kauc="pkill -f xdotool"
  136. alias rsl="java -jar ~/Downloads/RuneLite.jar"
  137. alias vbn="cvlc --loop --alsa-gain 1 ~/Music/brown-noise.mp3"
  138. alias rmsw="rm .sw*"
  139. # function rs(){ redshift -O $(echo "scale=2;$1*1000" | bc) ; }
  140. function rds(){ redshift -O $1 ; }
  141. alias rx="redshift -x"
  142. # python related {{{ #
  143. function grpy() { grep $1 *.py ; }
  144. function p3() { python3 $1 ; }
  145. function py() { python $1 ; }
  146. # }}} python related #
  147. # }}} applications #
  148. # git {{{ #
  149. # aliases {{{
  150. alias gstr="git config credential.helper store"
  151. # add {{{ #
  152. alias ga="git add -A . && gs"
  153. alias gac="git add -A . && git commit"
  154. # }}} add #
  155. # diff/log {{{ #
  156. alias gd="git diff -w"
  157. alias gdc="git diff --cached"
  158. alias gds="git diff --stat"
  159. alias gdt="git difftool --tool=vimdiff"
  160. alias gl="git log"
  161. alias gsl="git shortlog"
  162. # }}} diff/log #
  163. # update {{{ #
  164. alias gs="git status -u"
  165. alias gchom="git checkout master"
  166. alias gchnw="git checkout -b wip"
  167. alias gchw="git checkout wip"
  168. alias gheadm1="git reset --hard HEAD~1"
  169. alias glstf="git ls-tree -r HEAD --name-only"
  170. # push {{{ #
  171. alias egc="nvim -c \"set syn=gitcommit\" -c \"set tw=72\" commit-msg.txt"
  172. alias gst="git stash"
  173. alias gstp="git stash pop"
  174. alias gc="git commit"
  175. alias gcam="ga && git commit --amend"
  176. # todo: fix
  177. function gcm(){ echo git commit -m \""$1"\" ; }
  178. function psg() {
  179. git add .
  180. git commit -m '.'
  181. git push
  182. }
  183. alias gps="git push"
  184. alias gpsi="git push --set-upstream origin master"
  185. alias gpsf="git push --force"
  186. alias gclear="git stash clear"
  187. # }}} push #
  188. # pull {{{ #
  189. alias gpl="git pull --rebase"
  190. alias grbc="git rebase --continue"
  191. # }}} pull #
  192. # }}} update #
  193. # edit {{{ #
  194. alias vig="ni .gitignore"
  195. alias vir="ni README.md"
  196. alias crm="mrk README.md"
  197. # }}} edit #
  198. # aliases }}}
  199. # functions {{{
  200. function gcho() { git checkout $1 ; }
  201. function gchon() { git checkout -b $1 ; }
  202. function gchof() { git checkout $1 $2 ; }
  203. function gcln() { git clone $1 ; }
  204. function gchp() { git cherry-pick $1 ; }
  205. alias gchpc="git cherry-pick --continue"
  206. # add multiple push repos
  207. function gremotes() {
  208. git remote set-url --add --push origin $1
  209. git remote set-url --add --push origin $2
  210. git remote -v
  211. }
  212. # gmrgr: merge repos {{{ #
  213. function gmrgr() {
  214. # 1 = remote name, 2 = remote path
  215. git remote add $1 $2
  216. git fetch $1
  217. # whichever branch you want to merge
  218. git merge --allow-unrelated-histories $1/master
  219. git remote remove $1
  220. }
  221. # }}} merge repos #
  222. # assume file unchanged
  223. function gunc() { git update-index --assume-unchanged $1 ; }
  224. # delete branch locally and on server
  225. function grmb() { git push origin --delete $1 && git branch -D $1 ; }
  226. # functions }}}
  227. # }}} git #
  228. # coding projs {{{ #
  229. coding_dir="~/coding"
  230. cd_coding_dir="f $coding_dir"
  231. alias cdn="$cd_coding_dir"
  232. alias ans="f /usr/local/android-studio/bin && ./studio.sh"
  233. alias gx="ni ~/Documents/csgo-config/autoexec.cfg"
  234. alias jnd="f ~/Documents/journal"
  235. alias jn="ni ~/Documents/journal/todo/9.md"
  236. alias jnt="ni ~/Documents/journal/todo/todo.md"
  237. alias rs="f ~/Documents/runescape"
  238. # ideas {{{ #
  239. # ideas_dir="$coding_dir""/ideas"
  240. # alias ids="f $ideas_dir"
  241. # alias lci="f $ideas_dir/general"
  242. # alias vli="ni $ideas_dir/general/ideas.md"
  243. # alias fyn="f $ideas_dir/yes-no"
  244. # }}} ideas #
  245. # trapbot {{{ #
  246. alias tb="$cd_coding_dir/trapbot"
  247. alias vtb="$cd_coding_dir/trapbot && ni scan_reddit.py"
  248. alias ptb="python scan_reddit.py"
  249. alias rtb="$cd_coding_dir/trapbot && python scan_reddit.py"
  250. # }}} trapbot #
  251. # spotify-lib-vis {{{ #
  252. spv_dir="$coding_dir""/spotify-lib-vis"
  253. alias sv="f $spv_dir/src"
  254. alias svl="f $spv_dir/src/login"
  255. alias sva="f $spv_dir/src/api"
  256. alias svg="f $spv_dir/src/graphs"
  257. alias ft="f templates"
  258. function ssv() {
  259. source api-keys.sh
  260. source ../bin/activate
  261. python manage.py runserver
  262. }
  263. alias spvdb="psql -d spotifyvis -U django"
  264. function mig() {
  265. python manage.py makemigrations
  266. python manage.py migrate --run-syncdb
  267. ssv
  268. }
  269. alias cldb="python manage.py flush --no-input"
  270. alias djs="python manage.py shell"
  271. # }}} spotify-lib-vis #
  272. # Stardew Valley {{{
  273. sdv_save_dir=~/Documents/sdv-save
  274. alias sdv="f $sdv_save_dir"
  275. alias smp="~/Downloads/sdv/smapi/install\ on\ Linux.sh"
  276. alias imc="sdv && source import-save.sh coop"
  277. function ucf() { f ~/Documents/StardewMods/UncaughtFish ; }
  278. function svmd() { f ~/.local/share/Steam/steamapps/common/Stardew\ Valley/Mods ; }
  279. function svm() { mv $1 ~/.local/share/Steam/steamapps/common/Stardew\ Valley/Mods ; }
  280. # }}}
  281. # }}} coding projs #
  282. # school {{{ #
  283. alias sch="f ~/Documents/school"
  284. alias sta="f ~/Documents/school/sta"
  285. # 236
  286. alias 236="f ~/Documents/school/236"
  287. alias a1="f ~/Documents/school/latex-notes/236/a1"
  288. # }}} school #