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.

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