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.

341 lines
8.6 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. HISTFILE=~/.histfile
  3. HISTSIZE=1000
  4. SAVEHIST=1000
  5. setopt appendhistory autocd extendedglob nomatch notify
  6. # vim mode {{{ #
  7. bindkey -v
  8. function zle-line-init zle-keymap-select {
  9. VIM_PROMPT="%{$fg_bold[yellow]%} [% NORMAL]% %{$reset_color%}"
  10. RPS1="${${KEYMAP/vicmd/$VIM_PROMPT}/(main|viins)/} $EPS1"
  11. zle reset-prompt
  12. }
  13. zle -N zle-line-init
  14. zle -N zle-keymap-select
  15. export KEYTIMEOUT=1
  16. # }}} vim mode #
  17. # command line related {{{ #
  18. # search history
  19. bindkey '\e[A' history-beginning-search-backward
  20. bindkey '\e[B' history-beginning-search-forward
  21. function src() { source $1 ; }
  22. alias cs='printf "\033c"'
  23. alias hst="history"
  24. alias nf="neofetch"
  25. alias rur="xrdb ~/.Xresources"
  26. function gvx() { urxvt --help 2>&1 | grep $1 ; }
  27. # list file sizes in megabytes with depth 1
  28. alias dum="sudo du -d 1 -B M"
  29. alias grbm="sudo grub-mkconfig -o /boot/grub/grub.cfg"
  30. # install deb files
  31. function ideb() { sudo dpkg -i $1 ; }
  32. function cld() { colordiff -y --suppress-common-lines $1 $2 ; }
  33. alias grep='grep --color=auto'
  34. # for finding files by name
  35. function rf() { find . -name '$1' ; }
  36. # find text inside files
  37. function rg() { grep -nr $1 * ; }
  38. function cpd() { cp -avr $1 $2 ; }
  39. # extract tar archive
  40. function untar() { tar -xzvf $1 && rm $1; }
  41. function rzip() { unzip $1 && rm $1; }
  42. function lzip() { unzip -l $1 | less; }
  43. function mkex() { chmod 777 $1 ; }
  44. # }}} command line related #
  45. # directory-related {{{ #
  46. alias l='ls -a'
  47. alias ll='ls -alF'
  48. function f() { cd $1 && pwd > ~/.last_dir && ls -a ; }
  49. # restore last dir
  50. if [ -f ~/.last_dir ]
  51. then cd `cat ~/.last_dir`
  52. fi
  53. function rmr() { rm -rf $1 ; }
  54. # todo: fix
  55. # function f.() { f $(printf "%0.s../" $(seq 1 $1 )) ; }
  56. alias "f."="f .."
  57. alias "f.."="f ..."
  58. function mvd() { mv $1 ~/Downloads ; }
  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. # sound
  89. alias vlm="alsamixer -c 0"
  90. alias vlh="alsamixer -c 2"
  91. # apt
  92. function apti() { sudo apt install $1 ; }
  93. function aptr() { sudo apt remove $1 ; }
  94. function pac() { sudo pacman -S $1 ; }
  95. alias aptu="sudo apt upgrade"
  96. # }}} system #
  97. # config files {{{ #
  98. function glc() { grep $1 ~/linux-config/aliases/zsh_aliases ; }
  99. alias lca="f ~/linux-config/aliases"
  100. source ~/.shortcuts
  101. # i3
  102. alias i3b="f ~/i3blocks"
  103. alias pipes="pipes.sh -t 2"
  104. # UltiSnips {{{ #
  105. urnp_dir="~/.vim/plugged/vim-snippets/UltiSnips"
  106. function vsnp() { ni ~/.vim/plugged/vim-snippets/UltiSnips/"$1".snippets ; }
  107. # }}} #
  108. # }}} config files #
  109. # applications {{{ #
  110. silent="> /dev/null 2>&1& "
  111. alias r="ranger"
  112. alias mr="man ranger"
  113. # okular
  114. # function ok() { nohup okular $1 > /dev/null 2>&1& ; }
  115. # zathura
  116. function za() { nohup zathura $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. # function mrk() { pandoc -o ${1%.*}.html $1 && chr ${1%.*}.html ; }
  123. function mrk() { pandoc -o ${1%.*}.html $1 ; }
  124. function auc() { xdotool click --repeat 1000000 --delay $1 1 ; }
  125. # alias auc1="xdotool click --repeat 1000000 --delay 1 1"
  126. # alias auc3="xdotool click --repeat 1000000 --delay 300 1"
  127. # alias auc5="xdotool click --repeat 1000000 --delay 500 1"
  128. # alias kauc="pkill -f xdotool"
  129. # alias rsl="java -jar ~/Downloads/RuneLite.jar"
  130. alias swex="sudo nohup ~/Downloads/swex.appimage $silent"
  131. alias vbn="cvlc --loop --alsa-gain 1 ~/Music/brown-noise.mp3"
  132. alias rmsw="rm .sw*"
  133. function rs(){ redshift -O $(echo "scale=2;$1*1000" | bc) ; }
  134. # function rds(){ 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 gdt="git difftool --tool=vimdiff"
  154. alias gl="git log"
  155. alias gsl="git shortlog"
  156. # }}} diff/log #
  157. # update {{{ #
  158. alias gs="git status -u"
  159. alias gchom="git checkout master"
  160. alias gchnw="git checkout -b wip"
  161. alias gchw="git checkout wip"
  162. alias gheadm1="git reset --hard HEAD~1"
  163. alias glstf="git ls-tree -r HEAD --name-only"
  164. # push {{{ #
  165. alias egc="nvim -c \"set syn=gitcommit\" -c \"set tw=72\" commit-msg.txt"
  166. alias gst="git stash"
  167. alias gstp="git stash pop"
  168. alias gc="git commit"
  169. alias gcam="ga && git commit --amend"
  170. # todo: fix
  171. function gcm(){ echo git commit -m \""$1"\" ; }
  172. function psg() {
  173. git add .
  174. git commit -m '.'
  175. git push
  176. }
  177. alias gps="git push"
  178. alias gpsi="git push --set-upstream origin master"
  179. alias gpsf="git push --force"
  180. alias gclear="git stash clear"
  181. # }}} push #
  182. # pull {{{ #
  183. alias gpl="git pull --rebase"
  184. alias grbc="git rebase --continue"
  185. # }}} pull #
  186. # }}} update #
  187. # edit {{{ #
  188. alias vir="ni README.md"
  189. alias crm="mrk README.md"
  190. # }}} edit #
  191. # aliases }}}
  192. # functions {{{
  193. function gcho() { git checkout $1 ; }
  194. function gchon() { git checkout -b $1 ; }
  195. function gchof() { git checkout $1 $2 ; }
  196. function gcln() { git clone $1 ; }
  197. function gchp() { git cherry-pick $1 ; }
  198. alias gchpc="git cherry-pick --continue"
  199. # add multiple push repos
  200. function gremotes() {
  201. git remote set-url --add --push origin $1
  202. git remote set-url --add --push origin $2
  203. git remote -v
  204. }
  205. # gmrgr: merge repos {{{ #
  206. function gmrgr() {
  207. # 1 = remote name, 2 = remote path
  208. git remote add $1 $2
  209. git fetch $1
  210. # whichever branch you want to merge
  211. git merge --allow-unrelated-histories $1/master
  212. git remote remove $1
  213. }
  214. # }}} merge repos #
  215. # assume file unchanged
  216. function gunc() { git update-index --assume-unchanged $1 ; }
  217. # delete branch locally and on server
  218. function grmb() { git push origin --delete $1 && git branch -D $1 ; }
  219. # functions }}}
  220. # }}} git #
  221. # coding projs {{{ #
  222. coding_dir="~/coding"
  223. alias cdn="$cd_coding_dir"
  224. alias gx="ni ~/Documents/csgo-config/autoexec.cfg"
  225. # trapbot {{{ #
  226. alias tb="$cd_coding_dir/trapbot"
  227. alias vtb="$cd_coding_dir/trapbot && ni scan_reddit.py"
  228. alias ptb="python scan_reddit.py"
  229. alias rtb="$cd_coding_dir/trapbot && python scan_reddit.py"
  230. # }}} trapbot #
  231. # spotify-lib-vis {{{ #
  232. spv_dir="$coding_dir""/spotify-lib-vis"
  233. alias svl="f $spv_dir/src/login"
  234. alias sva="f $spv_dir/src/api"
  235. alias svg="f $spv_dir/src/graphs"
  236. alias svscs="f $spv_dir/src/static/scss"
  237. alias svcss="f $spv_dir/src/spotifyvis/static/scss"
  238. # source ~/coding/spotify-lib-vis/src/api-keys.sh
  239. # source "$spv_dir""/src/api-keys.sh"
  240. function ssv() {
  241. source ../bin/activate
  242. python manage.py runserver
  243. }
  244. alias spvdb="psql -d spotifyvis -U django"
  245. function mig() {
  246. python manage.py makemigrations
  247. python manage.py migrate --run-syncdb
  248. ssv
  249. }
  250. alias cldb="python manage.py flush --no-input && ssv"
  251. alias djs="python manage.py shell"
  252. alias upip="pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U"
  253. alias ureq="pip freeze > requirements.txt"
  254. # scan history
  255. alias hlg="cat $spv_dir/src/api/management/commands/update-history.log | tail -n 1"
  256. alias crnl="grep \"(kevin) CMD\" /var/log/syslog | tail -n 1 && hlg"
  257. alias hs="$spv_dir/src/update-history.sh && hlg"
  258. # removes all but newest file
  259. # alias rmol="ls -t | tail -n +2 | xargs rm -- && l"
  260. # }}} spotify-lib-vis #
  261. # Stardew Valley {{{
  262. sdv_save_dir=~/Documents/sdv-save
  263. alias sdv="f $sdv_save_dir"
  264. alias smp="~/Downloads/sdv/smapi/install\ on\ Linux.sh"
  265. alias imc="sdv && source import-save.sh coop"
  266. function ucf() { f ~/Documents/StardewMods/UncaughtFish ; }
  267. function svmd() { f ~/.local/share/Steam/steamapps/common/Stardew\ Valley/Mods ; }
  268. function svm() { mv $1 ~/.local/share/Steam/steamapps/common/Stardew\ Valley/Mods ; }
  269. # }}}
  270. # }}} coding projs #
  271. # school {{{ #
  272. # 343
  273. alias ij="sudo ~/Downloads/idea/bin/idea.sh $silent"
  274. alias a2="f ~/Documents/school/343/a2"
  275. alias a2j="f ~/Documents/school/343/a2/java/src"
  276. alias q2="psql -U postgres -d 343-a2 -f q2-test.sql"
  277. alias q2o="psql -U postgres -d 343-a2 -f q2-test.sql -o q2.out"
  278. alias q2a="psql -U postgres -d 343-a2 -f q2.sql"
  279. alias q4="psql -U postgres -d 343-a2 -f q4-test.sql"
  280. alias q4a="psql -U postgres -d 343-a2 -f q4.sql"
  281. # }}} school #