From c5382934e19755b19a879cd3d0132fa08d35a127 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Thu, 25 Jul 2024 12:39:13 +0300 Subject: [PATCH] config/bash/aliases: update status and fix prompt exit code --- .config/bash/aliases.bash | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/.config/bash/aliases.bash b/.config/bash/aliases.bash index 46c9bc1..8e57b3c 100644 --- a/.config/bash/aliases.bash +++ b/.config/bash/aliases.bash @@ -39,24 +39,31 @@ xtrace () { set +x } -highlight() { echo "$1"; } +highlight() { echo; echo "$1"; } status() { highlight 'System' - free -h df -h -T --exclude-type=tmpfs --exclude-type=devtmpfs --exclude-type=squashfs --exclude-type=overlay - zfs list -d 0 - sudo certbot certificates + zfs list -d 0 2>/dev/null + free -h + sudo certbot certificates 2>/dev/null + highlight 'Internet' #--color=always ip -brief address | grep --color=none -E '^(wl|en|tun|vmbr)' ip route echo -n 'IPv4: ' && timeout 3s ping example.com -A -c 3 -w 3 -q -4 echo -n 'IPv6: ' && timeout 3s ping example.com -A -c 3 -w 3 -q -6 + highlight 'Programs' - tmux ls - $sudo systemctl --no-pager list-units --failed || service --status-all - if type docker >/dev/null - then $sudo docker ps || $sudo systemctl status docker + tmux ls 2>/dev/null + $sudo systemctl --no-pager list-units --failed --no-legend || service --status-all + echo '== WEBSERVER' + { sudo lsof -i :443 || sudo lsof -i :80; } | head -4 + echo + if type docker &>/dev/null + then + echo '== DOCKER' + $sudo docker ps || $sudo systemctl status docker fi } @@ -67,6 +74,9 @@ disks() { sudo fdisk -l } | less } +scandisks() { + for host in /sys/class/scsi_host/*; do echo "- - -" | sudo tee $host/scan; ls /dev/sd* ; done +} __u="$sudo apt update && $sudo apt upgrade" alias u="$__u" @@ -121,8 +131,8 @@ shopt -oq posix || src /etc/bash_completion # Fancy prompt PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]" -PS1="$PS1 \`if [ \$? = 0 ]; then echo -e '\[\033[01;32m\]:)';" -PS1="$PS1 else echo -e '\[\033[01;31m\]' \$?; fi\`\[\033[00m\]" +PS1="$PS1 \`exitcode=\${?}; if test \$exitcode = 0; then printf '\[\033[01;32m\] :)';" +PS1="$PS1 else printf '\[\033[01;31m\]%3d' \$exitcode; fi\`\[\033[00m\]" ;; (*zsh) setopt sh_word_split;; esac @@ -130,4 +140,4 @@ esac src /usr/share/git/completion/git-prompt.sh && PS1="$PS1\$(__git_ps1 \" (%s)\")" src $HOME/.config/shell/functions -PS1="$PS1 \$ " +PS1="$PS1 \`test \$UID = 0 && printf '#' || printf '$'\` "