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.

361 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
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 ru="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. function gpdf() {
  32. pdfgrep -n -e $1 $2
  33. }
  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. alias pk="pkill -f"
  40. # extract tar archive
  41. function utar() { tar -xzvf $1 && rm $1; }
  42. function rzip() { unzip $1 && rm $1; }
  43. function lzip() { unzip -l $1 | less; }
  44. alias mkpk="makepkg -sri"
  45. alias mkex="chmod 777"
  46. alias udm="udisksctl mount -b"
  47. alias udu="udisksctl unmount -b"
  48. alias udub="udisksctl unmount -b /dev/sdc2"
  49. alias mkex="chmod 777"
  50. alias ctle="systemctl enable"
  51. alias ctls="systemctl start"
  52. # }}} command line related #
  53. # directory-related {{{ #
  54. alias l='ls -a'
  55. alias ll='ls -alFh'
  56. function f() { cd $1 && pwd > ~/.last_dir && ls -a ; }
  57. # restore last dir
  58. if [ -f ~/.last_dir ]
  59. then cd `cat ~/.last_dir`
  60. fi
  61. alias rmr="rm -rf"
  62. alias mdp="mkdir -p"
  63. alias "f."="f .."
  64. alias "f.."="f ..."
  65. function mvd() { mv $1 ~/Downloads ; }
  66. alias lhd="sudo fdisk -l"
  67. alias ds="df -h | grep sd"
  68. alias nbu="f /run/media/kevin/pc-backup/backups/nzxt && ll | grep gz"
  69. # }}} directory-related #
  70. # power options {{{ #
  71. alias s="systemctl suspend"
  72. alias sd="sudo shutdown 0"
  73. alias reb="sudo shutdown -r 0"
  74. alias lo="i3-msg exit"
  75. # }}} power options #
  76. # rotate monitor {{{ #
  77. function rt() {
  78. output="HDMI-0"
  79. if [ "$1" = "s" ]
  80. # if [ "${1:0:1}" = "s" ]
  81. then
  82. output="DVI-I-1"
  83. fi
  84. dir="normal"
  85. if [ "$2" = "r" ]
  86. # if [ "${1:1:2}" = "r" ]
  87. then
  88. dir="right"
  89. fi
  90. if [ "$2" = "l" ]
  91. then
  92. dir="left"
  93. fi
  94. # echo "xrandr --output \"$output\" --rotate \"$dir\""
  95. xrandr --output "$output" --rotate "$dir"
  96. }
  97. # }}} rotate monitor #
  98. # sound
  99. alias vlm="alsamixer -c 0"
  100. alias vlh="alsamixer -c 2"
  101. # apt
  102. # function apti() { sudo apt install $1 ; }
  103. # function aptr() { sudo apt remove $1 ; }
  104. # alias aptu="sudo apt upgrade"
  105. alias pc="sudo pacman -S"
  106. alias pcr="sudo pacman -Rs"
  107. alias spc="pacman -Qqe > ~/linux-config/txt/pacman-pkgs/pacman-pkgs.txt"
  108. # alias tri="trizen -S --noconfirm"
  109. alias tri="trizen -S"
  110. # }}} system #
  111. # config files {{{ #
  112. function gz() { grep $1 ~/linux-config/aliases/zsh_aliases ; }
  113. alias lca="f ~/linux-config/aliases"
  114. source ~/.shortcuts
  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() { ni ~/.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. alias gdc="git diff --cached"
  165. alias gds="git diff --stat"
  166. alias gdt="git difftool --tool=vimdiff"
  167. alias gl="git log"
  168. alias gsl="git shortlog"
  169. # }}} diff/log #
  170. # update {{{ #
  171. alias gs="git status -u"
  172. alias gchom="git checkout master"
  173. alias gchnw="git checkout -b wip"
  174. alias gchw="git checkout wip"
  175. alias gheadm1="git reset --hard HEAD~1"
  176. alias gls="git ls-tree -r HEAD --name-only"
  177. # push {{{ #
  178. alias egc="nvim -c \"set syn=gitcommit\" -c \"set tw=72\" commit-msg.txt"
  179. alias gst="git stash"
  180. alias gstp="git stash pop"
  181. alias gc="git commit"
  182. alias gcam="ga && git commit --amend --no-edit"
  183. alias gcamp="ga && git commit --amend --no-edit && gpsf"
  184. # todo: fix
  185. function gcm(){ echo git commit -m \""$1"\" ; }
  186. function psg() {
  187. git add .
  188. git commit -m '.'
  189. git push
  190. }
  191. alias gps="git push"
  192. alias gpsi="git push --set-upstream origin master"
  193. alias gpsf="git push --force"
  194. alias gclear="git stash clear"
  195. # }}} push #
  196. # pull {{{ #
  197. alias gpl="git pull --rebase"
  198. alias grbc="git rebase --continue"
  199. # }}} pull #
  200. # }}} update #
  201. # edit {{{ #
  202. alias vre="ni README.md"
  203. alias crm="mrk README.md"
  204. # }}} edit #
  205. # aliases }}}
  206. # functions {{{
  207. alias gcho="git checkout"
  208. alias gchon="git checkout -b"
  209. function gchof() { git checkout $1 $2 ; }
  210. alias gcln="git clone"
  211. alias gchp="git cherry-pick"
  212. alias gchpc="git cherry-pick --continue"
  213. # add multiple push repos
  214. function gremotes() {
  215. git remote set-url --add --push origin $1
  216. git remote set-url --add --push origin $2
  217. git remote -v
  218. }
  219. # gmrgr: merge repos {{{ #
  220. function gmrgr() {
  221. # 1 = remote name, 2 = remote path
  222. git remote add $1 $2
  223. git fetch $1
  224. # whichever branch you want to merge
  225. git merge --allow-unrelated-histories $1/master
  226. git remote remove $1
  227. }
  228. # }}} merge repos #
  229. # assume file unchanged
  230. alias gunc="git update-index --assume-unchanged"
  231. # delete branch locally and on server
  232. function grmb() { git push origin --delete $1 && git branch -D $1 ; }
  233. # functions }}}
  234. # }}} git #
  235. # coding projs {{{ #
  236. coding_dir="~/coding"
  237. alias cdn="$cd_coding_dir"
  238. alias gx="ni ~/Documents/csgo-config/autoexec.cfg"
  239. # trapbot {{{ #
  240. alias tb="$cd_coding_dir/trapbot"
  241. alias vtb="$cd_coding_dir/trapbot && ni scan_reddit.py"
  242. alias ptb="python scan_reddit.py"
  243. alias rtb="$cd_coding_dir/trapbot && python scan_reddit.py"
  244. # }}} trapbot #
  245. # spotify-lib-vis {{{ #
  246. spv_dir="$coding_dir""/spotify-lib-vis"
  247. alias svl="f $spv_dir/src/login"
  248. alias sva="f $spv_dir/src/api"
  249. alias svg="f $spv_dir/src/graphs"
  250. alias svscs="f $spv_dir/src/static/scss"
  251. alias svcss="f $spv_dir/src/spotifyvis/static/scss"
  252. # source ~/coding/spotify-lib-vis/src/api-keys.sh
  253. # source "$spv_dir""/src/api-keys.sh"
  254. function ssv() {
  255. source ../bin/activate
  256. python manage.py runserver
  257. }
  258. alias spvdb="psql -d spotifyvis -U django"
  259. function mig() {
  260. python manage.py makemigrations
  261. python manage.py migrate --run-syncdb
  262. ssv
  263. }
  264. alias cldb="python manage.py flush --no-input && ssv"
  265. alias djs="python manage.py shell"
  266. alias upip="pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U"
  267. alias ureq="pip freeze > requirements.txt"
  268. # scan history
  269. alias hlg="cat $spv_dir/src/api/management/commands/update-history.log | tail -n 1"
  270. alias crnl="grep \"(kevin) CMD\" /var/log/syslog | tail -n 1 && hlg"
  271. alias hs="$spv_dir/src/update-history.sh && hlg"
  272. # removes all but newest file
  273. # alias rmol="ls -t | tail -n +2 | xargs rm -- && l"
  274. # }}} spotify-lib-vis #
  275. # # Stardew Valley {{{
  276. # sdv_save_dir=~/Documents/sdv-save
  277. # alias sdv="f $sdv_save_dir"
  278. # alias smp="~/Downloads/sdv/smapi/install\ on\ Linux.sh"
  279. # # alias imc="sdv && source import-save.sh coop"
  280. # function ucf() { f ~/Documents/StardewMods/UncaughtFish ; }
  281. # function svmd() { f ~/.local/share/Steam/steamapps/common/Stardew\ Valley/Mods ; }
  282. # function svm() { mv $1 ~/.local/share/Steam/steamapps/common/Stardew\ Valley/Mods ; }
  283. # # }}}
  284. # }}} coding projs #
  285. # school {{{ #
  286. alias pdl="pdflatex"
  287. # 343
  288. alias ij="sudo ~/Downloads/idea/bin/idea.sh $silent"
  289. alias a2="f ~/Documents/school/343/a2"
  290. alias a2j="f ~/Documents/school/343/a2/java/src"
  291. alias q2="psql -U postgres -d 343-a2 -f q2-test.sql"
  292. alias q2o="psql -U postgres -d 343-a2 -f q2-test.sql -o q2.out"
  293. alias q2a="psql -U postgres -d 343-a2 -f q2.sql"
  294. alias q4="psql -U postgres -d 343-a2 -f q4-test.sql"
  295. alias q4a="psql -U postgres -d 343-a2 -f q4.sql"
  296. # }}} school #