From 4b1a2f91db628633b4d6366f11e1396eeafae61d Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Tue, 24 May 2022 19:44:36 +0200 Subject: [PATCH] bin: extend usecases handled by some scripts - git-fuzz can also handle deletions - kover takes a parameter --- .local/bin/scripts/b | 2 +- .local/bin/scripts/git-fuzz | 9 +++++---- .local/bin/scripts/{kver => kover} | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) rename .local/bin/scripts/{kver => kover} (70%) diff --git a/.local/bin/scripts/b b/.local/bin/scripts/b index 9a37dda..1aeafc9 100755 --- a/.local/bin/scripts/b +++ b/.local/bin/scripts/b @@ -183,7 +183,7 @@ if test "$ls" -o $# -le $(echo "$flags" | wc -w); then { timeout .6s sh -c " if which exa 2>/dev/null >&2 - then exa --color=always --long --group --classify --group-directories-first --all --all $flags $(printf "'%s' " "${ls[@]:-.}") + then exa --color=always --long --group --classify --all --all --sort=changed --reverse $flags $(printf "'%s' " "${ls[@]:-.}") else $elevate ls -l $(test $# -gt ${#ls[@]} && echo '-d') --color=always --human-readable --si --group-directories-first --file-type --dereference-command-line-symlink-to-dir --all $flags $(printf "'%s' " "${ls[@]:-.}") fi " || $elevate ls $(test $# -gt ${#ls[@]} && echo "-d") --color=always --human-readable --si --dereference-command-line --all --sort=none $flags "${ls[@]:-.}" diff --git a/.local/bin/scripts/git-fuzz b/.local/bin/scripts/git-fuzz index 519edd1..654aa74 100755 --- a/.local/bin/scripts/git-fuzz +++ b/.local/bin/scripts/git-fuzz @@ -1,9 +1,9 @@ #!/bin/sh -e # Create a commit or stage files via fzf selection # If the first arg is "add", files are staged rather than committed. -# All remaining args are passed to git-commit +# All remaining args are passed to the last git command (add or commit). # TODO fix broken prep-commit-msg hook when there is no unifying path -# fix broken alt-enter not opening editor --bind='alt-enter:change-prompt(hi>)' +# TODO fix broken alt-enter not opening editor --bind='alt-enter:change-prompt(hi>)' fzfpipe() { # Take nul-separated input from git-status short/porcelain @@ -22,9 +22,10 @@ case "$1" in (add) shift git status -z --porcelain --no-renames --untracked-files=all $wd | grep -zv '^\\w ' | fzfpipe | - git -c advice.addEmptyPathspec=false add --verbose --pathspec-from-file=- "$@";; + xargs -d '\n' -L 1 git -c advice.addEmptyPathspec=false add --verbose "$@";; (*) git status -z --porcelain --no-renames $wd | sed -z 's/^\\(\\w\\) / \\1/' | fzfpipe >"$prefix/files" - git -c advice.addEmptyPathspec=false add --intent-to-add --pathspec-from-file="$prefix/files" + cat "$prefix/files" | xargs -d '\n' ls -fd 2>/dev/null >"$prefix/files-existing" || true + git -c advice.addEmptyPathspec=false add --intent-to-add --pathspec-from-file="$prefix/files-existing" git commit -v --only --pathspec-from-file="$prefix/files" "$@";; esac diff --git a/.local/bin/scripts/kver b/.local/bin/scripts/kover similarity index 70% rename from .local/bin/scripts/kver rename to .local/bin/scripts/kover index a737f57..bf8ed46 100755 --- a/.local/bin/scripts/kver +++ b/.local/bin/scripts/kover @@ -1,6 +1,6 @@ #!/bin/sh # Prints the latest Gradle and Kotlin versions highlight "Kotlin" -curl https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/maven-metadata.xml 2>/dev/null | grep 'version>' | grep -iv '\(m\|rc\)' | sed 's/.*>\(.*\)<.*/\1/' | tail -6 +curl https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/maven-metadata.xml 2>/dev/null | grep 'version>' | grep -iv '\(m\|rc\)' | sed 's/.*>\(.*\)<.*/\1/' | tail -${1:-6} highlight "Gradle" -curl https://services.gradle.org/distributions/ 2>/dev/null | grep 'name.*all.*sha' | grep -v rc | head -6 | cut -d- -f2 +curl https://services.gradle.org/distributions/ 2>/dev/null | grep 'name.*all.*sha' | grep -v rc | head -${1:-6} | cut -d- -f2