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.5 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
  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. # i3
  98. alias i3b="f ~/i3blocks"
  99. alias pipes="pipes.sh -t 2"
  100. # UltiSnips {{{ #
  101. urnp_dir="~/.vim/plugged/vim-snippets/UltiSnips"
  102. function vsnp() { ni ~/.vim/plugged/vim-snippets/UltiSnips/"$1".snippets ; }
  103. # }}} #
  104. # }}} config files #
  105. # applications {{{ #
  106. silent="> /dev/null 2>&1& "
  107. alias r="ranger"
  108. alias mr="man ranger"
  109. # okular
  110. # function ok() { nohup okular $1 > /dev/null 2>&1& ; }
  111. # zathura
  112. function za() { nohup zathura $1 > /dev/null 2>&1& ; }
  113. # xviewer
  114. function xv() { nohup xviewer $1 > /dev/null 2>&1& ; }
  115. function chr() { google-chrome $1 ; }
  116. function ni() { nvim $1 ; }
  117. function sni() { sudo nvim $1 ; }
  118. # function mrk() { pandoc -o ${1%.*}.html $1 && chr ${1%.*}.html ; }
  119. function mrk() { pandoc -o ${1%.*}.html $1 ; }
  120. function auc() { xdotool click --repeat 1000000 --delay $1 1 ; }
  121. # alias auc1="xdotool click --repeat 1000000 --delay 1 1"
  122. # alias auc3="xdotool click --repeat 1000000 --delay 300 1"
  123. # alias auc5="xdotool click --repeat 1000000 --delay 500 1"
  124. # alias kauc="pkill -f xdotool"
  125. # alias rsl="java -jar ~/Downloads/RuneLite.jar"
  126. alias swex="sudo nohup ~/Downloads/swex.appimage $silent"
  127. alias vbn="cvlc --loop --alsa-gain 1 ~/Music/brown-noise.mp3"
  128. alias rmsw="rm .sw*"
  129. function rs(){ redshift -O $(echo "scale=2;$1*1000" | bc) ; }
  130. # function rds(){ redshift -O $1 ; }
  131. alias rx="redshift -x"
  132. # python related {{{ #
  133. function grpy() { grep $1 *.py ; }
  134. function p3() { python3 $1 ; }
  135. function py() { python $1 ; }
  136. # }}} python related #
  137. # }}} applications #
  138. # git {{{ #
  139. # aliases {{{
  140. alias gstr="git config credential.helper store"
  141. # add {{{ #
  142. alias ga="git add -A . && gs"
  143. alias gac="git add -A . && git commit"
  144. # }}} add #
  145. # diff/log {{{ #
  146. alias gd="git diff -w"
  147. alias gdc="git diff --cached"
  148. alias gds="git diff --stat"
  149. alias gdt="git difftool --tool=vimdiff"
  150. alias gl="git log"
  151. alias gsl="git shortlog"
  152. # }}} diff/log #
  153. # update {{{ #
  154. alias gs="git status -u"
  155. alias gchom="git checkout master"
  156. alias gchnw="git checkout -b wip"
  157. alias gchw="git checkout wip"
  158. alias gheadm1="git reset --hard HEAD~1"
  159. alias glstf="git ls-tree -r HEAD --name-only"
  160. # push {{{ #
  161. alias egc="nvim -c \"set syn=gitcommit\" -c \"set tw=72\" commit-msg.txt"
  162. alias gst="git stash"
  163. alias gstp="git stash pop"
  164. alias gc="git commit"
  165. alias gcam="ga && git commit --amend"
  166. # todo: fix
  167. function gcm(){ echo git commit -m \""$1"\" ; }
  168. function psg() {
  169. git add .
  170. git commit -m '.'
  171. git push
  172. }
  173. alias gps="git push"
  174. alias gpsi="git push --set-upstream origin master"
  175. alias gpsf="git push --force"
  176. alias gclear="git stash clear"
  177. # }}} push #
  178. # pull {{{ #
  179. alias gpl="git pull --rebase"
  180. alias grbc="git rebase --continue"
  181. # }}} pull #
  182. # }}} update #
  183. # edit {{{ #
  184. alias vir="ni README.md"
  185. alias crm="mrk README.md"
  186. # }}} edit #
  187. # aliases }}}
  188. # functions {{{
  189. function gcho() { git checkout $1 ; }
  190. function gchon() { git checkout -b $1 ; }
  191. function gchof() { git checkout $1 $2 ; }
  192. function gcln() { git clone $1 ; }
  193. function gchp() { git cherry-pick $1 ; }
  194. alias gchpc="git cherry-pick --continue"
  195. # add multiple push repos
  196. function gremotes() {
  197. git remote set-url --add --push origin $1
  198. git remote set-url --add --push origin $2
  199. git remote -v
  200. }
  201. # gmrgr: merge repos {{{ #
  202. function gmrgr() {
  203. # 1 = remote name, 2 = remote path
  204. git remote add $1 $2
  205. git fetch $1
  206. # whichever branch you want to merge
  207. git merge --allow-unrelated-histories $1/master
  208. git remote remove $1
  209. }
  210. # }}} merge repos #
  211. # assume file unchanged
  212. function gunc() { git update-index --assume-unchanged $1 ; }
  213. # delete branch locally and on server
  214. function grmb() { git push origin --delete $1 && git branch -D $1 ; }
  215. # functions }}}
  216. # }}} git #
  217. # coding projs {{{ #
  218. coding_dir="~/coding"
  219. alias cdn="$cd_coding_dir"
  220. alias gx="ni ~/Documents/csgo-config/autoexec.cfg"
  221. # trapbot {{{ #
  222. alias tb="$cd_coding_dir/trapbot"
  223. alias vtb="$cd_coding_dir/trapbot && ni scan_reddit.py"
  224. alias ptb="python scan_reddit.py"
  225. alias rtb="$cd_coding_dir/trapbot && python scan_reddit.py"
  226. # }}} trapbot #
  227. # spotify-lib-vis {{{ #
  228. spv_dir="$coding_dir""/spotify-lib-vis"
  229. alias svl="f $spv_dir/src/login"
  230. alias sva="f $spv_dir/src/api"
  231. alias svg="f $spv_dir/src/graphs"
  232. alias svscs="f $spv_dir/src/static/scss"
  233. alias svcss="f $spv_dir/src/spotifyvis/static/scss"
  234. source ~/coding/spotify-lib-vis/src/api-keys.sh
  235. # source "$spv_dir""/src/api-keys.sh"
  236. function ssv() {
  237. source ../bin/activate
  238. python manage.py runserver
  239. }
  240. alias spvdb="psql -d spotifyvis -U django"
  241. function mig() {
  242. python manage.py makemigrations
  243. python manage.py migrate --run-syncdb
  244. ssv
  245. }
  246. alias cldb="python manage.py flush --no-input && ssv"
  247. alias djs="python manage.py shell"
  248. alias upip="pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U"
  249. alias ureq="pip freeze > requirements.txt"
  250. # scan history
  251. alias hlg="cat $spv_dir/src/api/management/commands/update-history.log | tail -n 1"
  252. alias crnl="grep \"(kevin) CMD\" /var/log/syslog | tail -n 1 && hlg"
  253. alias hs="$spv_dir/src/update-history.sh && hlg"
  254. # removes all but newest file
  255. # alias rmol="ls -t | tail -n +2 | xargs rm -- && l"
  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 #
  267. # school {{{ #
  268. # 343
  269. alias ij="sudo ~/Downloads/idea/bin/idea.sh $silent"
  270. alias a2="f ~/Documents/school/343/a2"
  271. alias a2j="f ~/Documents/school/343/a2/java/src"
  272. alias q2="psql -U postgres -d 343-a2 -f q2-test.sql"
  273. alias q2o="psql -U postgres -d 343-a2 -f q2-test.sql -o q2.out"
  274. alias q2a="psql -U postgres -d 343-a2 -f q2.sql"
  275. alias q4="psql -U postgres -d 343-a2 -f q4-test.sql"
  276. alias q4a="psql -U postgres -d 343-a2 -f q4.sql"
  277. # }}} school #