Live data from Hacker News

Clear Your Terminal in Style

adammusciano.com

41–50 of 133 posts

Re: Clear Your Terminal in Style

#42
post #24

I've just used alias c=clear in my .bashrc and never looked back. Not even Ctrl+L feels as convenient as c+Enter

Ctrl+L works when a program is running. Clear does not.

> Ctrl+L works when a program is running. Clear does not.

I can't see how because ctrl+l is a $SHELL / readline shortcut rather than one defined in the terminal emulator. Once you run a program you're forking STDIN control to another process so you'd have to wait for the $SHELL / readline prompt again just like you would if you typed a command / function / alias into the command prompt.

Re: Clear Your Terminal in Style

#44
post #17

I’d just settle for macOS’ Terminal.app’s ⌘-K, that resets the terminal, and clears all the screen including scroll back window. Something so basic I have it in muscle memory but I haven’t found the equivalent in Linux terminals.

You can make your life easier on macOS by aliasing the `⌘-K` shortcut, as in: https://github.com/kdeldycke/dotfiles/blob/23ac0cd2a6c944242...

Re: Clear Your Terminal in Style

#45
post #17

I’d just settle for macOS’ Terminal.app’s ⌘-K, that resets the terminal, and clears all the screen including scroll back window. Something so basic I have it in muscle memory but I haven’t found the equivalent in Linux terminals.

[deleted]

Re: Clear Your Terminal in Style

#46

Earlier quoted context omitted.

I am currently using Fedora 31 Cinnamon which uses GNOME Terminal and the shortcut to reset and clear screen/scrollback is CTRL+L. I am not sure if this shortcut is standard on GNOME Terminal or not, but it's present in this flavor. EDIT: On my windows machine I think it is ALT+F8 in Git Bash. May be similar in other terminal emulators.

It's actually an Emacs keybinding, that was added to GNU readline, which is used by Bash; most shells followed suit (either by using readline, or implementing it themselves). Ctrl + l is in Bash, in your case.

While many of the readline keybindings come from Emacs, I would have said the common shell handling of Ctrl-L comes from that ^L is ASCII form-feed, which is "clear the page; start a new page" (in the same way that ^H is ASCII backspace).

I hadn't considered Bash C-L to be the same as Emacs C-L, since in Emacs I can hit C-L again to "undo" it (kinda).

Re: Clear Your Terminal in Style

#47
post #3
post #2

It may not be stylish, but I was very happy when I realised that CTRL+L will clear the screen, decent speed up if you're doing a load of demos and want the cursor at the top of the terminal

Unfortunately, Emacs uses CTRL+L to scroll the text buffer so that the caret is in the center. This collision means I often clear terminals by accident.

All the more reason for you to finally bite the bullet and make the switch to the superior editor /s

Re: Clear Your Terminal in Style

#48
post #35

Earlier quoted context omitted.

The fact that Ternimal.app and iTerm2 use different keyboard shortcuts for clearing scrollback buffer (⌥⌘K vs ⇧⌘K) is a constant frustration of my spotty use of Terminal.app. I would instinctively hit the iTerm2 shortcut, which brings up a connect to server panel or something.

You can use System Preferences (Keyboard -> Shortcuts, “App Shortcuts” in the list) to change any binding in any menu item in any app. In this case you could force both apps to use the same keys for those commands.

Good point. I used that feature in the past but somehow haven’t touched it in years.

Re: Clear Your Terminal in Style

#49
post #4

Any kind of delay will turn into an annoyance. If it doesn't, then the randomness will make it a dopamine hit / that somehow makes your brain feel rewarded. Which will lead to more terminal clearing. Not sure if that's the thing you want :-) I'd stick with CTRL+L instead.

That's what I thought too. It looks cute, but I normally turn down any animation delays I can. After the first dozen times it just becomes annoying.

Re: Clear Your Terminal in Style

#50
post #42
post #24

Earlier quoted context omitted.

Ctrl+L works when a program is running. Clear does not.

> Ctrl+L works when a program is running. Clear does not. I can't see how because ctrl+l is a $SHELL / readline shortcut rather than one defined in the terminal emulator. Once you run a program you're forking STDIN control to another process so you'd have to wait for the $SHELL / readline prompt again just like you would if you typed a command / function / alias into the command prompt.

Is ctrl+c handled; by the terminal emulator?

ctrl+l allows to clear when the prompt is non-empty, maybe parent poster meant that

Post reply on HN