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.

351 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
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. alias cs='printf "\033c"'
  22. alias hst="history"
  23. alias nf="cs && neofetch | lolcat"
  24. # nf
  25. alias rur="xrdb ~/.Xresources"
  26. # list file sizes in megabytes with depth 1
  27. alias dum="sudo du -d 1 -B M"
  28. alias grbm="sudo grub-mkconfig -o /boot/grub/grub.cfg"
  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 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 mkex="chmod 777"
  45. alias ctle="systemctl enable"
  46. alias ctls="systemctl start"
  47. # }}} command line related #
  48. # directory-related {{{ #
  49. alias l='ls -a'
  50. alias ll='ls -alFh'
  51. function f() { cd $1 && pwd > ~/.last_dir && ls -a ; }
  52. # restore last dir
  53. if [ -f ~/.last_dir ]
  54. then cd `cat ~/.last_dir`
  55. fi
  56. alias rmr="rm -rf"
  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. # alias aptu="sudo apt upgrade"
  99. alias pc="sudo pacman -S"
  100. alias pcr="sudo pacman -Rs"
  101. alias tri="trizen -S --noconfirm"
  102. # }}} system #
  103. # config files {{{ #
  104. function gz() { grep $1 ~/linux-config/aliases/zsh_aliases ; }
  105. alias lca="f ~/linux-config/aliases"
  106. source ~/.shortcuts
  107. # i3
  108. alias i3b="f ~/i3blocks"
  109. alias pipes="pipes.sh -t 3"
  110. # UltiSnips {{{ #
  111. urnp_dir="~/.vim/plugged/vim-snippets/UltiSnips"
  112. function vsnp() { ni ~/.vim/plugged/vim-snippets/UltiSnips/"$1".snippets ; }
  113. # }}} #
  114. # }}} config files #
  115. # applications {{{ #
  116. silent="> /dev/null 2>&1& "
  117. alias h="htop -s PERCENT_CPU"
  118. alias r="ranger"
  119. alias mr="man ranger"
  120. alias clc="cloc ."
  121. # zathura
  122. function za() { nohup zathura $1 > /dev/null 2>&1& ; }
  123. function chr() { google-chrome $1 ; }
  124. alias ni="nvim"
  125. alias sni="sudo nvim"
  126. function mrk() { pandoc -o ${1%.*}.html $1 ; }
  127. # auto-clicker {{{ #
  128. function auc() { xdotool click --repeat 1000000 --delay $1 1 ; }
  129. # alias auc1="xdotool click --repeat 1000000 --delay 1 1"
  130. # alias auc3="xdotool click --repeat 1000000 --delay 300 1"
  131. # alias auc5="xdotool click --repeat 1000000 --delay 500 1"
  132. # alias kauc="pkill -f xdotool"
  133. # }}} auto-clicker #
  134. # alias rsl="java -jar ~/Downloads/RuneLite.jar"
  135. alias swex="sudo nohup ~/Downloads/swex.appimage $silent"
  136. alias vbn="cvlc --loop --alsa-gain 1 ~/Music/brown-noise.mp3"
  137. alias rmsw="rm .sw*"
  138. function rs(){ redshift -P -O $(echo "scale=2;$1*1000" | bc) ; }
  139. alias rx="redshift -x"
  140. alias kd="pkill discord"
  141. # python related {{{ #
  142. function grpy() { grep $1 *.py ; }
  143. alias p3="python3"
  144. alias py="python"
  145. # }}} python related #
  146. # }}} applications #
  147. # git {{{ #
  148. # aliases {{{
  149. alias gstr="git config credential.helper store"
  150. # add {{{ #
  151. alias ga="git add -A . && gs"
  152. alias gac="git add -A . && git commit"
  153. # }}} add #
  154. # diff/log {{{ #
  155. alias gd="git diff -w"
  156. alias gdc="git diff --cached"
  157. alias gds="git diff --stat"
  158. alias gdt="git difftool --tool=vimdiff"
  159. alias gl="git log"
  160. alias gsl="git shortlog"
  161. # }}} diff/log #
  162. # update {{{ #
  163. alias gs="git status -u"
  164. alias gchom="git checkout master"
  165. alias gchnw="git checkout -b wip"
  166. alias gchw="git checkout wip"
  167. alias gheadm1="git reset --hard HEAD~1"
  168. alias gls="git ls-tree -r HEAD --name-only"
  169. # push {{{ #
  170. alias egc="nvim -c \"set syn=gitcommit\" -c \"set tw=72\" commit-msg.txt"
  171. alias gst="git stash"
  172. alias gstp="git stash pop"
  173. alias gc="git commit"
  174. alias gcam="ga && git commit --amend --no-edit"
  175. alias gcamp="ga && git commit --amend --no-edit && gpsf"
  176. # todo: fix
  177. function gcm(){ echo git commit -m \""$1"\" ; }
  178. function psg() {
  179. git add .
  180. git commit -m '.'
  181. git push
  182. }
  183. alias gps="git push"
  184. alias gpsi="git push --set-upstream origin master"
  185. alias gpsf="git push --force"
  186. alias gclear="git stash clear"
  187. # }}} push #
  188. # pull {{{ #
  189. alias gpl="git pull --rebase"
  190. alias grbc="git rebase --continue"
  191. # }}} pull #
  192. # }}} update #
  193. # edit {{{ #
  194. alias vre="ni README.md"
  195. alias crm="mrk README.md"
  196. # }}} edit #
  197. # aliases }}}
  198. # functions {{{
  199. alias gcho="git checkout"
  200. alias gchon="git checkout -b"
  201. function gchof() { git checkout $1 $2 ; }
  202. alias gcln="git clone"
  203. alias gchp="git cherry-pick"
  204. alias gchpc="git cherry-pick --continue"
  205. # add multiple push repos
  206. function gremotes() {
  207. git remote set-url --add --push origin $1
  208. git remote set-url --add --push origin $2
  209. git remote -v
  210. }
  211. # gmrgr: merge repos {{{ #
  212. function gmrgr() {
  213. # 1 = remote name, 2 = remote path
  214. git remote add $1 $2
  215. git fetch $1
  216. # whichever branch you want to merge
  217. git merge --allow-unrelated-histories $1/master
  218. git remote remove $1
  219. }
  220. # }}} merge repos #
  221. # assume file unchanged
  222. alias gunc="git update-index --assume-unchanged"
  223. # delete branch locally and on server
  224. function grmb() { git push origin --delete $1 && git branch -D $1 ; }
  225. # functions }}}
  226. # }}} git #
  227. # coding projs {{{ #
  228. coding_dir="~/coding"
  229. alias cdn="$cd_coding_dir"
  230. alias gx="ni ~/Documents/csgo-config/autoexec.cfg"
  231. # trapbot {{{ #
  232. alias tb="$cd_coding_dir/trapbot"
  233. alias vtb="$cd_coding_dir/trapbot && ni scan_reddit.py"
  234. alias ptb="python scan_reddit.py"
  235. alias rtb="$cd_coding_dir/trapbot && python scan_reddit.py"
  236. # }}} trapbot #
  237. # spotify-lib-vis {{{ #
  238. spv_dir="$coding_dir""/spotify-lib-vis"
  239. alias svl="f $spv_dir/src/login"
  240. alias sva="f $spv_dir/src/api"
  241. alias svg="f $spv_dir/src/graphs"
  242. alias svscs="f $spv_dir/src/static/scss"
  243. alias svcss="f $spv_dir/src/spotifyvis/static/scss"
  244. # source ~/coding/spotify-lib-vis/src/api-keys.sh
  245. # source "$spv_dir""/src/api-keys.sh"
  246. function ssv() {
  247. source ../bin/activate
  248. python manage.py runserver
  249. }
  250. alias spvdb="psql -d spotifyvis -U django"
  251. function mig() {
  252. python manage.py makemigrations
  253. python manage.py migrate --run-syncdb
  254. ssv
  255. }
  256. alias cldb="python manage.py flush --no-input && ssv"
  257. alias djs="python manage.py shell"
  258. alias upip="pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U"
  259. alias ureq="pip freeze > requirements.txt"
  260. # scan history
  261. alias hlg="cat $spv_dir/src/api/management/commands/update-history.log | tail -n 1"
  262. alias crnl="grep \"(kevin) CMD\" /var/log/syslog | tail -n 1 && hlg"
  263. alias hs="$spv_dir/src/update-history.sh && hlg"
  264. # removes all but newest file
  265. # alias rmol="ls -t | tail -n +2 | xargs rm -- && l"
  266. # }}} spotify-lib-vis #
  267. # # Stardew Valley {{{
  268. # sdv_save_dir=~/Documents/sdv-save
  269. # alias sdv="f $sdv_save_dir"
  270. # alias smp="~/Downloads/sdv/smapi/install\ on\ Linux.sh"
  271. # # alias imc="sdv && source import-save.sh coop"
  272. # function ucf() { f ~/Documents/StardewMods/UncaughtFish ; }
  273. # function svmd() { f ~/.local/share/Steam/steamapps/common/Stardew\ Valley/Mods ; }
  274. # function svm() { mv $1 ~/.local/share/Steam/steamapps/common/Stardew\ Valley/Mods ; }
  275. # # }}}
  276. # }}} coding projs #
  277. # school {{{ #
  278. # 343
  279. alias ij="sudo ~/Downloads/idea/bin/idea.sh $silent"
  280. alias a2="f ~/Documents/school/343/a2"
  281. alias a2j="f ~/Documents/school/343/a2/java/src"
  282. alias q2="psql -U postgres -d 343-a2 -f q2-test.sql"
  283. alias q2o="psql -U postgres -d 343-a2 -f q2-test.sql -o q2.out"
  284. alias q2a="psql -U postgres -d 343-a2 -f q2.sql"
  285. alias q4="psql -U postgres -d 343-a2 -f q4-test.sql"
  286. alias q4a="psql -U postgres -d 343-a2 -f q4.sql"
  287. # }}} school #