By accident, I just discovered something neat in the terminal emulator...

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
11,497
Reaction score
9,994
Credits
95,326
I checked in a few different terminal emulators and CTRL + L performs the same function as 'clear'.

I did not know this. Sure, it's probably in the help files somewhere, but it's much more enjoyable discovering this by accident. I've been at this a long time, so finding a neat shortcut like that is pretty neat. (I usually use the 'clear' function before taking screenshots for the site.)

I meant to CTRL + L to open the address bar in the browser, but I'm kinda prone and pressed the mouse button (I presume) which made the terminal take focus and it cleared the terminal. I tested again and in a few other terminal emulators and it appears fairly universal.

Alas, there's not enough meat here to turn this into an article or anything. Well, I could probably look for 'universal' keyboard shortcuts for terminals or something like that.
 


Right? I've tried it in a few terminal emulators, from qps to Terminator, and it worked in all of them.

I had no idea this shortcut existed. It'll come in handy, as I do a lot with the keyboard and terminal - and I take an inordinate number of screenshots.
 
Cntl+L is part of a group of key presses in the "Miscellaneous" category of bash "emacs Editing Mode Commands" which is the default on bash. When a command line is written, basic key presses to manipulate the line include:

Cntl+A --- move to the beginning of the command line
Cntl+E --- move to the end of the command line
Cntl+K --- delete the forward-to-end of the command line
Cntl+U --- delete the backward-to-start of the command line

Another couple of commands in the "Miscellaneous" category are:
Cntl+J --- the same as pressing the return/enter key
Cntl+[ --- the same as pressing the Esc key.

Although these are part of the suite of "emacs mode" word key presses, the user can choose a "vi mode" of key presses which offer some other effects but they also include Cntl+L.
 
I like serendipitous events!
Could use it to copy URLs quickly, as well.
 
Cntl+L is part of a group of key presses in the "Miscellaneous" category of bash

I actually know some of that. I use the CTRL A and CTRL E fairly often as I reuse commands in my history. The CTRL L was entirely new to me. I was pretty darned pleased with myself when I discovered it. I felt like a great explorer stumbling across some hitherto unknown ruins! Well, not quite that excited, but still pretty pleased with learning this.
 
KGill wrote:
I was pretty darned pleased with myself when I discovered it. I felt like a great explorer stumbling across some hitherto unknown ruins!
It's refreshing to hear of such joy. In my own case when learning a bit of bash I felt myself clunking and fumbling about with it so much but wanting it to do so many different things, that I bought a book on the bash shell and pulled myself into gear, somewhat. It's nevertheless quite a mountain to climb for me, and I'm still in the foothills.
 
It's refreshing to hear of such joy.

I love the fact that I don't know everything about Linux. I am learning new things all the time.

My L-T project/site has been a great exercise that has taught me a whole lot. I like things like that. I love learning new things. I like knowing that, no matter what, I'll never know it all. I could have two lifetimes and still not know everything about Linux.
 
It's a new one on me too, David.

Ta for sharing :)

Wiz
 
New here also, But does not see to work in KDE distros will have to investigate further on that one.
 
Ta for sharing

Between us we've been using Linux for like a few decades and not noticed it. I was pretty pleased when I found it, so I had to share.

New here also, But does not see to work in KDE distros will have to investigate further on that one.

Hmm... Have you tried multiple terminals - such as installing Terminator and trying there?
 
Between us we've been using Linux for like a few decades and not noticed it. I was pretty pleased when I found it, so I had to share.



Hmm... Have you tried multiple terminals - such as installing Terminator and trying there?
No haven't had time yet will next week I hope.
 
Check your keyboard shortcuts. There's a whole bunch of stuff already setup in there. You can also create your own. Back in 2011 I got tired of having manually move the windows around so I wrote script that uses wmctrl, xwininfo and xdotool to change window sizes and placement. I used the keyboard shortcuts tool under the menu > control center > Keyboard shortcuts (In Manjaro anyway). There's already a bunch of window commands, but none did what I wanted to do. ;) The less I have to use the mouse, the more I can get done. :D
 
nice that make clearing so much easer.
 
nice that make clearing so much easer.

I expect it to be quite handy and worth remembering, as I take a lot of screenshots. I like them to be more or less neat and tidy, without superfluous information. So, I always manually type clear and take my screenshots after that. CTRL + :L should be much faster.
 
I knew this one!!

It's not only quicker than clear, but as it is not a command but a terminal emulator feature, it also preserves the exit code of the last command, which is useful.

Try this:
Code:
$ nonexisting command
zsh: nonexisting: command not found...

# press CTRL+L here to clear the screen
$ echo $?
127

$ nonexisting command
zsh: nonexisting: command not found...

$ clear
$ echo $?
0

$
 
I expect it to be quite handy and worth remembering, as I take a lot of screenshots. I like them to be more or less neat and tidy, without superfluous information. So, I always manually type clear and take my screenshots after that. CTRL + :L should be much faster.
Hey KG,

Just goes to show that you are never too old to learn!!!! LOL.

There is joy in learning new stuff. Thanks for the 'new' trick. I'm on Mint and it works on the installed terminal.

I guess that's part of the reason I am involved with Linux.
I have been foolin around with the C language off and on for about a year or so. One of the things I read was that C is not difficult to learn, but it takes a long time to learn it. The reason for being long to learn is because of how vast the program is, not because of difficulty per se.

I am not a programmer or ever will be. But, that is not the reason I have spent time learning some of the basic things in C. The joy I get when the light comes on in my brain when I finally understand something that has been puzzling me, is well worth the effort spent.

Old Geez!!!
 


Top