bin: various little script fixes

This commit is contained in:
xeruf 2022-01-15 22:01:18 +01:00
parent 3509d68b75
commit 122a4bfad7
5 changed files with 11 additions and 3 deletions

View File

@ -6,7 +6,7 @@ if test "$1" = "f"
else else
IFS="\n" IFS="\n"
cols=$(tput cols) cols=$(tput cols)
lsblk --output name,size,fsavail,fsuse%,mountpoints,label,fstype$(test $cols -gt 110 && echo ',uuid') --width $cols | lsblk --output name,size,fsavail,fsuse%,mountpoints,label,fstype$(test $cols -gt 120 && echo ',uuid') --width $cols |
while read line while read line
do p=$(echo "$line" | sed 's|.* \([[:digit:]]\+\)%.*|\1|;t;c0') do p=$(echo "$line" | sed 's|.* \([[:digit:]]\+\)%.*|\1|;t;c0')
printf "$(expr "$line" : " " >/dev/null || echo "\033[$(test -z "$first" && echo "4" || expr "5;31" \& "$p" \> 98 \| "31" \& "$p" \> 97 \| "33" \& "$p" \> 94 \| "35" \& "$p" \> 90)m")%s\n" "$line" printf "$(expr "$line" : " " >/dev/null || echo "\033[$(test -z "$first" && echo "4" || expr "5;31" \& "$p" \> 98 \| "31" \& "$p" \> 97 \| "33" \& "$p" \> 94 \| "35" \& "$p" \> 90)m")%s\n" "$line"

View File

@ -1,5 +1,6 @@
#!/bin/sh -e #!/bin/sh -e
# Mount a partition by label or device identifier automatically # Mount a partition by label or device identifier automatically
# TODO Autocomplete: lsblk --output label --noheadings
arg=$1 arg=$1
test "$arg" = "--help" && echo "$0 <device> [mountpoint] [options...]" && exit 0 test "$arg" = "--help" && echo "$0 <device> [mountpoint] [options...]" && exit 0
if test "$arg" = "-u" if test "$arg" = "-u"

7
.local/bin/scripts/plantclip Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
# plantuml from xclip selection clipboard
file="/tmp/plantuml-xclip-$(date +%s).plantuml"
echo "@startuml" >$file
xclip -o >>$file
echo -e "\n@enduml" >>$file
plantuml $file

View File

@ -12,7 +12,7 @@ do
test "$answer" = "y" && test "$answer" = "y" &&
$elevate rm -rf "$f" $elevate rm -rf "$f"
else else
find "$f" -maxdepth 4 -not -name ".stfolder" -empty -printf "Removing empty %p\n" -delete $elevate find "$f" -maxdepth 4 -not -name ".stfolder" -empty -printf "Removing empty %p\n" -delete
test $# -eq 0 && exit $? test $# -eq 0 && exit $?
if test -e "$f"; then if test -e "$f"; then
echo -n "$f ($(ls -A "$f" | head -3 | paste -s -d' ')) " >&2 && echo -n "$f ($(ls -A "$f" | head -3 | paste -s -d' ')) " >&2 &&

View File

@ -1,3 +1,3 @@
#!/bin/sh #!/bin/sh
# Pipe a command into this and each output line will rewrite the previous one # Pipe a command into this and each output line will rewrite the previous one
sed --unbuffered '2,$s|^|\\e[1A\\e[K|' | xargs -d '\n' -L 1 echo -e sed --unbuffered '2,$s|^|\\e[1A\\e[K|' | cut -c-$(tput cols) | xargs -d '\n' -L 1 echo -e