From c44400ed529624172b07b7dd3bc436ea5bd399fd Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Tue, 3 May 2022 11:22:10 +0200 Subject: [PATCH] bin: tweaks --- .local/bin/scripts/b | 10 ++++++---- .local/bin/scripts/diff-color | 2 +- .local/bin/scripts/git-aur | 2 +- .local/bin/scripts/git-fuzz | 2 +- .local/bin/scripts/git-ln | 2 +- .local/bin/scripts/m | 2 +- .local/bin/scripts/pdiff | 2 +- .local/bin/scripts/sign | 2 +- 8 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.local/bin/scripts/b b/.local/bin/scripts/b index 939d50a..1ee1521 100755 --- a/.local/bin/scripts/b +++ b/.local/bin/scripts/b @@ -85,7 +85,7 @@ for arg; do test -L "$arg" || continue ;; (*) - case "$(file "$arg")" in + case "$(file --dereference "$arg")" in (*\ ?udio*) # TODO preconvert aac - |*\ ADTS\ * img="$tmpfile.png" @@ -112,6 +112,7 @@ for arg; do esac; fi ;; (*:\ *database*) highlight "Tables" && sqlite3 "$arg" ".tables";; + (*:\ data) ;; (*) bat+=("$arg") timga+=("$arg") continue;; @@ -172,11 +173,12 @@ if test "$ls" -o $# -le $(echo "$flags" | wc -w); then checkperm . # Alternative: find -exec ls -dl {} + { + # TODO don't use * for ls array as spaces go awry timeout .1s sh -c " if which exa 2>/dev/null >&2 - then exa --color=always --long --group --classify --group-directories-first --all --all $flags '${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 '${ls[@]:-.}' + then exa --color=always --long --group --classify --group-directories-first --all --all $flags ${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 ${ls[*]:-.} fi " || $elevate ls $(test $# -gt ${#ls[@]} && echo "-d") --color=always --human-readable --si --dereference-command-line --all --sort=none $flags "${ls[@]:-.}" - } | $pager + } | $pager --quit-if-one-screen fi diff --git a/.local/bin/scripts/diff-color b/.local/bin/scripts/diff-color index 3a84074..3a0371e 100755 --- a/.local/bin/scripts/diff-color +++ b/.local/bin/scripts/diff-color @@ -1,4 +1,4 @@ #!/bin/sh # Colorize with diffr -diff --color=always -U 2 "$@" | +diff --color=always --unified=2 "$@" | diffr --colors refine-added:none:background:0x33,0x66,0x33:bold --colors added:none:background:0x33,0x44,0x33 --colors refine-removed:none:background:0x66,0x33,0x33:bold --colors removed:none:background:0x44,0x33,0x33 diff --git a/.local/bin/scripts/git-aur b/.local/bin/scripts/git-aur index ddd8948..1528701 100755 --- a/.local/bin/scripts/git-aur +++ b/.local/bin/scripts/git-aur @@ -22,7 +22,7 @@ case "$command" in (commit) makepkg --printsrcinfo > .SRCINFO git add -f .SRCINFO - git commit -v "$@" + git commit -v "$@";; (push) updpkgsums git add -f *.install 2>/dev/null || true diff --git a/.local/bin/scripts/git-fuzz b/.local/bin/scripts/git-fuzz index 0a31c65..519edd1 100755 --- a/.local/bin/scripts/git-fuzz +++ b/.local/bin/scripts/git-fuzz @@ -10,7 +10,7 @@ fzfpipe() { # and return a newline-separated list of selected files cut -z -c2- | git fzf-diff --read0 -d' ' --nth=2.. --bind="alt-enter:execute($EDITOR '$(git rev-parse --show-toplevel)/{2..}')" \ - --preview="test {1} != \? && git diff --color HEAD -U5 -- {2..} | $(git config interactive.diffFilter) || find {2..} -type f | xargs -I% diff --recursive --color=always -u /dev/null %" | + --preview="test {1} != \? && git diff --color HEAD --unified=4 -- {2..} | $(git config interactive.diffFilter) || find {2..} -type f | xargs -I% diff --recursive --color=always -u /dev/null %" | cut -c3- } diff --git a/.local/bin/scripts/git-ln b/.local/bin/scripts/git-ln index ed7a8cc..e557e39 100755 --- a/.local/bin/scripts/git-ln +++ b/.local/bin/scripts/git-ln @@ -2,4 +2,4 @@ set -o pipefail upCount=$(git rev-list --count HEAD...@{push} 2>/dev/null) count=$(expr ${upCount:-0} + 3 \& ${upCount:-0} \> 3 \& ${upCount:-0} \< 6 \| 6) -git --no-pager lo -$count --color=always --graph HEAD @{upstream} || git --no-pager lo -7 +git --no-pager lo -$count --color=always --graph HEAD @{upstream} "$@" || git --no-pager lo -7 "$@" diff --git a/.local/bin/scripts/m b/.local/bin/scripts/m index e6a18cc..4d344f2 100755 --- a/.local/bin/scripts/m +++ b/.local/bin/scripts/m @@ -7,7 +7,7 @@ checkaccess -w "$@" || elevate=sudo ! $elevate test -e "$1" && echo "$1 does not exist" && exit 1 dir="$(dirname "$1")" -test "$(lsattr -d "$dir" | cut -c6 2>/dev/null)" = a && setappend=true +test "$(lsattr -d "$dir" 2>/dev/null | cut -c6)" = a && setappend=true test -z "$setappend" || sudo chattr -V -a "$dir" $elevate mkdir -p $(case "$last" in (*/) echo "$last";; (*) dirname "$last";; esac) diff --git a/.local/bin/scripts/pdiff b/.local/bin/scripts/pdiff index 5d95a19..8fce8f2 100755 --- a/.local/bin/scripts/pdiff +++ b/.local/bin/scripts/pdiff @@ -1,3 +1,3 @@ #!/bin/sh # Diff project directories, excluding any generated content -diff-color -r $DIRS_IGNORE "$@" | less -F +diff-color --recursive $DIRS_IGNORE "$@" | less -F diff --git a/.local/bin/scripts/sign b/.local/bin/scripts/sign index 9bc3309..0f3d227 100755 --- a/.local/bin/scripts/sign +++ b/.local/bin/scripts/sign @@ -13,7 +13,7 @@ sig=$tmp_base/signature_offset.pdf result="${1%.pdf}_${5:-signed}.pdf" pdfjam $quiet "$signature" --outfile "$sig" --papersize "{595pt, 842pt}" --noautoscale true \ - --offset "${2:-0}pt ${3:-0}pt" --scale "${4:-1}" + --offset "${2:--160}pt ${3:--310}pt" --scale "${4:-1}" pdfjam $quiet "$1" last "$sig" --outfile "$tmp_signed" --delta "0 -842pt" --nup "1x2" --fitpaper true timg "$tmp_signed"