aboutsummaryrefslogtreecommitdiff
path: root/.config/tmux/right-status.sh
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2022-12-04 21:52:27 +0200
committersrdusr <trevorgray@srdusr.com>2022-12-04 21:52:27 +0200
commit30c8efcde9ec75e101599eb64d99ebde0272c938 (patch)
treecf6dede9308bcc6fb4a76ff2351b21ff402862d8 /.config/tmux/right-status.sh
parenteb90431614ae45ec030e6b553c1a6319c215fd1c (diff)
downloaddotfiles-30c8efcde9ec75e101599eb64d99ebde0272c938.tar.gz
dotfiles-30c8efcde9ec75e101599eb64d99ebde0272c938.zip
Add right-status script
Diffstat (limited to '.config/tmux/right-status.sh')
-rwxr-xr-x.config/tmux/right-status.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/.config/tmux/right-status.sh b/.config/tmux/right-status.sh
new file mode 100755
index 0000000..e806570
--- /dev/null
+++ b/.config/tmux/right-status.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+function memory-usage() {
+ if [ "$(which bc)" ]; then
+ # Display used, total, and percentage of memory using the free command.
+ read used total <<< $(free -m | awk '/Mem/{printf $2" "$3}')
+ # Calculate the percentage of memory used with bc.
+ percent=$(bc -l <<< "100 * $total / $used")
+ # Feed the variables into awk and print the values with formating.
+ awk -v u=$used -v t=$total -v p=$percent 'BEGIN {printf "%sMi/%sMi %.1f% ", t, u, p}'
+ fi
+}
+
+function main() {
+ # Comment out any function you do not need.
+ memory-usage
+}
+
+# Calling the main function which will call the other functions.
+main