aboutsummaryrefslogtreecommitdiff
path: root/linux/home/.config/tmux/right-status.sh
diff options
context:
space:
mode:
Diffstat (limited to 'linux/home/.config/tmux/right-status.sh')
-rwxr-xr-xlinux/home/.config/tmux/right-status.sh27
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% |"
+