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.

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