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.

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