From 75e4d26f3979f1085785c083498a01a92e58c1b3 Mon Sep 17 00:00:00 2001 From: Abra Date: Sat, 30 Jun 2018 01:45:53 +0400 Subject: [PATCH] function rehaul --- .zprezto/runcoms/zalias | 58 +++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/.zprezto/runcoms/zalias b/.zprezto/runcoms/zalias index b532cc5..a01627e 100644 --- a/.zprezto/runcoms/zalias +++ b/.zprezto/runcoms/zalias @@ -60,6 +60,10 @@ alias tmuxr="tmux new -ADs auto-session" alias FUNCTION_PRELUDE="setopt LOCAL_OPTIONS PIPE_FAIL XTRACE ERR_RETURN" +is_local() { + [[ $(hostname) =~ '^abra0' ]] +} + publish() { FUNCTION_PRELUDE @@ -72,26 +76,12 @@ twitch() { livestreamer "http://www.twitch.tv/${1}" "${${@:2}:-best}" } -test_default() { - # echo "${@:-$(whoami) at $(date)}" - - for i in $@; do - echo "[$i]" - done -} - -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)}" -} - dcp() { FUNCTION_PRELUDE git add --all :/ - git commit -m "${@:-$(whoami) at $(date)}" + git commit -m "${*:-$(whoami) at $(date)}" git push } @@ -100,11 +90,9 @@ dcp() { .dcp() { FUNCTION_PRELUDE - local COMMIT_MESSAGE="${@:-$(whoami) at $(date)}" - .g add -u - .g commit -m "$COMMIT_MESSAGE" + .g commit -m "${*:-$(whoami) at $(date)}" .g push } @@ -147,13 +135,21 @@ rsync2() { --stats \ --fuzzy \ --verbose \ - "$@" + "${(@)@}" } sync_music() { FUNCTION_PRELUDE - rsync2 --delete dedi:/home/torrent-user/music-library/ /Users/abra/music/library/ + if ! is_local; then + echo "Should be local" + return 1 + fi + + rsync2 \ + --delete \ + "dedi:/home/torrent-user/music-library/" \ + "/Users/abra/music/library/" } # function .g-init() { @@ -165,9 +161,6 @@ sync_music() { # .g remote add origin ssh://dedi/var/www/git.abra.me/dot.git # } -is_local() { - [[ $(hostname) =~ '^abra0' ]] -} # make_user() { # FUNCTION_PRELUDE @@ -188,20 +181,33 @@ is_local() { # 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" local PRESET="${2:-"ultrafast"}" - local REST="${@:3}" + local REST=("${@:3}") - (ls "/mnt/a/snaps/$DATE" | wc -l) || return + ls "/mnt/a/snaps/$DATE" | wc -l ffmpeg \ -framerate 60 \ -pattern_type glob -i "/mnt/a/snaps/$DATE/*.jpg" \ -preset "$PRESET" \ - "$REST" \ + "${(@)REST}" \ -y "/mnt/a/$DATE.mp4" } \ No newline at end of file