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.

346 lines
8.7 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
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. alias mkpk="makepkg -sri"
  44. function mkex() { chmod 777 $1 ; }
  45. # }}} command line related #
  46. # directory-related {{{ #
  47. alias l='ls -a'
  48. alias ll='ls -alFh'
  49. function f() { cd $1 && pwd > ~/.last_dir && ls -a ; }
  50. # restore last dir
  51. if [ -f ~/.last_dir ]
  52. then cd `cat ~/.last_dir`
  53. fi
  54. function rmr() { rm -rf $1 ; }
  55. # todo: fix
  56. # function f.() { f $(printf "%0.s../" $(seq 1 $1 )) ; }
  57. alias "f."="f .."
  58. alias "f.."="f ..."
  59. function mvd() { mv $1 ~/Downloads ; }
  60. alias lhd="sudo fdisk -l"
  61. # }}} directory-related #
  62. # power options {{{ #
  63. alias s="systemctl suspend"
  64. alias sd="sudo shutdown 0"
  65. alias reb="sudo shutdown -r 0"
  66. alias lo="i3-msg exit"
  67. # }}} power options #
  68. # rotate monitor {{{ #
  69. function rt() {
  70. output="HDMI-0"
  71. if [ "$1" = "s" ]
  72. # if [ "${1:0:1}" = "s" ]
  73. then
  74. output="DVI-I-1"
  75. fi
  76. dir="normal"
  77. if [ "$2" = "r" ]
  78. # if [ "${1:1:2}" = "r" ]
  79. then
  80. dir="right"
  81. fi
  82. if [ "$2" = "l" ]
  83. then
  84. dir="left"
  85. fi
  86. # echo "xrandr --output \"$output\" --rotate \"$dir\""
  87. xrandr --output "$output" --rotate "$dir"
  88. }
  89. # }}} rotate monitor #
  90. # sound
  91. alias vlm="alsamixer -c 0"
  92. alias vlh="alsamixer -c 2"
  93. # apt
  94. function apti() { sudo apt install $1 ; }
  95. function aptr() { sudo apt remove $1 ; }
  96. function pac() { sudo pacman -S $1 ; }
  97. function pcr() { sudo pacman -Rs $1 ; }
  98. alias aptu="sudo apt upgrade"
  99. # }}} system #
  100. # config files {{{ #
  101. function glc() { grep $1 ~/linux-config/aliases/zsh_aliases ; }
  102. alias lca="f ~/linux-config/aliases"
  103. source ~/.shortcuts
  104. # i3
  105. alias i3b="f ~/i3blocks"
  106. alias pipes="pipes.sh -t 2"
  107. # UltiSnips {{{ #
  108. urnp_dir="~/.vim/plugged/vim-snippets/UltiSnips"
  109. function vsnp() { ni ~/.vim/plugged/vim-snippets/UltiSnips/"$1".snippets ; }
  110. # }}} #
  111. # }}} config files #
  112. # applications {{{ #
  113. silent="> /dev/null 2>&1& "
  114. alias rg="ranger"
  115. alias mr="man ranger"
  116. # okular
  117. # function ok() { nohup okular $1 > /dev/null 2>&1& ; }
  118. # zathura
  119. function za() { nohup zathura $1 > /dev/null 2>&1& ; }
  120. # xviewer
  121. function xv() { nohup xviewer $1 > /dev/null 2>&1& ; }
  122. function chr() { google-chrome $1 ; }
  123. function ni() { nvim $1 ; }
  124. function sni() { sudo nvim $1 ; }
  125. # function mrk() { pandoc -o ${1%.*}.html $1 && chr ${1%.*}.html ; }
  126. function mrk() { pandoc -o ${1%.*}.html $1 ; }
  127. function auc() { xdotool click --repeat 1000000 --delay $1 1 ; }
  128. # alias auc1="xdotool click --repeat 1000000 --delay 1 1"
  129. # alias auc3="xdotool click --repeat 1000000 --delay 300 1"
  130. # alias auc5="xdotool click --repeat 1000000 --delay 500 1"
  131. # alias kauc="pkill -f xdotool"
  132. # alias rsl="java -jar ~/Downloads/RuneLite.jar"
  133. alias swex="sudo nohup ~/Downloads/swex.appimage $silent"
  134. alias h="htop"
  135. alias vbn="cvlc --loop --alsa-gain 1 ~/Music/brown-noise.mp3"
  136. alias rmsw="rm .sw*"
  137. function rs(){ redshift -O $(echo "scale=2;$1*1000" | bc) ; }
  138. # function rds(){ redshift -O $1 ; }
  139. alias rx="redshift -x"
  140. # python related {{{ #
  141. function grpy() { grep $1 *.py ; }
  142. function p3() { python3 $1 ; }
  143. function py() { python $1 ; }
  144. # }}} python related #
  145. # }}} applications #
  146. # git {{{ #
  147. # aliases {{{
  148. alias gstr="git config credential.helper store"
  149. # add {{{ #
  150. alias ga="git add -A . && gs"
  151. alias gac="git add -A . && git commit"
  152. # }}} add #
  153. # diff/log {{{ #
  154. alias gd="git diff -w"
  155. alias gdc="git diff --cached"
  156. alias gds="git diff --stat"
  157. alias gdt="git difftool --tool=vimdiff"
  158. alias gl="git log"
  159. alias gsl="git shortlog"
  160. # }}} diff/log #
  161. # update {{{ #
  162. alias gs="git status -u"
  163. alias gchom="git checkout master"
  164. alias gchnw="git checkout -b wip"
  165. alias gchw="git checkout wip"
  166. alias gheadm1="git reset --hard HEAD~1"
  167. alias glstf="git ls-tree -r HEAD --name-only"
  168. # push {{{ #
  169. alias egc="nvim -c \"set syn=gitcommit\" -c \"set tw=72\" commit-msg.txt"
  170. alias gst="git stash"
  171. alias gstp="git stash pop"
  172. alias gc="git commit"
  173. alias gcam="ga && git commit --amend"
  174. # todo: fix
  175. function gcm(){ echo git commit -m \""$1"\" ; }
  176. function psg() {
  177. git add .
  178. git commit -m '.'
  179. git push
  180. }
  181. alias gps="git push"
  182. alias gpsi="git push --set-upstream origin master"
  183. alias gpsf="git push --force"
  184. alias gclear="git stash clear"
  185. # }}} push #
  186. # pull {{{ #
  187. alias gpl="git pull --rebase"
  188. alias grbc="git rebase --continue"
  189. # }}} pull #
  190. # }}} update #
  191. # edit {{{ #
  192. alias vir="ni README.md"
  193. alias crm="mrk README.md"
  194. # }}} edit #
  195. # aliases }}}
  196. # functions {{{
  197. function gcho() { git checkout $1 ; }
  198. function gchon() { git checkout -b $1 ; }
  199. function gchof() { git checkout $1 $2 ; }
  200. function gcln() { git clone $1 ; }
  201. function gchp() { git cherry-pick $1 ; }
  202. alias gchpc="git cherry-pick --continue"
  203. # add multiple push repos
  204. function gremotes() {
  205. git remote set-url --add --push origin $1
  206. git remote set-url --add --push origin $2
  207. git remote -v
  208. }
  209. # gmrgr: merge repos {{{ #
  210. function gmrgr() {
  211. # 1 = remote name, 2 = remote path
  212. git remote add $1 $2
  213. git fetch $1
  214. # whichever branch you want to merge
  215. git merge --allow-unrelated-histories $1/master
  216. git remote remove $1
  217. }
  218. # }}} merge repos #
  219. # assume file unchanged
  220. function gunc() { git update-index --assume-unchanged $1 ; }
  221. # delete branch locally and on server
  222. function grmb() { git push origin --delete $1 && git branch -D $1 ; }
  223. # functions }}}
  224. # }}} git #
  225. # coding projs {{{ #
  226. coding_dir="~/coding"
  227. alias cdn="$cd_coding_dir"
  228. alias gx="ni ~/Documents/csgo-config/autoexec.cfg"
  229. # trapbot {{{ #
  230. alias tb="$cd_coding_dir/trapbot"
  231. alias vtb="$cd_coding_dir/trapbot && ni scan_reddit.py"
  232. alias ptb="python scan_reddit.py"
  233. alias rtb="$cd_coding_dir/trapbot && python scan_reddit.py"
  234. # }}} trapbot #
  235. # spotify-lib-vis {{{ #
  236. spv_dir="$coding_dir""/spotify-lib-vis"
  237. alias svl="f $spv_dir/src/login"
  238. alias sva="f $spv_dir/src/api"
  239. alias svg="f $spv_dir/src/graphs"
  240. alias svscs="f $spv_dir/src/static/scss"
  241. alias svcss="f $spv_dir/src/spotifyvis/static/scss"
  242. # source ~/coding/spotify-lib-vis/src/api-keys.sh
  243. # source "$spv_dir""/src/api-keys.sh"
  244. function ssv() {
  245. source ../bin/activate
  246. python manage.py runserver
  247. }
  248. alias spvdb="psql -d spotifyvis -U django"
  249. function mig() {
  250. python manage.py makemigrations
  251. python manage.py migrate --run-syncdb
  252. ssv
  253. }
  254. alias cldb="python manage.py flush --no-input && ssv"
  255. alias djs="python manage.py shell"
  256. alias upip="pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U"
  257. alias ureq="pip freeze > requirements.txt"
  258. # scan history
  259. alias hlg="cat $spv_dir/src/api/management/commands/update-history.log | tail -n 1"
  260. alias crnl="grep \"(kevin) CMD\" /var/log/syslog | tail -n 1 && hlg"
  261. alias hs="$spv_dir/src/update-history.sh && hlg"
  262. # removes all but newest file
  263. # alias rmol="ls -t | tail -n +2 | xargs rm -- && l"
  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 #
  275. # school {{{ #
  276. # 343
  277. alias ij="sudo ~/Downloads/idea/bin/idea.sh $silent"
  278. alias a2="f ~/Documents/school/343/a2"
  279. alias a2j="f ~/Documents/school/343/a2/java/src"
  280. alias q2="psql -U postgres -d 343-a2 -f q2-test.sql"
  281. alias q2o="psql -U postgres -d 343-a2 -f q2-test.sql -o q2.out"
  282. alias q2a="psql -U postgres -d 343-a2 -f q2.sql"
  283. alias q4="psql -U postgres -d 343-a2 -f q4-test.sql"
  284. alias q4a="psql -U postgres -d 343-a2 -f q4.sql"
  285. # }}} school #