My python file:
print('HelloWorld')After executing the file in terminal history:
HelloWorld
Press ENTER or type command to continueThis is fine.
Now, if I then run the file again, it shows the previous history as well.
HelloWorld
Press ENTER or type command to continue
HelloWorld
Press ENTER or type command to continueIt should only return one 'HelloWorld', and clear the past history.
Please help.
12 Answers
You need to add a clear before each external command you run. For example, with ls, that would be
:!clear;lsIt would admitedly be pretty clumsy to type that for each command, so a map can be added in .vimrc. For example,
noremap ! :!clear;will map ! in normal and visual modes. (That overrides the default ! behavior. If you do not want to override default maps, use one of the unused keys instead.)
0There is no one answer. Different shells offer different options for configuring where your history is stored. Generally, the default filename is either .history or .SHELL_NAME_history (for example .bash_history). It’ll be stored in your home directory. You can delete that file, but there’s no guarantee that an open shell process doesn’t have some cached history information waiting to be written.
Run the history command to find out the number of the command you want to delete and then issue the following command
$ history -d numberYou can also simply edit the history file using vim and delete whatever you want to:
$ vim $HISTFILEOr for bash:
$ vim ~/.bash_history 2