Skip to content

Suggestion: cpu vis comment tput ? #33

@wx4cb

Description

@wx4cb

a suggestion i thought of after watching the net vis video..

@7:45 he uses a way of padding the line so that he can clear to end of line. the easiest way to do this is to use tput.

for example.

CLR_EOL=$(tput el)
.
echo "This is a longer line of text."
# Use a carriage return to move to the beginning of the line
# then use $CLR_EOL to clear the entire line
printf "\r%s" "${CLR_EOL}New, shorter text."

another way is t just use stadard ansi escape sequencies which is less $TERM compatible if you aren't using an ansi capable terminal.

echo "This is a longer line of text."
# \r moves to the beginning of the line, \033[0K clears to the end
printf "\r\033[0K%s" "New, shorter text."
echo # Add a final newline

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions