114

I want a shortcut key to clear the screen in my (Windows 7) psql console just like CTRL-l clears the screen in my R console. I am tired of typing '! cls'. Do I need to write a macro for this? I am running Postgres 9.35. '\r' resets the query buffer but does not clear the screen.

starball
  • 20,030
  • 7
  • 43
  • 238
rferrisx
  • 1,598
  • 2
  • 12
  • 14
  • 2
    For `psql` on Linux, control-L . It isn't supported under Windows; unsure if there's a different keyboard shortcut or if there just isn't one. `psql` isn't as full featured under Windows because none of the PostgreSQL developers use Windows for day to day work. Patches are welcome ;-) – Craig Ringer Sep 27 '14 at 07:13
  • 16
    We are not living in perfect world. Some of us still using windows for work. Use `\! cls` to clear screen. Generally, use `\! command` to invoke command from current console (cmd.exe). – fa wildchild Mar 23 '15 at 06:20
  • I am on Windows 7. I found CTRL + SHIFT + L worked for me. Postgresql 12. – Moustache Jul 01 '20 at 13:37
  • 1
    `CTRL + SHIFT + L` doesn't seem to work on Windows 10 [Pro]. I tried it on Postgres 12.4 and it didn't work. `\! cls` works great! – Dut A. Sep 18 '20 at 20:06

7 Answers7

216

As an alternative to Ctrl-L use, e.g. for scripts in an linux environment:

\! clear

or

\! cls

for Microsoft.

Hartmut Pfarr
  • 5,534
  • 5
  • 36
  • 42
87

Please use: CTRL + L

Check out the link: http://postgresql.nabble.com/psql-in-bash-how-to-clear-screen-td2141886.html

Kevin Guto
  • 1,023
  • 6
  • 6
18

In case CTRL + L doesn't work on the Windows OS, use:

\! cls

Ensure there is SPACE between \! and cls, hit ENTER.

Dut A.
  • 1,029
  • 11
  • 22
4

\! cls + Enter

can be usedfor Windows 10

geisterfurz007
  • 5,292
  • 5
  • 33
  • 54
3

This works for me using postgresql in Windows 10 with Bash:

\! clear
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Vikram Parimi Sep 07 '22 at 12:15
  • Please read this to learn about Bash: https://opensource.com/resources/what-bash – saucysquatch Sep 08 '22 at 23:26
0

When using psql ((PostgreSQL) 14.4) through linux terminal just use:

CTRL + Shift + L

It will clear outputs and move cursor to the top of terminal window.

:)

0

If you're using WSL and a Docker Container, only works with:

\clear
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 21 '22 at 12:33