config: improve compatibility

This commit is contained in:
xeruf 2022-01-21 19:57:10 +01:00
parent 9b81c98adc
commit 0f210bd7db
3 changed files with 7 additions and 5 deletions

View File

@ -1,4 +1,5 @@
command! PU PlugUpdate | PlugUpgrade
command! PU PlugClean | PlugUpdate | PlugUpgrade
" TODO Automatically do this in topgrade
" TODO auto-update on start/error

View File

@ -1,12 +1,12 @@
#!/bin/sh
# [d]ist [s]ize usage and partition overview
# [d]isk [s]ize usage and partition overview
# For an accurate usage percentage add "f" as argument which uses "df"
if test "$1" = "f"
then 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/1024,$4/1024,$6; printf n}'
else
IFS="\n"
cols=$(tput cols)
lsblk --output name,size,fsavail,fsuse%,mountpoints,label,fstype$(test $cols -gt 120 && echo ',uuid') --width $cols |
test "$(lsblk --version | cut -d. -f2)" -ge 37 && width="--width" && cols=$(tput cols) && outcols="s"
lsblk --output name,size,fsavail,fsuse%,mountpoint$outcols,label,fstype$(test "${cols:-0}" -gt 120 && echo ',uuid') $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"

View File

@ -27,7 +27,8 @@ case "$sel" in
(/etc/default/grub) sudoedit "$sel" && sudo grub-mkconfig -o /boot/grub/grub.cfg;;
(/etc/locale.gen) sudoedit "$sel" && sudo locale-gen;;
(/etc/nginx/*) sudoedit "$sel" && nginx -t && nginx -s reload;;
(/etc/caddy/*) sudoedit "$sel" && sudo systemctl reload caddy;;
(/etc/caddy/*) sudoedit "$sel" && sudo systemctl reload-or-restart caddy;;
(/etc/ssh/*) sudoedit "$sel" && sudo systemctl reload-or-restart sshd;;
(*) $(test -w "$sel" || echo sudo) "$EDITOR" "$sel";;
esac
echo "$sel" | cat - "$conf_cache" | head -20 >"$conf_tmp" && mv "$conf_tmp" "$conf_cache"