How can I prevent line numbers from appearing in .bash_history?

Solution 1:

Update: The recent edit you've made to you question shows the following line being in your .bash_profile file:

export HISTTIMEFORMAT='%y-%m-%d-%T   '

Remove this line to stop the timestamp from being added to the ~/.bash_history file.


Original Answer:

As HISTTIMEFORMAT is not set by default, up to an including macOS Mojave, you'll need to check one of the following files to see where it was added:

  • /etc/bashrc
  • /etc/profile
  • ~/.bash_profile
  • ~/.bash_login
  • ~/.profile
  • ~/.bashrc

Removing the line that has HISTTIMEFORMAT from the file that has it will stop the timestamp from being added to the ~/.bash_history file.

Note: The dot files mentioned in the $HOME directory are hidden and some may not exist.