bin: adjust scripts

most notably move sd to use lsblk
This commit is contained in:
xeruf 2021-11-07 06:00:29 +01:00
parent 2b4a5508ab
commit 47ed53c0a6
5 changed files with 24 additions and 5 deletions

View File

@ -32,13 +32,19 @@ cd() {
test -n "$dir" && cd "$dir" test -n "$dir" && cd "$dir"
else else
builtin cd $1 && builtin cd $1 &&
command ls --file-type --group-directories-first --color=always --format=vertical -w $COLUMNS | head -3 command ls --literal --file-type --color=always --format=vertical -U -w $COLUMNS |
#pr -4 -l1 -W $COLUMNS -S" " |
head -3
code=$? && test $code -eq 141 || return $code
fi fi
} }
# LOCATE # LOCATE
alias fselect='fzf -0 -1 --reverse --height=30%' alias fselect='fzf -0 -1 --reverse --height=30%'
loci() { locate --all --ignore-case --basename --existing "$@" | command grep --extended-regexp --ignore-case --color=always $(echo "$|${@:$#}" | sed 's/ /|/g') | fselect } loci() {
locate --all --ignore-case --basename --existing "$@" |
command grep --extended-regexp --ignore-case --color=always $(echo "$|${@:$#}" | sed 's/ /|/g') | fselect
}
alias loc='noglob loci' alias loc='noglob loci'
alias uloc='noglob sudo updatedb && loci' alias uloc='noglob sudo updatedb && loci'
# locate exactly # locate exactly

View File

@ -11,6 +11,7 @@ fi
xdh="$XDG_DATA_HOME" xdh="$XDG_DATA_HOME"
xch="$XDG_CONFIG_HOME" xch="$XDG_CONFIG_HOME"
xsh="$XDG_STATE_HOME"
if test -d "$DATA"; then if test -d "$DATA"; then
da=$(builtin cd $DATA/_* && pwd) da=$(builtin cd $DATA/_* && pwd)
d1=$(builtin cd $DATA/1* && pwd) d1=$(builtin cd $DATA/1* && pwd)

View File

@ -1,3 +1,3 @@
#!/bin/sh #!/bin/sh
# Take ownership of the given files recursively # Take ownership of the given files recursively
sudo chown -R --preserve-root $USER "$@" sudo chown -R --preserve-root $USER:$USER "$@"

View File

@ -1,4 +1,11 @@
#!/bin/sh #!/bin/sh
# disk size usage information # disk size usage information
df -B1M -x tmpfs -x devtmpfs -x squashfs | awk -v a="\033[31m" -v b="\033[33m" -v c="\033[35m" -v n="\033[0m" 'NR==1 {printf "%-20s %6s %7s %9s %s\n",$1,$5,$3,$4,$6} NR>1 {u=strtonum($5); printf (u > 99) ? a : (u > 97) ? b : (u > 94) ? c : ""; printf "%-20s %6s %6.1fG %8.1fG %s\n",$1,$5,$3/1000,$4/1000,$6; printf n}' IFS="\n"
cols=$(tput cols)
lsblk --output name,size,fsuse%,mountpoints,label$(test $cols -gt 110 && echo ',uuid,fstype') --width $cols |
while read line
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"
first=1
done
# df -B1M -x tmpfs -x devtmpfs -x squashfs | awk -v a="\033[31m" -v b="\033[33m" -v c="\033[35m" -v n="\033[0m" 'NR==1 {printf "%-20s %6s %7s %9s %s\n",$1,$5,$3,$4,$6} NR>1 {u=strtonum($5); printf (u > 99) ? a : (u > 97) ? b : (u > 94) ? c : ""; printf "%-20s %6s %6.1fG %8.1fG %s\n",$1,$5,$3/1000,$4/1000,$6; printf n}'

View File

@ -1,3 +1,8 @@
#!/bin/sh #!/bin/sh
# List files recursively with [dirsfirst] including hidden files (-a)
# showing sizes of directories (--du) and files in [h]uman readable form
# with forced [C]olorization and pipe into less
# If first arg is a digit, it displaces the default depth of 3
# Any other arguments (usually pathnames) are passed on to the tree command
case "$1" in [0-9]) depth=$1; shift;; esac case "$1" in [0-9]) depth=$1; shift;; esac
tree -a --dirsfirst -L ${depth:-3} --du -h -C "$@" | ${PAGER:-less} tree -a --dirsfirst -L ${depth:-3} --du -h -C "$@" | ${PAGER:-less}