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.

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