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.

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