config: script fixes

This commit is contained in:
xeruf 2022-01-05 17:53:06 +01:00
parent 75316b70c2
commit bdc2e2c94e
9 changed files with 41 additions and 30 deletions

View File

@ -203,7 +203,7 @@ alias usergroups="cat /etc/passwd | cut -d':' -f1 | xargs -n 1 id"
p() { pass "$@" || pass edit "$@"; } p() { pass "$@" || pass edit "$@"; }
alias omd="(echo '#+OPTIONS: tags:nil'; xclip -o -selection clipboard) | pandoc -f org-auto_identifiers -t markdown --wrap preserve | xclip -filter" alias omd="(echo '#+OPTIONS: tags:nil'; xclip -o -selection clipboard) | pandoc -f org-auto_identifiers -t markdown --wrap preserve | xclip -filter"
alias mdo="pandoc -f gfm-ascii_identifiers-gfm_auto_identifiers -t org --wrap preserve" alias mdo="pandoc -f gfm-ascii_identifiers-gfm_auto_identifiers -t org-auto_identifiers --wrap preserve"
alias mdox="xclip -o -selection clipboard | mdo | xclip -filter" alias mdox="xclip -o -selection clipboard | mdo | xclip -filter"
alias gdiff='git diff --word-diff=color --word-diff-regex=. --no-index' alias gdiff='git diff --word-diff=color --word-diff-regex=. --no-index'

View File

@ -2,7 +2,7 @@
#assume_yes = true #assume_yes = true
# Disable specific steps - same options as the command line flag # Disable specific steps - same options as the command line flag
disable = ["npm", "nix", "emacs"] disable = ["node", "pnpm", "nix", "emacs", "pacdiff"]
# Ignore failures for these steps # Ignore failures for these steps
#ignore_failures = ["powershell"] #ignore_failures = ["powershell"]

View File

@ -54,7 +54,8 @@ for arg; do
test -f "$tmpfile-1.png" || pdftoppm -r 70 "$arg" "$tmpfile" -l $(expr $grid '*' 2) test -f "$tmpfile-1.png" || pdftoppm -r 70 "$arg" "$tmpfile" -l $(expr $grid '*' 2)
timg -W --grid=$grid "$tmpfile"* timg -W --grid=$grid "$tmpfile"*
;; ;;
(*/x-xcf*) ;; (*/x-xcf*) convert -flatten "$arg" png:"$tmpfile"
timg+=("$tmpfile");;
(*\ video/*) (*\ video/*)
suffix=_thumbs.jpg suffix=_thumbs.jpg
mtn -i -t -W -r2 -D6 -b 0,6 -c $grid -w $(expr $(tput cols) '*' 20) \ mtn -i -t -W -r2 -D6 -b 0,6 -c $grid -w $(expr $(tput cols) '*' 20) \

View File

@ -3,9 +3,8 @@
typeset -A _clean_map typeset -A _clean_map
_clean_map=([h]=$XDG_CACHE_HOME [t]=/var/tmp [l]=/var/log [v]=/var/cache) _clean_map=([h]=$XDG_CACHE_HOME [t]=/var/tmp [l]=/var/log [v]=/var/cache)
# Directories to always clean _clean_home=(.ant .autopsy .bundle .cache .cargo .cpanm .docker .electron .electron-gyp .gradle .gradle-kotlin-dsl .hex .java .kscript .konan .m2 .mix .nix-defexpr .node-gyp .node_modules .npm .pnpm-store .nv .openjfx .parallel .stack .surf .texlive .yarn luametatex-cache
_clean_folders=(~/.ant ~/.autopsy ~/.bundle ~/.cache ~/.cargo ~/.cpanm ~/.docker ~/.electron ~/.electron-gyp ~/.gradle ~/.gradle-kotlin-dsl ~/.hex ~/.java ~/.kscript ~/.konan ~/.m2 ~/.mix ~/.nix-defexpr ~/.node-gyp ~/.npm ~/.nv ~/.openjfx ~/.parallel ~/.stack ~/.surf ~/.texlive ~/.yarn luametatex-cache .lesshst .python_history .rubberband.wisdom.d .yarnrc)
~/.lesshst ~/.rubberband.wisdom.d ~/.yarnrc)
[[ $1 =~ "." ]] && local=pwd [[ $1 =~ "." ]] && local=pwd
[[ $1 =~ "i" ]] && i=-i [[ $1 =~ "i" ]] && i=-i
@ -13,10 +12,10 @@ dir="$("$local" 2>/dev/null || echo "$HOME")"
df --output="source,avail" -h $(test -n "$local" && echo ".") "$dir" df --output="source,avail" -h $(test -n "$local" && echo ".") "$dir"
highlight "clean home" highlight "cleaning home"
for f in ${_clean_folders[@]} for f in ${_clean_home[@]}
do "$local" >/dev/null 2>&1 && f="$(echo "$f" | sed "s|$HOME|$($loc)|")" do path="$dir/$f"
test -f $f || test -d $f && echo "Removing superfluous $f" && rm -rf $i $f test -f "$path" || test -d "$path" && echo "Removing superfluous $path" && rm -rf $i "$path"
done done
find "$dir" -maxdepth 2 -not -name ".stfolder" -empty -printf "Removing empty %p\n" -delete find "$dir" -maxdepth 2 -not -name ".stfolder" -empty -printf "Removing empty %p\n" -delete

3
.local/bin/scripts/denest Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
# Remove one level of folders
find -mindepth 1 -maxdepth 1 -exec sh -c 'mv -nv {}/* . && rm -dv {}' \;

View File

@ -9,7 +9,7 @@ listconf() {
-maxdepth 4 -follow \( -name Partitions -o -name mdn -o -name .git -o -name .local -o -name plugged \) -prune -o \ -maxdepth 4 -follow \( -name Partitions -o -name mdn -o -name .git -o -name .local -o -name plugged \) -prune -o \
! -iname "*.markdown" -a ! -iname "*.md" -a ! -iname "*.org" \ ! -iname "*.markdown" -a ! -iname "*.md" -a ! -iname "*.org" \
-type f -readable -exec grep -lI '' {} + 2>/dev/null; -type f -readable -exec grep -lI '' {} + 2>/dev/null;
find /boot -name "*.c*"; find /boot -name "*.c*" 2>/dev/null;
} | dedup } | dedup
} }

View File

@ -3,15 +3,16 @@
# adapted and improved from the commonly circulating version # adapted and improved from the commonly circulating version
# detects whether unpacking into a subfolder is sensible # detects whether unpacking into a subfolder is sensible
# and shows progress indications for some operations # and shows progress indications for some operations
# optdepends: rewrite(in dotfiles) # optdepends: rewrite(part of my dotfiles)
for arg do for arg do
if test -r "$arg"; then if test -r "$arg"; then
path="$(realpath "$arg")" path="$(realpath "$arg")"
name="$(basename "${path%.*}")" name="$(basename "${path%.*}")"
namepart="$name.part"
( (
if test "$(ls -U | wc -l)" -gt 2; then if test "$(ls -U | wc -l)" -gt 2; then
mkdir -p "$name" mkdir -p "$namepart"
cd "$name" cd "$namepart"
fi fi
echo "Extracting $arg into $PWD" echo "Extracting $arg into $PWD"
case "$arg" in case "$arg" in
@ -28,8 +29,11 @@ for arg do
(*.Z) uncompress "$path";; (*.Z) uncompress "$path";;
(*) echo "'$arg' cannot be extracted by ex" >&2;; (*) echo "'$arg' cannot be extracted by ex" >&2;;
esac esac
test "$(ls -U | wc -l)" -lt 3 && test "$(basename "$PWD")" = "$namepart" &&
mv */* . && find -empty -delete if test "$(ls -U | wc -l)" -lt 3
then mv * .. && cd .. && rm -d "$namepart"
else mv "$namepart" "$name"
fi
) )
else else
echo "'$1' is not a readable file" echo "'$1' is not a readable file"

View File

@ -1,5 +1,7 @@
#!/bin/sh #!/bin/sh
# open info-page, man-page or command help # open info-page, man-page or command help
# depends: unbuffer
# optdepends: highlight(dotfiles)
paginate="${PAGER:-less} +Gg" paginate="${PAGER:-less} +Gg"
test "$1" = "-d" && browse=1 && shift test "$1" = "-d" && browse=1 && shift
# TODO resolve aliases # TODO resolve aliases
@ -9,11 +11,12 @@ case $1 in
# need to install zsh-doc package for info pages # need to install zsh-doc package for info pages
info --vi-keys "$(test "$last" != zsh && echo "--index-search=$last")" zsh || info --vi-keys "$(test "$last" != zsh && echo "--index-search=$last")" zsh ||
LESS="$LESS +/^ *$last *\\[" man zshall;; LESS="$LESS +/^ *$last *\\[" man zshall;;
(vlc) unbuffer vlc --full-help "${@:2}" | $paginate;; (gh|chordpro|bat|pdfjam|reflector|topgrade) unbuffer "$@" --help | $paginate;;
(gh|chordpro|bat|pdfjam|reflector) unbuffer "$@" --help | $paginate;;
(plantuml) unbuffer "$@" -help | $paginate;;
(caddy|stretchly|go) "$1" help "${@:2}" | $paginate;; (caddy|stretchly|go) "$1" help "${@:2}" | $paginate;;
(plantuml) unbuffer "$@" -help | $paginate;;
(kdeconnect*) kdeconnect-cli --help-all "${@:2}" | $paginate;; (kdeconnect*) kdeconnect-cli --help-all "${@:2}" | $paginate;;
(vlc) unbuffer vlc --full-help "${@:2}" | $paginate;;
(pandoc) man pandoc; highlight "Extensions" && pandoc --list-extensions;;
(*) man "$@" || (*) man "$@" ||
{ info "$1" -w | grep -v "manpages" && pinfo "$@"; } || { info "$1" -w | grep -v "manpages" && pinfo "$@"; } ||
if which "$1" >/dev/null; then "$@" --help; "$@" -help 2>&1 | $paginate; fi;; if which "$1" >/dev/null; then "$@" --help; "$@" -help 2>&1 | $paginate; fi;;

View File

@ -1,18 +1,19 @@
#!/bin/sh #!/bin/sh -e
# Remove recursively safely # Remove recursively safely
case "$1" in ([0-9]) depth=$1; shift;; esac case "$1" in ([0-9]) depth=$1; shift;; esac
for f in "${@-.}" for f in "${@-.}"
do do
test -w "$f" && elevate="" || elevate=sudo test -w "$f" && elevate="" || elevate=sudo
if test -d "$f"; then if test -d "$f"
find "$f" -maxdepth 4 -not -name ".stfolder" -empty -printf "Removing empty %p\n" -delete then find "$f" -maxdepth 4 -not -name ".stfolder" -empty -printf "Removing empty %p\n" -delete
test $# -eq 0 && exit $?
if test -e "$f/.git" || test -e "$f/packed-refs" if test -e "$f/.git" || test -e "$f/packed-refs"
then echo -n "Force delete git project $f? " then echo -n "Force delete git project $f? "
read answer read answer
test "$answer" = "y" && test "$answer" = "y" &&
$elevate rm -rf "$f" $elevate rm -rf "$f"
else test -e "$f" && else test -e "$f" &&
echo -n "$f ($(ls -A $f | head -3 | paste -s -d' ')) " >&2 && echo -n "$f ($(ls -A "$f" | head -3 | paste -s -d' ')) " >&2 &&
$elevate rm -rI "$f" $elevate rm -rI "$f"
fi fi
else $elevate rm -i "$f" else $elevate rm -i "$f"