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.

337 lines
8.2 KiB

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