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.

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