mirror of
https://github.com/tmux-plugins/tmux-cpu.git
synced 2026-09-10 07:16:16 -04:00
Merge 564de038cf into bcb110d754
This commit is contained in:
commit
2bfb20b792
4
cpu.tmux
4
cpu.tmux
|
|
@ -18,6 +18,8 @@ cpu_interpolation=(
|
|||
"\#{ram_bg_color}"
|
||||
"\#{ram_fg_color}"
|
||||
"\#{gram_percentage}"
|
||||
"\#{gram_total}"
|
||||
"\#{gram_used}"
|
||||
"\#{gram_icon}"
|
||||
"\#{gram_bg_color}"
|
||||
"\#{gram_fg_color}"
|
||||
|
|
@ -44,6 +46,8 @@ cpu_commands=(
|
|||
"#($CURRENT_DIR/scripts/ram_bg_color.sh)"
|
||||
"#($CURRENT_DIR/scripts/ram_fg_color.sh)"
|
||||
"#($CURRENT_DIR/scripts/gram_percentage.sh)"
|
||||
"#($CURRENT_DIR/scripts/gram_total.sh)"
|
||||
"#($CURRENT_DIR/scripts/gram_used.sh)"
|
||||
"#($CURRENT_DIR/scripts/gram_icon.sh)"
|
||||
"#($CURRENT_DIR/scripts/gram_bg_color.sh)"
|
||||
"#($CURRENT_DIR/scripts/gram_fg_color.sh)"
|
||||
|
|
|
|||
27
scripts/gram_total.sh
Executable file
27
scripts/gram_total.sh
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
gram_total_format="%dk"
|
||||
|
||||
print_gram_total() {
|
||||
gram_total_format=$(get_tmux_option "@gram_total_format" "$gram_total_format")
|
||||
|
||||
if command_exists "nvidia-smi"; then
|
||||
loads=$(cached_eval nvidia-smi | sed -nr 's/.*\s([0-9]+)MiB\s*\/\s*([0-9]+)MiB.*/\1 \2/p')
|
||||
elif command_exists "cuda-smi"; then
|
||||
loads=$(cached_eval cuda-smi | sed -nr 's/.*\s([0-9.]+) of ([0-9.]+) MB.*/\1 \2/p' | awk '{print $2-$1" "$2}')
|
||||
else
|
||||
echo "No GPU"
|
||||
return
|
||||
fi
|
||||
echo "$loads" | awk -v format="$gram_total_format" '{total+=$2} END {printf format, total}'
|
||||
}
|
||||
|
||||
main() {
|
||||
print_gram_total
|
||||
}
|
||||
main "$@"
|
||||
27
scripts/gram_used.sh
Executable file
27
scripts/gram_used.sh
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
gram_used_format="%dk"
|
||||
|
||||
print_gram_usage() {
|
||||
gram_used_format=$(get_tmux_option "@gram_used_format" "$gram_used_format")
|
||||
|
||||
if command_exists "nvidia-smi"; then
|
||||
loads=$(cached_eval nvidia-smi | sed -nr 's/.*\s([0-9]+)MiB\s*\/\s*([0-9]+)MiB.*/\1 \2/p')
|
||||
elif command_exists "cuda-smi"; then
|
||||
loads=$(cached_eval cuda-smi | sed -nr 's/.*\s([0-9.]+) of ([0-9.]+) MB.*/\1 \2/p' | awk '{print $2-$1" "$2}')
|
||||
else
|
||||
echo "No GPU"
|
||||
return
|
||||
fi
|
||||
echo "$loads" | awk -v format="$gram_used_format" '{used+=$1} END {printf format, used}'
|
||||
}
|
||||
|
||||
main() {
|
||||
print_gram_usage
|
||||
}
|
||||
main "$@"
|
||||
Loading…
Reference in a new issue