While trying to find a clean method to remove line numbers from the
history command, I found an interesting trick by using the
HISTTIMEFORMAT environment variable. Here’s what
But it turns out you can actually put pretty much anything in there, and for example, an
ANSI escape sequence that does a line feed and erases the current line:
$ HISTTIMEFORMAT="$(echo -e '\r\e[K')"
There we go, no more line numbers:
$ history |tail -1