Accidentally sourced .bash_history
In a moment of brilliance, I executed the command source ~/.bash_history
. Fortunately, most of the commands are using vim
to edit some file, but there are some scary commands in my history - moving and removing files with relative paths.
Fortunately right now it's stuck in a vim
session, however if I suspend or quit it, it's on to the next one. The history file is 1000 lines long.
How can I cancel this command, short of rebooting the machine?
Solution 1:
If it's a local machine, start a new terminal and kill the shell in question.
If it's a remote machine, ssh in and kill the shell in question.
Solution 2:
You can hit Ctrl+Z or start a subshell using :!bash
, and then kill the shell. Specific steps:
Ctrl+Z
kill -9 $$
:suspend
(or acceptable abbreviations thereof) may function equivalently to Ctrl+Z.