diff --git a/.zprezto/runcoms/zalias b/.zprezto/runcoms/zalias index 00b219d..b532cc5 100644 --- a/.zprezto/runcoms/zalias +++ b/.zprezto/runcoms/zalias @@ -41,6 +41,7 @@ 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])' @@ -57,50 +58,81 @@ alias tmuxr="tmux new -ADs auto-session" # ===== FUNCTIONS ===== -function publish() { - rsyncc $@ "dedi:/var/www/abra.me/list/" +alias FUNCTION_PRELUDE="setopt LOCAL_OPTIONS PIPE_FAIL XTRACE ERR_RETURN" + +publish() { + FUNCTION_PRELUDE + + rsync2 "$@" "dedi:/var/www/abra.me/list/" } -function publishwhere() { - rsyncc ${@:2} "dedi:/var/www/abra.me/$1" +twitch() { + FUNCTION_PRELUDE + + livestreamer "http://www.twitch.tv/${1}" "${${@:2}:-best}" } -function twitch() { - local arg=${@:2} - local arg=${arg:-best} - livestreamer "http://www.twitch.tv/$1" $arg +test_default() { + # echo "${@:-$(whoami) at $(date)}" + + for i in $@; do + echo "[$i]" + done } -function dcp() { - local arg=$@ - - if [[ -z $arg ]]; then - local arg="$(whoami) at $(date)" - fi - - a || return 1 - - git commit -m "$arg" || return 1 - - git push || return 1 +test_default2() { + test_default git commit -m "${@:-$(whoami) at $(date)}" + test_default .g commit -m "${@:-$(whoami) at $(date)}" + test_default .g commit -m "${@:-$(whoami) at $(date)}" } -function strip-tags() { +dcp() { + FUNCTION_PRELUDE + + git add --all :/ + + git commit -m "${@:-$(whoami) at $(date)}" + + git push +} + + +.dcp() { + FUNCTION_PRELUDE + + local COMMIT_MESSAGE="${@:-$(whoami) at $(date)}" + + .g add -u + + .g commit -m "$COMMIT_MESSAGE" + + .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 } -function dedi-beet() { - ssh dedi -- sudo -u torrent-user beet $@ +dedi-beet() { + FUNCTION_PRELUDE + + ssh dedi -- sudo -u torrent-user beet "$@" } -function beet-comments() { +beet-comments() { + FUNCTION_PRELUDE + + : "${1:?who?}" + : "${2:?what?}" + dedi-beet modify "comments='$2'" "albumartist:'$1'" } -function rsync2() { - #rsync -rzPh -u --no-W +rsync2() { rsync \ --info=PROGRESS2 \ --progress \ @@ -115,80 +147,61 @@ function rsync2() { --stats \ --fuzzy \ --verbose \ - $@ - + "$@" } -function sync-music() { +sync_music() { + FUNCTION_PRELUDE + rsync2 --delete dedi:/home/torrent-user/music-library/ /Users/abra/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 -} +# 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 +# } -function is_local() { +is_local() { [[ $(hostname) =~ '^abra0' ]] } -function make_user() { - if is_local; then - echo "You're local" - return 1 - fi +# make_user() { +# FUNCTION_PRELUDE - adduser --system --shell /bin/zsh --disabled-password $1 || return 1 +# if is_local; then +# echo "You're local" +# return 1 +# fi - 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/ -} +# adduser --system --shell /bin/zsh --disabled-password $1 || return 1 -function latest() { - echo -n ("${(@f)$(ls *(om[1,$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 testo() { - # set -eux - # set -o pipefail - - # set -exo pipefail - setopt ERR_RETURN - d - sadsa - - ls -} - -function testo2() { - # set -eux - # set -o pipefail - - # set -exo pipefail - sadsa - - ls -} +# function latest() { +# echo -n ("${(@f)$(ls *(om[1,$1]))}") +# } -function ffmpeg_timelapse() { - local DATE=$1 - local PRESET=$2 +ffmpeg_timelapse() { + FUNCTION_PRELUDE - if [[ -z $PRESET ]]; then - local PRESET="ultrafast" - fi + local DATE="$1" + local PRESET="${2:-"ultrafast"}" + local REST="${@:3}" - ls /mnt/a/snaps/$DATE | wc -l || return + (ls "/mnt/a/snaps/$DATE" | wc -l) || return ffmpeg \ -framerate 60 \ -pattern_type glob -i "/mnt/a/snaps/$DATE/*.jpg" \ - -preset $PRESET \ + -preset "$PRESET" \ + "$REST" \ -y "/mnt/a/$DATE.mp4" } \ No newline at end of file