Skip to content

Commit

Permalink
[scripts] ,tmux-load: fix code to get top process name
Browse files Browse the repository at this point in the history
  • Loading branch information
meain committed Aug 25, 2023
1 parent d268fc8 commit 08edb21
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions scripts/.local/bin/tmux/,tmux-load
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/bin/sh

LOAD=$(ps -A -o %cpu | awk '{s+=$1} END {print s}' | sed 's/\..*//')
if [ "$LOAD" -ge 200 ];
then
PROCESS=$(ps axhc -o command -r | head -n2 | tail -n1 | sed 's/com\.\(.*\)\..*/\1/')
echo "#[fg=red]$LOAD%($PROCESS)#[fg=default]"
LOAD=$(ps -A -o %cpu | awk '{s+=$1} END {print s}' | sed 's/\..*//')
if [ "$LOAD" -ge 200 ]; then
PROCESS=$(ps -eo cmd --sort=-%cpu --no-headers | head -n 1 | xargs basename)
echo "#[fg=red]$LOAD%($PROCESS)#[fg=default]"
else
echo ""
echo ""
fi

0 comments on commit 08edb21

Please sign in to comment.