keystroke to clear screen in psql?
Asked Answered
L

7

119

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.

Lopez answered 26/9, 2014 at 17:47 Comment(4)
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 ;-)Discomfiture
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).Phyllisphylloclade
I am on Windows 7. I found CTRL + SHIFT + L worked for me. Postgresql 12.Daman
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!Franciscafranciscan
I
231

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

\! clear

or

\! cls

for Microsoft.

Indecent answered 23/7, 2015 at 11:39 Comment(0)
H
89

Please use: CTRL + L

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

Hamamelidaceous answered 13/11, 2014 at 12:57 Comment(4)
I'm on Postgres 11.5 on Windows 10 and this doesn't work. It just adds ^L on the lineCabriole
I had the same issue. I got it working with CTRL + SHIFT + L instead. I am using Windows 7, postgresql 12.Daman
Works on Mac, too!Ruck
@Cabriole SEEMS Working on WSL Env.Suggestion
F
22

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

\! cls

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

Franciscafranciscan answered 18/9, 2020 at 20:1 Comment(0)
P
5

\! cls + Enter

can be usedfor Windows 10

Peanuts answered 25/12, 2020 at 12:40 Comment(0)
F
4

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

\! clear
Forlorn answered 31/8, 2022 at 11:17 Comment(2)
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.Beneficiary
Please read this to learn about Bash: opensource.com/resources/what-bashForlorn
D
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.

:)

Daniel answered 17/6, 2022 at 18:48 Comment(0)
H
0

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

\clear
Hajji answered 15/10, 2022 at 4:38 Comment(1)
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.Panada

© 2022 - 2024 — McMap. All rights reserved.