5

Is there a way to quickly delete an entire query that I've been typing?

To clarify, this would be a query I'm still typing, not something that's currently running.

For example in bash, you can hit CTRL+C and it kills your current line, like:

$ typing some comman<CTRL-C>

After pressing CTRL+C it stops the previous stuff I have typed without executing.

It's just a thing I'm used to doing for quickly switching trains of thought ("oh what if I do this instead of this?"), but CTRL+C in the postgres terminal just terminates the process.

clemens
  • 16,716
  • 11
  • 50
  • 65
rococo
  • 2,280
  • 2
  • 22
  • 37
  • 1
    If you are talking about `psql`, that's the way it is already working. – Laurenz Albe Mar 25 '18 at 04:50
  • 1
    Oh my gosh thank you... it wasn't working that way for me but now that you mention that it's the correct way, I realized I was running it through `su`, i.e. my command was `su - postgres -c "psql"`. Apparently, when you hit `CTRL+C` in there it always gives `Session terminated, killing shell... ...killed.` regardless of whether you have another process open. I suppose if I want `CTRL+C` I'll have to manually log in as the `postgres` user first, then! – rococo Mar 25 '18 at 04:54

1 Answers1

3

Aa alternative to Ctrl+C is Ctrl+ACtrl+K. While Ctrl+A moves the cursor to the beginning of the current line, Ctrl+K deletes all characters after the cursor.

This can be used in bash or many other UNIX commands, too.

clemens
  • 16,716
  • 11
  • 50
  • 65