# ===== ALIASES ===== alias g="git" alias a="git add --all :/" alias b="git branch" alias c="git commit -am" alias ch="git checkout" alias pull="git pull" alias rb="git reset HEAD --hard" alias s="git status" alias st="git stash" # alias g5="git5" # alias e="git5 export" # alias m="git5 merge --no-ff" # alias ma="git5 mail -m" # alias push="git5 submit -xy" # alias push="git submit -xy" alias dc="a && c \"dummy comment\"" # alias dcp="a; dc; git push" alias zshconfig="subl ~/.zshrc" alias zshreload="exec zsh" alias tarc="tar cvzf" # alias rcp="rsync --partial --progress --append --rsh=ssh -r -h" # alias rmv="rsync --partial --progress --append --rsh=ssh -r -h --remove-sent-files" # alias rsyncc="rsync -rzPhc" alias pythonserve="sudo python -m SimpleHTTPServer 80" # replace alias sg='perl -0pe' # alias clbin="curl -F 'clbin=<-' https://clbin.com" #alias afs="unmount-abra0; mount-abra0;" alias .g='git --git-dir=$HOME/.dotgit/ --work-tree=$HOME' alias .gs='.g status -uno' alias .gp='.g commit -am "auto" && .g push' alias p="perl -pe" alias p0="perl -0pe" alias -g LATEST='*(om[1])' #alias f1sql="/google/data/ro/projects/storage/f1/tools/f1-sql" #alias t="task" #alias revs="ssh abra0 'tail -f -n0 ~/reverse_shell' | tee -a .rem_history| zsh -s" #alias nika_pop="echo \"afplay ~/tmp/nika.mp3\" > ~/reverse_shell" # remote tmux on server alias tmuxr="tmux new -ADs auto-session" # ===== FUNCTIONS ===== alias FUNCTION_PRELUDE="setopt LOCAL_OPTIONS PIPE_FAIL XTRACE ERR_RETURN" is_local() { [[ $(hostname) =~ '^abra0' ]] } publish() { FUNCTION_PRELUDE rsync2 "$@" "dedi:/var/www/abra.me/list/" } twitch() { FUNCTION_PRELUDE livestreamer "http://www.twitch.tv/${1}" "${${@:2}:-best}" } dcp() { FUNCTION_PRELUDE git add --all :/ git commit -m "${*:-$(whoami) at $(date)}" git push } .dcp() { FUNCTION_PRELUDE .g add -u .g commit -m "${*:-$(whoami) at $(date)}" .g push } strip-tags() { FUNCTION_PRELUDE find . -type f -name '*.mp3' \ | tr '\n' '\0' \ | xargs -0 -n1 mid3v2 --delete-frames=TXXX,USLT,TIPL,UFID,APIC,TBPM,TCMP,TDOR,TDRC,TLAN,TMED,TPOS,TPUB,TRCK,TCON } dedi-beet() { FUNCTION_PRELUDE ssh dedi -- sudo -u torrent-user beet "$@" } beet-comments() { FUNCTION_PRELUDE : "${1:?who?}" : "${2:?what?}" dedi-beet modify \'"comments=$2"\' \'"albumartist::$1"\' } rsync2() { rsync \ --info=PROGRESS2 \ --progress \ --recursive \ --compress \ --human-readable \ --update \ --times \ --no-whole-file \ --itemize-changes \ --stats \ --verbose \ --links \ "${(@)@}" } sync-music() { FUNCTION_PRELUDE # if ! is_local; then # echo "Should be local" # return 1 # fi mkdir -p "$HOME/music/library" rsync2 \ --delete \ "dedi:/home/torrent-user/music-library/" \ "$HOME/music/library/" } # function .g-init() { # git init --bare $HOME/.dotgit # .g config --local status.showUntrackedFiles no # .g remote add origin ssh://dedi/root/.dotgit # git config --global user.name "Your Name" # git config --global user.email you@example.com # .g remote add origin ssh://dedi/var/www/git.abra.me/dot.git # } # make_user() { # FUNCTION_PRELUDE # if is_local; then # echo "You're local" # return 1 # fi # adduser --system --shell /bin/zsh --disabled-password $1 || return 1 # # wget abra.me/.dotfiles.tar.gz -O /home/$1/.dotfiles.tar.gz # # tar xf /home/$1/.dotfiles.tar.gz -C /home/$1 # # chown $1:nogroup -R /home/$1/ # } # function latest() { # echo -n ("${(@f)$(ls *(om[1,$1]))}") # } testo() { local A="${@[2,3]}" ./t.py ${(t)A} "$A" ${A[@]} unset A local A=("$@[2,3]") ./t.py ${(t)A} "$A" ${A[@]} unset A ./t.py "$@[2,3]" } # testo 1 "2 3" 4 # shit shit shit s hist h is htisthsi 2018-06-30 ffmpeg_timelapse() { FUNCTION_PRELUDE local DATE="$1" ls "/mnt/a/snaps/$DATE" | wc -l ffmpeg \ -framerate 60 \ -pattern_type glob -i "/mnt/a/snaps/$DATE/*.jpg" \ "${@:2}" \ -y "/mnt/a/tmp/$DATE.mp4" mv "/mnt/a/tmp/$DATE.mp4" "/mnt/a/$DATE.mp4" rm -rf "/mnt/a/snaps/$DATE" } ffmpeg_timelapse_today() { local TODAY=$(date '+%Y-%m-%d') ffmpeg_timelapse "$TODAY" -preset ultrafast -crf 20 } update_.g() { local RES=$(.g pull 2>&1) if [[ ! ($RES =~ "Already up.to.date") ]]; then echo "Updated .g" echo $RES echo "======" echo fi }