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.

386 lines
9.9 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. source ~/.shortcuts
  103. alias vv="ni ~/.vimrc"
  104. alias vu="ni ~/.Xresources"
  105. alias vzb="ni ~/.zshrc"
  106. alias vz="ni ~/linux-config/aliases/zsh_aliases"
  107. alias vr="ni ~/.config/ranger/rc.conf"
  108. # i3 {{{ #
  109. alias v3="ni ~/.config/i3/config"
  110. alias v3b="ni ~/.config/i3blocks/i3blocks.conf"
  111. alias i3b="f ~/i3blocks"
  112. alias pipes="pipes.sh -t 2"
  113. alias bg="f ~/Pictures/Backgrounds"
  114. # }}} i3 #
  115. # UltiSnips {{{ #
  116. usnp_dir="~/.vim/plugged/vim-snippets/UltiSnips"
  117. alias snp="f $usnp_dir"
  118. function vsnp() { ni ~/.vim/plugged/vim-snippets/UltiSnips/"$1".snippets ; }
  119. alias tm="ni $usnp_dir/texmath.snippets"
  120. # }}} #
  121. # }}} config files #
  122. # applications {{{ #
  123. silent="> /dev/null 2>&1& "
  124. alias ran="ranger"
  125. # okular
  126. # function ok() { nohup okular $1 > /dev/null 2>&1& ; }
  127. # zathura
  128. function za() { nohup zathura $1 > /dev/null 2>&1& ; }
  129. # xviewer
  130. function xv() { nohup xviewer $1 > /dev/null 2>&1& ; }
  131. function chr() { google-chrome $1 ; }
  132. function ni() { nvim $1 ; }
  133. function sni() { sudo nvim $1 ; }
  134. alias nisw="f ~/.local/share/nvim/swap"
  135. # function mrk() { pandoc -o ${1%.*}.html $1 && chr ${1%.*}.html ; }
  136. function mrk() { pandoc -o ${1%.*}.html $1 ; }
  137. function auc() { xdotool click --repeat 1000000 --delay $1 1 ; }
  138. # alias auc1="xdotool click --repeat 1000000 --delay 1 1"
  139. # alias auc3="xdotool click --repeat 1000000 --delay 300 1"
  140. # alias auc5="xdotool click --repeat 1000000 --delay 500 1"
  141. # alias kauc="pkill -f xdotool"
  142. # alias rsl="java -jar ~/Downloads/RuneLite.jar"
  143. alias swex="sudo nohup ~/Downloads/swex.appimage $silent"
  144. alias vbn="cvlc --loop --alsa-gain 1 ~/Music/brown-noise.mp3"
  145. alias rmsw="rm .sw*"
  146. function rs(){ redshift -O $(echo "scale=2;$1*1000" | bc) ; }
  147. # function rds(){ redshift -O $1 ; }
  148. alias rx="redshift -x"
  149. # python related {{{ #
  150. function grpy() { grep $1 *.py ; }
  151. function p3() { python3 $1 ; }
  152. function py() { python $1 ; }
  153. # }}} python related #
  154. # }}} applications #
  155. # git {{{ #
  156. # aliases {{{
  157. alias gstr="git config credential.helper store"
  158. # add {{{ #
  159. alias ga="git add -A . && gs"
  160. alias gac="git add -A . && git commit"
  161. # }}} add #
  162. # diff/log {{{ #
  163. alias gd="git diff -w"
  164. alias gdc="git diff --cached"
  165. alias gds="git diff --stat"
  166. alias gdt="git difftool --tool=vimdiff"
  167. alias gl="git log"
  168. alias gsl="git shortlog"
  169. # }}} diff/log #
  170. # update {{{ #
  171. alias gs="git status -u"
  172. alias gchom="git checkout master"
  173. alias gchnw="git checkout -b wip"
  174. alias gchw="git checkout wip"
  175. alias gheadm1="git reset --hard HEAD~1"
  176. alias glstf="git ls-tree -r HEAD --name-only"
  177. # push {{{ #
  178. alias egc="nvim -c \"set syn=gitcommit\" -c \"set tw=72\" commit-msg.txt"
  179. alias gst="git stash"
  180. alias gstp="git stash pop"
  181. alias gc="git commit"
  182. alias gcam="ga && git commit --amend"
  183. # todo: fix
  184. function gcm(){ echo git commit -m \""$1"\" ; }
  185. function psg() {
  186. git add .
  187. git commit -m '.'
  188. git push
  189. }
  190. alias gps="git push"
  191. alias gpsi="git push --set-upstream origin master"
  192. alias gpsf="git push --force"
  193. alias gclear="git stash clear"
  194. # }}} push #
  195. # pull {{{ #
  196. alias gpl="git pull --rebase"
  197. alias grbc="git rebase --continue"
  198. # }}} pull #
  199. # }}} update #
  200. # edit {{{ #
  201. alias vig="ni .gitignore"
  202. alias vir="ni README.md"
  203. alias crm="mrk README.md"
  204. # }}} edit #
  205. # aliases }}}
  206. # functions {{{
  207. function gcho() { git checkout $1 ; }
  208. function gchon() { git checkout -b $1 ; }
  209. function gchof() { git checkout $1 $2 ; }
  210. function gcln() { git clone $1 ; }
  211. function gchp() { git cherry-pick $1 ; }
  212. alias gchpc="git cherry-pick --continue"
  213. # add multiple push repos
  214. function gremotes() {
  215. git remote set-url --add --push origin $1
  216. git remote set-url --add --push origin $2
  217. git remote -v
  218. }
  219. # gmrgr: merge repos {{{ #
  220. function gmrgr() {
  221. # 1 = remote name, 2 = remote path
  222. git remote add $1 $2
  223. git fetch $1
  224. # whichever branch you want to merge
  225. git merge --allow-unrelated-histories $1/master
  226. git remote remove $1
  227. }
  228. # }}} merge repos #
  229. # assume file unchanged
  230. function gunc() { git update-index --assume-unchanged $1 ; }
  231. # delete branch locally and on server
  232. function grmb() { git push origin --delete $1 && git branch -D $1 ; }
  233. # functions }}}
  234. # }}} git #
  235. # coding projs {{{ #
  236. coding_dir="~/coding"
  237. cd_coding_dir="f $coding_dir"
  238. alias cdn="$cd_coding_dir"
  239. alias ans="f /usr/local/android-studio/bin && ./studio.sh"
  240. alias gx="ni ~/Documents/csgo-config/autoexec.cfg"
  241. alias jnd="f ~/Documents/journal"
  242. alias jn="ni ~/Documents/journal/todo/11.md"
  243. alias jnt="ni ~/Documents/journal/todo/todo.md"
  244. # alias rs="f ~/Documents/runescape"
  245. # ideas {{{ #
  246. # ideas_dir="$coding_dir""/ideas"
  247. # alias ids="f $ideas_dir"
  248. # alias lci="f $ideas_dir/general"
  249. # alias vli="ni $ideas_dir/general/ideas.md"
  250. # alias fyn="f $ideas_dir/yes-no"
  251. # }}} ideas #
  252. # trapbot {{{ #
  253. alias tb="$cd_coding_dir/trapbot"
  254. alias vtb="$cd_coding_dir/trapbot && ni scan_reddit.py"
  255. alias ptb="python scan_reddit.py"
  256. alias rtb="$cd_coding_dir/trapbot && python scan_reddit.py"
  257. # }}} trapbot #
  258. # spotify-lib-vis {{{ #
  259. spv_dir="$coding_dir""/spotify-lib-vis"
  260. alias sv="f $spv_dir/src"
  261. alias svl="f $spv_dir/src/login"
  262. alias sva="f $spv_dir/src/api"
  263. alias svg="f $spv_dir/src/graphs"
  264. alias svscs="f $spv_dir/src/static/scss"
  265. alias svcss="f $spv_dir/src/spotifyvis/static/scss"
  266. source ~/coding/spotify-lib-vis/src/api-keys.sh
  267. # source "$spv_dir""/src/api-keys.sh"
  268. function ssv() {
  269. source ../bin/activate
  270. python manage.py runserver
  271. }
  272. alias spvdb="psql -d spotifyvis -U django"
  273. function mig() {
  274. python manage.py makemigrations
  275. python manage.py migrate --run-syncdb
  276. ssv
  277. }
  278. alias cldb="python manage.py flush --no-input && ssv"
  279. alias djs="python manage.py shell"
  280. alias upip="pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U"
  281. alias ureq="pip freeze > requirements.txt"
  282. # scan history
  283. alias slh="f ~/Music/spotify-history"
  284. alias hlg="cat $spv_dir/src/api/management/commands/update-history.log | tail -n 1"
  285. alias hlgf="ni $spv_dir/src/api/management/commands/update-history.log"
  286. alias crnl="grep \"(kevin) CMD\" /var/log/syslog | tail -n 1 && hlg"
  287. alias hs="$spv_dir/src/update-history.sh && hlg"
  288. # removes all but newest file
  289. # alias rmol="ls -t | tail -n +2 | xargs rm -- && l"
  290. # }}} spotify-lib-vis #
  291. # Stardew Valley {{{
  292. sdv_save_dir=~/Documents/sdv-save
  293. alias sdv="f $sdv_save_dir"
  294. alias smp="~/Downloads/sdv/smapi/install\ on\ Linux.sh"
  295. alias imc="sdv && source import-save.sh coop"
  296. function ucf() { f ~/Documents/StardewMods/UncaughtFish ; }
  297. function svmd() { f ~/.local/share/Steam/steamapps/common/Stardew\ Valley/Mods ; }
  298. function svm() { mv $1 ~/.local/share/Steam/steamapps/common/Stardew\ Valley/Mods ; }
  299. # }}}
  300. # }}} coding projs #
  301. # school {{{ #
  302. alias sch="f ~/Documents/school"
  303. alias sta="f ~/Documents/school/sta"
  304. # 236
  305. alias 236="f ~/Documents/school/236"
  306. alias a3="f ~/Documents/school/latex-notes/236/a3"
  307. # 343
  308. alias 343="f ~/Documents/school/343"
  309. # alias a1="f ~/Documents/school/latex-notes/343/a1"
  310. alias ij="sudo ~/Downloads/idea/bin/idea.sh $silent"
  311. alias a2="f ~/Documents/school/343/a2"
  312. alias a2j="f ~/Documents/school/343/a2/java/src"
  313. alias q2="psql -U postgres -d 343-a2 -f q2-test.sql"
  314. alias q2o="psql -U postgres -d 343-a2 -f q2-test.sql -o q2.out"
  315. alias q2a="psql -U postgres -d 343-a2 -f q2.sql"
  316. alias q4="psql -U postgres -d 343-a2 -f q4-test.sql"
  317. alias q4a="psql -U postgres -d 343-a2 -f q4.sql"
  318. # }}} school #