# system {{{ # setopt extendedglob # vim mode {{{ # bindkey -v function zle-line-init zle-keymap-select { VIM_PROMPT="%{$fg_bold[yellow]%} [% NORMAL]% %{$reset_color%}" RPS1="${${KEYMAP/vicmd/$VIM_PROMPT}/(main|viins)/} $EPS1" zle reset-prompt } zle -N zle-line-init zle -N zle-keymap-select export KEYTIMEOUT=1 # }}} vim mode # # command line related {{{ # # search history bindkey '\e[A' history-beginning-search-backward bindkey '\e[B' history-beginning-search-forward function src() { source $1 ; } alias cs='printf "\033c"' alias hst="history" alias nf="neofetch" alias rur="xrdb ~/.Xresources" function gvx() { urxvt --help 2>&1 | grep $1 ; } # list file sizes in megabytes with depth 1 alias dum="sudo du -d 1 -B M" alias grbm="sudo grub-mkconfig -o /boot/grub/grub.cfg" # install deb files function ideb() { sudo dpkg -i $1 ; } function cld() { colordiff -y --suppress-common-lines $1 $2 ; } alias grep='grep --color=auto' # for finding files by name function rfnd() { find . -name "$1" ; } # find text inside files function rg() { grep -nr $1 * ; } function cpd() { cp -avr $1 $2 ; } # extract tar archive function untar() { tar -xzvf $1 && rm $1; } function runzip() { unzip $1 && rm $1; } function mkex() { chmod 777 $1 ; } # }}} command line related # # directory-related {{{ # alias l='ls -a' alias ll='ls -alF' function f() { cd $1 && pwd > ~/.last_dir && ls -a ; } # restore last dir if [ -f ~/.last_dir ] then cd `cat ~/.last_dir` fi function rmr() { rm -rf $1 ; } # todo: fix # function f.() { f $(printf "%0.s../" $(seq 1 $1 )) ; } alias "f."="f .." alias "f.2"="f ..." alias fd="f ~/Downloads" function mvd() { mv $1 ~/Downloads ; } alias fds="f ~/Downloads/sch" alias doc="f ~/Documents" alias wo="f ~/Documents/workout-logs/9" alias cfg="f ~/.config" # }}} directory-related # # power options {{{ # alias s="systemctl suspend" alias sd="sudo shutdown 0" alias reb="sudo shutdown -r 0" alias lo="i3-msg exit" # }}} power options # # rotate monitor {{{ # function rt() { output="HDMI-0" if [ "$1" = "s" ] # if [ "${1:0:1}" = "s" ] then output="DVI-I-1" fi dir="normal" if [ "$2" = "r" ] # if [ "${1:1:2}" = "r" ] then dir="right" fi if [ "$2" = "l" ] then dir="left" fi # echo "xrandr --output \"$output\" --rotate \"$dir\"" xrandr --output "$output" --rotate "$dir" } # }}} rotate monitor # # sound alias vlm="alsamixer -c 0" alias vlmh="alsamixer -c 3" # apt function apti() { sudo apt install $1 ; } function aptr() { sudo apt remove $1 ; } # }}} system # # config files {{{ # alias lc="f ~/linux-config/" function glc() { grep $1 ~/linux-config/aliases/zsh_aliases ; } alias lca="f ~/linux-config/aliases" alias vv="ni ~/.vimrc" alias vu="ni ~/.Xresources" alias vzb="ni ~/.zshrc" alias vz="ni ~/linux-config/aliases/zsh_aliases" alias vr="ni ~/.config/ranger/rc.conf" # i3 {{{ # alias v3="ni ~/.config/i3/config" alias v3b="ni ~/.config/i3blocks/i3blocks.conf" alias i3b="f ~/i3blocks" alias pipes="pipes.sh -t 2" alias bg="f ~/Pictures/Backgrounds" # }}} i3 # # UltiSnips {{{ # usnp_dir="~/.vim/plugged/vim-snippets/UltiSnips" alias snp="f $usnp_dir" function vsnp() { ni ~/.vim/plugged/vim-snippets/UltiSnips/"$1".snippets ; } alias tm="ni $usnp_dir/texmath.snippets" # }}} # # }}} config files # # applications {{{ # alias ran="ranger" # okular function ok() { nohup okular $1 > /dev/null 2>&1& ; } # xviewer function xv() { nohup xviewer $1 > /dev/null 2>&1& ; } function chr() { google-chrome $1 ; } function ni() { nvim $1 ; } function sni() { sudo nvim $1 ; } alias nisw="f ~/.local/share/nvim/swap" # function mrk() { pandoc -o ${1%.*}.html $1 && chr ${1%.*}.html ; } function mrk() { pandoc -o ${1%.*}.html $1 ; } function auc() { xdotool click --repeat 1000000 --delay $1 1 ; } # alias auc1="xdotool click --repeat 1000000 --delay 1 1" # alias auc3="xdotool click --repeat 1000000 --delay 300 1" # alias auc5="xdotool click --repeat 1000000 --delay 500 1" # alias kauc="pkill -f xdotool" alias rsl="java -jar ~/Downloads/RuneLite.jar" alias vbn="cvlc --loop --alsa-gain 1 ~/Music/brown-noise.mp3" alias rmsw="rm .sw*" # function rs(){ redshift -O $(echo "scale=2;$1*1000" | bc) ; } function rds(){ redshift -O $1 ; } alias rx="redshift -x" # python related {{{ # function grpy() { grep $1 *.py ; } function p3() { python3 $1 ; } function py() { python $1 ; } # }}} python related # # }}} applications # # git {{{ # # aliases {{{ alias gstr="git config credential.helper store" # add {{{ # alias ga="git add -A . && gs" alias gac="git add -A . && git commit" # }}} add # # diff/log {{{ # alias gd="git diff -w" alias gdc="git diff --cached" alias gds="git diff --stat" alias gdt="git difftool --tool=vimdiff" alias gl="git log" alias gsl="git shortlog" # }}} diff/log # # update {{{ # alias gs="git status -u" alias gchom="git checkout master" alias gchnw="git checkout -b wip" alias gchw="git checkout wip" alias gheadm1="git reset --hard HEAD~1" alias glstf="git ls-tree -r HEAD --name-only" # push {{{ # alias egc="nvim -c \"set syn=gitcommit\" -c \"set tw=72\" commit-msg.txt" alias gst="git stash" alias gstp="git stash pop" alias gc="git commit" alias gcam="ga && git commit --amend" # todo: fix function gcm(){ echo git commit -m \""$1"\" ; } function psg() { git add . git commit -m '.' git push } alias gps="git push" alias gpsi="git push --set-upstream origin master" alias gpsf="git push --force" alias gclear="git stash clear" # }}} push # # pull {{{ # alias gpl="git pull --rebase" alias grbc="git rebase --continue" # }}} pull # # }}} update # # edit {{{ # alias vig="ni .gitignore" alias vir="ni README.md" alias crm="mrk README.md" # }}} edit # # aliases }}} # functions {{{ function gcho() { git checkout $1 ; } function gchon() { git checkout -b $1 ; } function gchof() { git checkout $1 $2 ; } function gcln() { git clone $1 ; } function gchp() { git cherry-pick $1 ; } alias gchpc="git cherry-pick --continue" # add multiple push repos function gremotes() { git remote set-url --add --push origin $1 git remote set-url --add --push origin $2 git remote -v } # gmrgr: merge repos {{{ # function gmrgr() { # 1 = remote name, 2 = remote path git remote add $1 $2 git fetch $1 # whichever branch you want to merge git merge --allow-unrelated-histories $1/master git remote remove $1 } # }}} merge repos # # assume file unchanged function gunc() { git update-index --assume-unchanged $1 ; } # delete branch locally and on server function grmb() { git push origin --delete $1 && git branch -D $1 ; } # functions }}} # }}} git # # coding projs {{{ # coding_dir="~/coding" cd_coding_dir="f $coding_dir" alias cdn="$cd_coding_dir" alias ans="f /usr/local/android-studio/bin && ./studio.sh" alias gx="ni ~/Documents/csgo-config/autoexec.cfg" alias jnd="f ~/Documents/journal" alias jn="ni ~/Documents/journal/todo/9.md" alias jnt="ni ~/Documents/journal/todo/todo.md" alias rs="f ~/Documents/runescape" # ideas {{{ # # ideas_dir="$coding_dir""/ideas" # alias ids="f $ideas_dir" # alias lci="f $ideas_dir/general" # alias vli="ni $ideas_dir/general/ideas.md" # alias fyn="f $ideas_dir/yes-no" # }}} ideas # # trapbot {{{ # alias tb="$cd_coding_dir/trapbot" alias vtb="$cd_coding_dir/trapbot && ni scan_reddit.py" alias ptb="python scan_reddit.py" alias rtb="$cd_coding_dir/trapbot && python scan_reddit.py" # }}} trapbot # # spotify-lib-vis {{{ # spv_dir="$coding_dir""/spotify-lib-vis" alias sv="f $spv_dir/src" alias svl="f $spv_dir/src/login" alias sva="f $spv_dir/src/api" alias svg="f $spv_dir/src/graphs" alias ft="f templates" function ssv() { source api-keys.sh source ../bin/activate python manage.py runserver } alias spvdb="psql -d spotifyvis -U django" function mig() { python manage.py makemigrations python manage.py migrate --run-syncdb ssv } alias cldb="python manage.py flush --no-input" alias djs="python manage.py shell" # }}} spotify-lib-vis # # Stardew Valley {{{ sdv_save_dir=~/Documents/sdv-save alias sdv="f $sdv_save_dir" alias smp="~/Downloads/sdv/smapi/install\ on\ Linux.sh" alias imc="sdv && source import-save.sh coop" function ucf() { f ~/Documents/StardewMods/UncaughtFish ; } function svmd() { f ~/.local/share/Steam/steamapps/common/Stardew\ Valley/Mods ; } function svm() { mv $1 ~/.local/share/Steam/steamapps/common/Stardew\ Valley/Mods ; } # }}} # }}} coding projs # # school {{{ # alias sch="f ~/Documents/school" alias sta="f ~/Documents/school/sta" # 236 alias 236="f ~/Documents/school/236" alias a1="f ~/Documents/school/latex-notes/236/a1" # }}} school #