bin: adjust extra script features

This commit is contained in:
xeruf 2022-01-11 13:23:56 +01:00
parent bef11c21a1
commit f879fabc53
3 changed files with 10 additions and 7 deletions

View File

@ -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

View File

@ -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

View File

@ -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