From f879fabc5319afd2578113fa28dabd9ce9a4c77e Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Tue, 11 Jan 2022 13:23:56 +0100 Subject: [PATCH] bin: adjust extra script features --- .config/shell/functions | 2 +- .local/bin/scripts/git-fork | 12 +++++++----- .local/bin/scripts/predate | 3 ++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.config/shell/functions b/.config/shell/functions index bab085d..c4700e1 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -182,11 +182,11 @@ alias lar='last | tac' alias lst='( last; last -f /var/log/wtmp.1 ) | grep -v "pts/" | tac | less +G' u() { - topgrade --only emacs --yes which pacman-mirrors >/dev/null && sudo pacman-mirrors --geoip && sudo pacman -Syy topgrade + topgrade --only emacs --yes } # Remote diff --git a/.local/bin/scripts/git-fork b/.local/bin/scripts/git-fork index 7dbb1df..d1cb1d5 100755 --- a/.local/bin/scripts/git-fork +++ b/.local/bin/scripts/git-fork @@ -1,15 +1,17 @@ #!/bin/sh -e # Clones a fork and sets a corresponding upstream # ARGS -# - repo name +# - repo name (omit if setting upstream in existing repo) # - upstream user # - local user # - url # - target directory name (and further arguments to clone) if test -d ".git" - then git remote set-url origin "$(git-repo "${4:-github.com}" "$1" "$3" "${@:5}")" - else git-get "${4:-github.com}" "$1" "$3" "${@:5}" - cd $(expr "$5" \| "$1") +then repo="$(basename "$PWD")" + git remote set-url origin "$(git-repo "${3:-github.com}" "$repo" "$2" "${@:4}")" +else repo="$1" + git-get "${3:-github.com}" "$repo" "$2" "${@:4}" + cd $(expr "$5" \| "$1") fi -test "$2" && git remote add upstream "$(git-repo "${4:-github.com}" "$1" "$2")" +test "$1" && git remote add upstream "$(git-repo "${3:-github.com}" "$repo" "$1")" git remote -v diff --git a/.local/bin/scripts/predate b/.local/bin/scripts/predate index bc13e67..b68f189 100755 --- a/.local/bin/scripts/predate +++ b/.local/bin/scripts/predate @@ -1,8 +1,9 @@ #!/bin/sh -e # Add the modification date in front of the filename IFS='\n' +test "$1" = -s && short=true && shift for file do mv --verbose --interactive "$file" \ - "$(latest "$file" | head -2 | tail -1 | cut -d'+' -f1)_$(echo "$file" | sed 's/20\([0-9]\{2\}\)-\([0-9]\{2\}\)\(-[0-9]\{2\}\)\?_\?//')" + "$(latest "$file" | head -2 | tail -1 | cut -c$(test "$short" && echo "3,4,6,7,9,10" || echo "-10"))_$(echo "$file" | sed 's/2\?\([0-9]\{2,3\}\)-\([0-9]\{2\}\)\(-[0-9]\{2\}\)\?_\?//')" done # stat --format %y "$file" | cut -d' ' -f1