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.

366 lines
9.0 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. # vim mode {{{ #
  3. bindkey -v
  4. function zle-line-init zle-keymap-select {
  5. VIM_PROMPT="%{$fg_bold[yellow]%} [% NORMAL]% %{$reset_color%}"
  6. RPS1="${${KEYMAP/vicmd/$VIM_PROMPT}/(main|viins)/} $EPS1"
  7. zle reset-prompt
  8. }
  9. zle -N zle-line-init
  10. zle -N zle-keymap-select
  11. export KEYTIMEOUT=1
  12. # }}} vim mode #
  13. # command line related {{{ #
  14. # search history
  15. bindkey '\e[A' history-beginning-search-backward
  16. bindkey '\e[B' history-beginning-search-forward
  17. alias cs='printf "\033c"'
  18. alias hst="history"
  19. alias nf="cs && neofetch | lolcat"
  20. # nf
  21. alias ru="xrdb ~/.Xresources"
  22. # list file sizes in megabytes with depth 1
  23. alias dum="sudo du -d 1 -B M"
  24. alias grbm="sudo grub-mkconfig -o /boot/grub/grub.cfg"
  25. function cld() { colordiff -y --suppress-common-lines $1 $2 ; }
  26. alias grep='grep --color=auto'
  27. function gpdf() {
  28. pdfgrep -n -e $1 $2
  29. }
  30. # for finding files by name
  31. function rf() { find . -name '$1' ; }
  32. # find text inside files
  33. function rg() { grep -nr $1 ; }
  34. function cpd() { cp -avr $1 $2 ; }
  35. alias pk="pkill -f"
  36. # extract tar archive
  37. function utar() { tar -xzvf $1 && rm $1; }
  38. function rzip() { unzip $1 && rm $1; }
  39. function lzip() { unzip -l $1 | less; }
  40. alias mkpk="makepkg -sri"
  41. alias mkex="chmod 777"
  42. alias udm="udisksctl mount -b"
  43. alias udu="udisksctl unmount -b"
  44. alias udub="udisksctl unmount -b /dev/sdc2"
  45. alias mkex="chmod 777"
  46. alias ctle="systemctl enable"
  47. alias ctls="systemctl start"
  48. # }}} command line related #
  49. # directory-related {{{ #
  50. alias l='ls -a'
  51. alias ll='ls -alFh'
  52. # alias f="cd"
  53. function f() { cd $1 && pwd > ~/.last_dir ; }
  54. # function f() { cd $1 && pwd > ~/.last_dir && ls -a ; }
  55. # restore last dir
  56. if [ -f ~/.last_dir ]
  57. # then cd `cat ~/.last_dir`
  58. then f `cat ~/.last_dir`
  59. fi
  60. alias rmr="rm -rf"
  61. alias mdp="mkdir -p"
  62. alias "f."="f .."
  63. alias "f.."="f ..."
  64. function mvd() { mv $1 ~/Downloads ; }
  65. alias lhd="sudo fdisk -l"
  66. alias ds="df -h | grep sd"
  67. alias nbu="f /run/media/kevin/pc-backup/backups/nzxt && ll | grep gz"
  68. # }}} directory-related #
  69. # power options {{{ #
  70. alias p="systemctl suspend"
  71. alias sd="sudo shutdown 0"
  72. alias reb="sudo shutdown -r 0"
  73. alias lo="i3-msg exit"
  74. # }}} power options #
  75. # rotate monitor {{{ #
  76. function rt() {
  77. output="HDMI-0"
  78. if [ "$1" = "s" ]
  79. # if [ "${1:0:1}" = "s" ]
  80. then
  81. output="DVI-I-1"
  82. fi
  83. dir="normal"
  84. if [ "$2" = "r" ]
  85. # if [ "${1:1:2}" = "r" ]
  86. then
  87. dir="right"
  88. fi
  89. if [ "$2" = "l" ]
  90. then
  91. dir="left"
  92. fi
  93. # echo "xrandr --output \"$output\" --rotate \"$dir\""
  94. xrandr --output "$output" --rotate "$dir"
  95. }
  96. # }}} rotate monitor #
  97. # sound
  98. alias vlm="alsamixer -c 0"
  99. alias vlh="alsamixer -c 2"
  100. # apt
  101. # function apti() { sudo apt install $1 ; }
  102. # function aptr() { sudo apt remove $1 ; }
  103. # alias aptu="sudo apt upgrade"
  104. alias pc="sudo pacman -S"
  105. alias pcr="sudo pacman -Rs"
  106. alias xpc="pacman -Qqe > ~/linux-config/txt/pacman-pkgs/nzxt-pkgs.txt"
  107. # alias tri="trizen -S --noconfirm"
  108. alias tri="trizen -S"
  109. # }}} system #
  110. # config files {{{ #
  111. function gz() { grep $1 ~/linux-config/aliases/zsh_aliases ; }
  112. alias rz="source ~/linux-config/aliases/zsh_aliases"
  113. alias tst="echo a"
  114. alias lca="f ~/linux-config/aliases"
  115. # i3
  116. alias i3b="f ~/i3blocks"
  117. alias pipes="pipes.sh -t 3"
  118. # UltiSnips {{{ #
  119. urnp_dir="~/.vim/plugged/vim-snippets/UltiSnips"
  120. function vsnp() { nvim ~/.vim/plugged/vim-snippets/UltiSnips/"$1".snippets ; }
  121. # }}} #
  122. # }}} config files #
  123. # applications {{{ #
  124. silent="> /dev/null 2>&1& "
  125. alias h="htop -s PERCENT_MEM"
  126. alias hc="htop -s PERCENT_CPU"
  127. alias r="ranger"
  128. alias mr="man ranger"
  129. alias clc="cloc ."
  130. function za() { nohup zathura $1 > /dev/null 2>&1& ; }
  131. function ev() { nohup evince $1 > /dev/null 2>&1& ; }
  132. function chr() { google-chrome $1 ; }
  133. alias ni="nvim"
  134. alias sni="sudo nvim"
  135. function mrk() { pandoc -o ${1%.*}.html $1 ; }
  136. # auto-clicker {{{ #
  137. function auc() { xdotool click --repeat 1000000 --delay $1 1 ; }
  138. # alias auc1="xdotool click --repeat 1000000 --delay 1 1"
  139. # alias auc3="xdotool click --repeat 1000000 --delay 300 1"
  140. # alias auc5="xdotool click --repeat 1000000 --delay 500 1"
  141. # alias kauc="pkill -f xdotool"
  142. # }}} auto-clicker #
  143. # alias rsl="java -jar ~/Downloads/RuneLite.jar"
  144. alias swex="sudo nohup ~/Downloads/swex.appimage $silent"
  145. alias vbn="cvlc --loop --alsa-gain 1 ~/Music/brown-noise.mp3"
  146. alias rmsw="rm .sw*"
  147. function rs(){ redshift -P -O $(echo "scale=2;$1*1000" | bc) ; }
  148. alias rx="redshift -x"
  149. # python related {{{ #
  150. function grpy() { grep $1 *.py ; }
  151. alias p3="python3"
  152. alias py="python"
  153. # }}} python related #
  154. # }}} applications #
  155. # git {{{ #
  156. # aliases {{{
  157. alias gstr="git config credential.helper store"
  158. # add {{{ #
  159. alias ga="git add -A . && gs"
  160. alias gac="git add -A . && git commit"
  161. # }}} add #
  162. # diff/log {{{ #
  163. alias gd="git diff -w"
  164. function gde() { git diff --cached -- ':(exclude)'$1 ; }
  165. alias gdc="git diff --cached"
  166. alias gds="git diff --stat"
  167. alias gdt="git difftool --tool=vimdiff"
  168. alias gl="git log"
  169. alias gsl="git shortlog"
  170. # }}} diff/log #
  171. # update {{{ #
  172. alias gs="git status -u"
  173. alias gchom="git checkout master"
  174. alias gchnw="git checkout -b wip"
  175. alias gchw="git checkout wip"
  176. alias gheadm1="git reset --hard HEAD~1"
  177. alias gls="git ls-tree -r HEAD --name-only"
  178. # push {{{ #
  179. alias egc="nvim -c \"set syn=gitcommit\" -c \"set tw=72\" commit-msg.txt"
  180. alias gst="git stash"
  181. alias gstp="git stash pop"
  182. alias gc="git commit"
  183. alias gcam="ga && git commit --amend --no-edit"
  184. alias gcamp="ga && git commit --amend --no-edit && gpsf"
  185. # todo: fix
  186. function gcm(){ echo git commit -m \""$1"\" ; }
  187. function psg() {
  188. git add .
  189. git commit -m '.'
  190. git push
  191. }
  192. alias gps="git push"
  193. alias gpsi="git push --set-upstream origin master"
  194. alias gpsf="git push --force"
  195. alias gclear="git stash clear"
  196. # }}} push #
  197. # pull {{{ #
  198. alias gpl="git pull --rebase"
  199. alias grbc="git rebase --continue"
  200. # }}} pull #
  201. # }}} update #
  202. # edit {{{ #
  203. alias vre="ni README.md"
  204. alias crm="mrk README.md"
  205. # }}} edit #
  206. # aliases }}}
  207. # functions {{{
  208. alias gcho="git checkout"
  209. alias gchon="git checkout -b"
  210. function gchof() { git checkout $1 $2 ; }
  211. alias gcln="git clone"
  212. alias gchp="git cherry-pick"
  213. alias gchpc="git cherry-pick --continue"
  214. # add multiple push repos
  215. function gremotes() {
  216. git remote set-url --add --push origin $1
  217. git remote set-url --add --push origin $2
  218. git remote -v
  219. }
  220. # gmrgr: merge repos {{{ #
  221. function gmrgr() {
  222. # 1 = remote name, 2 = remote path
  223. git remote add $1 $2
  224. git fetch $1
  225. # whichever branch you want to merge
  226. git merge --allow-unrelated-histories $1/master
  227. git remote remove $1
  228. }
  229. # }}} merge repos #
  230. # assume file unchanged
  231. alias gunc="git update-index --assume-unchanged"
  232. # delete branch locally and on server
  233. function grmb() { git push origin --delete $1 && git branch -D $1 ; }
  234. # functions }}}
  235. # }}} git #
  236. # coding projs {{{ #
  237. coding_dir="~/coding"
  238. alias cdn="$cd_coding_dir"
  239. alias gx="ni ~/Documents/csgo-config/autoexec.cfg"
  240. # trapbot {{{ #
  241. alias tb="$cd_coding_dir/trapbot"
  242. alias vtb="$cd_coding_dir/trapbot && ni scan_reddit.py"
  243. alias ptb="python scan_reddit.py"
  244. alias rtb="$cd_coding_dir/trapbot && python scan_reddit.py"
  245. # }}} trapbot #
  246. # spotify-lib-vis {{{ #
  247. spv_dir="$coding_dir""/spotify-lib-vis"
  248. alias svl="f $spv_dir/src/login"
  249. alias sva="f $spv_dir/src/api"
  250. alias svg="f $spv_dir/src/graphs"
  251. alias svscs="f $spv_dir/src/static/scss"
  252. alias svcss="f $spv_dir/src/spotifyvis/static/scss"
  253. # source ~/coding/spotify-lib-vis/src/api-keys.sh
  254. # source "$spv_dir""/src/api-keys.sh"
  255. function ssv() {
  256. source ../bin/activate
  257. python manage.py runserver
  258. }
  259. alias spvdb="psql -d spotifyvis -U django"
  260. function mig() {
  261. python manage.py makemigrations
  262. python manage.py migrate --run-syncdb
  263. ssv
  264. }
  265. alias cldb="python manage.py flush --no-input && ssv"
  266. alias djs="python manage.py shell"
  267. alias upip="pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U"
  268. alias ureq="pip freeze > requirements.txt"
  269. # scan history
  270. alias hlg="cat $spv_dir/src/api/management/commands/update-history.log | tail -n 1"
  271. alias crnl="grep \"(kevin) CMD\" /var/log/syslog | tail -n 1 && hlg"
  272. alias hs="$spv_dir/src/update-history.sh && hlg"
  273. # removes all but newest file
  274. # alias rmol="ls -t | tail -n +2 | xargs rm -- && l"
  275. # }}} spotify-lib-vis #
  276. # # Stardew Valley {{{
  277. # sdv_save_dir=~/Documents/sdv-save
  278. # alias sdv="f $sdv_save_dir"
  279. # alias smp="~/Downloads/sdv/smapi/install\ on\ Linux.sh"
  280. # # alias imc="sdv && source import-save.sh coop"
  281. # function ucf() { f ~/Documents/StardewMods/UncaughtFish ; }
  282. # function svmd() { f ~/.local/share/Steam/steamapps/common/Stardew\ Valley/Mods ; }
  283. # function svm() { mv $1 ~/.local/share/Steam/steamapps/common/Stardew\ Valley/Mods ; }
  284. # # }}}
  285. alias s="cs && shellcheck"
  286. # }}} coding projs #
  287. # school {{{ #
  288. alias pdl="pdflatex"
  289. alias tcl="texclear"
  290. # 343
  291. alias ij="sudo ~/Downloads/idea/bin/idea.sh $silent"
  292. alias a2="f ~/Documents/school/343/a2"
  293. alias a2j="f ~/Documents/school/343/a2/java/src"
  294. alias q2="psql -U postgres -d 343-a2 -f q2-test.sql"
  295. alias q2o="psql -U postgres -d 343-a2 -f q2-test.sql -o q2.out"
  296. alias q2a="psql -U postgres -d 343-a2 -f q2.sql"
  297. alias q4="psql -U postgres -d 343-a2 -f q4-test.sql"
  298. alias q4a="psql -U postgres -d 343-a2 -f q4.sql"
  299. # }}} school #