diff options
| author | srdusr <trevorgray@srdusr.com> | 2025-08-30 00:50:14 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2025-08-30 00:50:14 +0200 |
| commit | bba0c17c6c0bc310e44ae45b9573d2dc99b8157f (patch) | |
| tree | efb8b4a3c9091d91f53905d69919935b33b5b1cd /linux/home/.config/tmux/right-status.sh | |
| parent | 4a29c3cc90b48048961331de31c2229cfd71055f (diff) | |
| download | dotfiles-bba0c17c6c0bc310e44ae45b9573d2dc99b8157f.tar.gz dotfiles-bba0c17c6c0bc310e44ae45b9573d2dc99b8157f.zip | |
Changed tmux
Diffstat (limited to 'linux/home/.config/tmux/right-status.sh')
| -rwxr-xr-x | linux/home/.config/tmux/right-status.sh | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/linux/home/.config/tmux/right-status.sh b/linux/home/.config/tmux/right-status.sh new file mode 100755 index 0000000..a14bbe3 --- /dev/null +++ b/linux/home/.config/tmux/right-status.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Get CPU average +getCPU=$[100-$(vmstat 1 2|tail -1|awk '{print $15}')] + +# Grab the second line of the ouput produced by the command: free -g (displays output in Gb) +getMem=$(free -h | sed -n '2p') +getMemPct=$(free -g | sed -n '2p') + +# Split the string in secondLine into an array +read -ra ADDR <<< "$getMem" +read -ra ADDRPct <<< "$getMemPct" + +# Get the total RAM from arrays +totalRam="${ADDR[1]//[^0-9.0-9]/}" +totalRamPct="${ADDRPct[1]}" + +# Get the used RAM from arrays +usedRam="${ADDR[2]//[^0-9.0-9]/}" +usedRamPct="${ADDRPct[2]}" + +# Calculate and display the percentages +pct="$(($usedRamPct*100/$totalRamPct))" +usage="$usedRam/$totalRam" +#echo "cpu:$getCPU% | mem:$pct% ($usage""G)" +echo "Cpu:$getCPU% | Mem:$pct% |" + |
