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.

351 lines
9.0 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
  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. function mvd() { mv $1 ~/Downloads ; }
  56. # }}} directory-related #
  57. # power options {{{ #
  58. alias s="systemctl suspend"
  59. alias sd="sudo shutdown 0"
  60. alias reb="sudo shutdown -r 0"
  61. alias lo="i3-msg exit"
  62. # }}} power options #
  63. # rotate monitor {{{ #
  64. function rt() {
  65. output="HDMI-0"
  66. if [ "$1" = "s" ]
  67. # if [ "${1:0:1}" = "s" ]
  68. then
  69. output="DVI-I-1"
  70. fi
  71. dir="normal"
  72. if [ "$2" = "r" ]
  73. # if [ "${1:1:2}" = "r" ]
  74. then
  75. dir="right"
  76. fi
  77. if [ "$2" = "l" ]
  78. then
  79. dir="left"
  80. fi
  81. # echo "xrandr --output \"$output\" --rotate \"$dir\""
  82. xrandr --output "$output" --rotate "$dir"
  83. }
  84. # }}} rotate monitor #
  85. # sound
  86. alias vlm="alsamixer -c 0"
  87. alias vlh="alsamixer -c 2"
  88. # apt
  89. function apti() { sudo apt install $1 ; }
  90. function aptr() { sudo apt remove $1 ; }
  91. alias aptu="sudo apt upgrade"
  92. # }}} system #
  93. # config files {{{ #
  94. function glc() { grep $1 ~/linux-config/aliases/zsh_aliases ; }
  95. alias lca="f ~/linux-config/aliases"
  96. source ~/.shortcuts
  97. alias vv="ni ~/.vimrc"
  98. alias vu="ni ~/.Xresources"
  99. alias vzb="ni ~/.zshrc"
  100. alias vz="ni ~/linux-config/aliases/zsh_aliases"
  101. alias vr="ni ~/.config/ranger/rc.conf"
  102. # i3 {{{ #
  103. alias v3="ni ~/.config/i3/config"
  104. alias v3b="ni ~/.config/i3blocks/i3blocks.conf"
  105. alias i3b="f ~/i3blocks"
  106. alias pipes="pipes.sh -t 2"
  107. # }}} i3 #
  108. # UltiSnips {{{ #
  109. usnp_dir="~/.vim/plugged/vim-snippets/UltiSnips"
  110. function vsnp() { ni ~/.vim/plugged/vim-snippets/UltiSnips/"$1".snippets ; }
  111. alias tm="ni $usnp_dir/texmath.snippets"
  112. # }}} #
  113. # }}} config files #
  114. # applications {{{ #
  115. silent="> /dev/null 2>&1& "
  116. alias rn="ranger"
  117. # okular
  118. # function ok() { nohup okular $1 > /dev/null 2>&1& ; }
  119. # zathura
  120. function za() { nohup zathura $1 > /dev/null 2>&1& ; }
  121. # xviewer
  122. function xv() { nohup xviewer $1 > /dev/null 2>&1& ; }
  123. function chr() { google-chrome $1 ; }
  124. function ni() { nvim $1 ; }
  125. function sni() { sudo nvim $1 ; }
  126. # function mrk() { pandoc -o ${1%.*}.html $1 && chr ${1%.*}.html ; }
  127. function mrk() { pandoc -o ${1%.*}.html $1 ; }
  128. function auc() { xdotool click --repeat 1000000 --delay $1 1 ; }
  129. # alias auc1="xdotool click --repeat 1000000 --delay 1 1"
  130. # alias auc3="xdotool click --repeat 1000000 --delay 300 1"
  131. # alias auc5="xdotool click --repeat 1000000 --delay 500 1"
  132. # alias kauc="pkill -f xdotool"
  133. # alias rsl="java -jar ~/Downloads/RuneLite.jar"
  134. alias swex="sudo nohup ~/Downloads/swex.appimage $silent"
  135. alias vbn="cvlc --loop --alsa-gain 1 ~/Music/brown-noise.mp3"
  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. alias cdn="$cd_coding_dir"
  229. alias gx="ni ~/Documents/csgo-config/autoexec.cfg"
  230. alias jn="ni ~/Documents/journal/todo/11.md"
  231. alias jnt="ni ~/Documents/journal/todo/todo.md"
  232. # trapbot {{{ #
  233. alias tb="$cd_coding_dir/trapbot"
  234. alias vtb="$cd_coding_dir/trapbot && ni scan_reddit.py"
  235. alias ptb="python scan_reddit.py"
  236. alias rtb="$cd_coding_dir/trapbot && python scan_reddit.py"
  237. # }}} trapbot #
  238. # spotify-lib-vis {{{ #
  239. spv_dir="$coding_dir""/spotify-lib-vis"
  240. alias svl="f $spv_dir/src/login"
  241. alias sva="f $spv_dir/src/api"
  242. alias svg="f $spv_dir/src/graphs"
  243. alias svscs="f $spv_dir/src/static/scss"
  244. alias svcss="f $spv_dir/src/spotifyvis/static/scss"
  245. source ~/coding/spotify-lib-vis/src/api-keys.sh
  246. # source "$spv_dir""/src/api-keys.sh"
  247. function ssv() {
  248. source ../bin/activate
  249. python manage.py runserver
  250. }
  251. alias spvdb="psql -d spotifyvis -U django"
  252. function mig() {
  253. python manage.py makemigrations
  254. python manage.py migrate --run-syncdb
  255. ssv
  256. }
  257. alias cldb="python manage.py flush --no-input && ssv"
  258. alias djs="python manage.py shell"
  259. alias upip="pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U"
  260. alias ureq="pip freeze > requirements.txt"
  261. # scan history
  262. alias hlg="cat $spv_dir/src/api/management/commands/update-history.log | tail -n 1"
  263. alias hlgf="ni $spv_dir/src/api/management/commands/update-history.log"
  264. alias crnl="grep \"(kevin) CMD\" /var/log/syslog | tail -n 1 && hlg"
  265. alias hs="$spv_dir/src/update-history.sh && hlg"
  266. # removes all but newest file
  267. # alias rmol="ls -t | tail -n +2 | xargs rm -- && l"
  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 #
  279. # school {{{ #
  280. # 343
  281. alias ij="sudo ~/Downloads/idea/bin/idea.sh $silent"
  282. alias a2="f ~/Documents/school/343/a2"
  283. alias a2j="f ~/Documents/school/343/a2/java/src"
  284. alias q2="psql -U postgres -d 343-a2 -f q2-test.sql"
  285. alias q2o="psql -U postgres -d 343-a2 -f q2-test.sql -o q2.out"
  286. alias q2a="psql -U postgres -d 343-a2 -f q2.sql"
  287. alias q4="psql -U postgres -d 343-a2 -f q4-test.sql"
  288. alias q4a="psql -U postgres -d 343-a2 -f q4.sql"
  289. # }}} school #