diff --git a/.config/shell/browse b/.config/shell/browse index 7c24f51..63e7077 100644 --- a/.config/shell/browse +++ b/.config/shell/browse @@ -32,13 +32,19 @@ cd() { test -n "$dir" && cd "$dir" else 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 } # LOCATE 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 uloc='noglob sudo updatedb && loci' # locate exactly diff --git a/.config/shell/functions b/.config/shell/functions index 01c24a0..07bcccc 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -11,6 +11,7 @@ fi xdh="$XDG_DATA_HOME" xch="$XDG_CONFIG_HOME" +xsh="$XDG_STATE_HOME" if test -d "$DATA"; then da=$(builtin cd $DATA/_* && pwd) d1=$(builtin cd $DATA/1* && pwd) diff --git a/.local/bin/scripts/own b/.local/bin/scripts/own index c9a61ac..7077584 100755 --- a/.local/bin/scripts/own +++ b/.local/bin/scripts/own @@ -1,3 +1,3 @@ #!/bin/sh # Take ownership of the given files recursively -sudo chown -R --preserve-root $USER "$@" +sudo chown -R --preserve-root $USER:$USER "$@" diff --git a/.local/bin/scripts/sd b/.local/bin/scripts/sd index 0fa643a..4e85940 100755 --- a/.local/bin/scripts/sd +++ b/.local/bin/scripts/sd @@ -1,4 +1,11 @@ #!/bin/sh # 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}' diff --git a/.local/bin/scripts/tl b/.local/bin/scripts/tl index b504031..d697be3 100755 --- a/.local/bin/scripts/tl +++ b/.local/bin/scripts/tl @@ -1,3 +1,8 @@ #!/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 tree -a --dirsfirst -L ${depth:-3} --du -h -C "$@" | ${PAGER:-less}