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.

333 lines
8.0 KiB

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