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?

  • 27
    This is madness! :)
    – rectummelancolique
    Jun 19, 2013 at 14:10
  • 8
    madness ? This is sparta! -- wait, sorry.
    – Sirex
    Jun 22, 2013 at 5:58
  • 4
    I am not alone :)
    – Alupotha
    Jun 3, 2018 at 14:06

2 Answers 2


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.


You can hit Ctrl+Z or start a subshell using :!bash, and then kill the shell. Specific steps:

kill -9 $$

:suspend (or acceptable abbreviations thereof) may function equivalently to Ctrl+Z.

  • 6
    But if you :!bash, then $$ will refer to the subshell you just created. You’d need to use ps to find out the PID. ... P.S. I guess this is, to an extent, a question of style, but if there’s no need to do bash-fancy stuff, I would use just plain :!sh. Also, for that matter, try :sh. Jun 22, 2013 at 2:53
  • 1
    Downvoting because, as the comment points out, as written this might give someone just enough false confidence to exit vim and hose their machine. Mar 25, 2019 at 15:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .