Live data from Hacker News

Clear Your Terminal in Style

adammusciano.com

111–120 of 133 posts

Re: Clear Your Terminal in Style

#111
post #104

Earlier quoted context omitted.

The reset command should clear the scrollback buffer. On older terminals where you'd get a garbled screen if you accidentally cat a binary file, it will give you your ASCII back.

Trying it just now on konsole, it does not. Whether that's because your terminal is following standards or because your terminal is interpreting a terminal command that doesn't actually say anything about scrollback to also clear scrollback, I don't know, and await anyone who does to answer that question. My gut is that the terminal protocol would know nothing about scrollback and thus not have a "clear scrollback" c…

[Konsole] Settings -> Configure Keyboard Shortcuts ... "Clear Scrollback and Reset". On my Arch boxes it is mapped to Ctrl + Shift + k. That's probably a default from upstream.

Re: Clear Your Terminal in Style

#112
post #46

Earlier quoted context omitted.

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).

C-l doesn't clear anything in it's default behavior right? It changes the line-at-poit to be at the center of the screen, bottom, or top, depending on how often yoi press it.

I would never have associated that with screen clear.

E: excuse me, of course C-l does the same scrolling in the terminal, it doesn't clear the history of course.

Re: Clear Your Terminal in Style

#113
post #86

In an average day I open more than 100 terminal windows (alt-escape which opens rxvt-unicode). Use most briefly, then they vanish behind other windows. Every-so-often, when I get in a mess with alt-tab I run killUnusedTerminalsAndBC.sh, which kills the dozen or so bc instances that accumulate, and then kills any terminals which don't have anything running in them. I've done that a couple of times today, just did it a…

I use yakuake with a persistent tmux session for that, I just open my yakuake terminal and perform whatever I want in a new tmux pane (or window if preferred).

Re: Clear Your Terminal in Style

#114
I wonder if the train animation is a direct descendant of this program which was published by Processor Technology in their Access newsletter, Volume 1, No. 4. The author is "Newett Awl", which supposedly was the pseudonym of Gordon French, co-founder of the Homebrew Computer Club.

PT was the maker of the Sol-20, a 1976-ish CP/M machine.

demo: https://www.youtube.com/watch?v=UjiYQqTWHbo

Source code: http://sol20.org/programs/train.asm

Re: Clear Your Terminal in Style

#115
post #98

Earlier quoted context omitted.

I'm sort of in the opposite camp — I remember there being a non-trivial reason for moving over to iTerm several years ago, but now it's just become a habit and I can't for the life of me remember why I'm using it still. As for shortcuts — ctrl-K (kill line), ctrl-A (go to start of line), ctrl-E (end of line) are my bread and butter, and work with most shells.

One thing I loved about Macs, even though I haven't used one in years, was that you could use Emacs keybindings with the control key and "standard" keybindings with the command key. Being able to type both C-c and ⌘-c was nice.

Definitely, having readline shortcuts available more or less across the whole OS is a godsend.

Re: Clear Your Terminal in Style

#116

Earlier quoted context omitted.

You don't know ctrl+L?

It looks like you're getting downvoted without explanation: Ctrl+L doesn't clear the scrollback, it just scrolls the terminal down.

Alacritty clears with Ctrl-L, out-of-the-box.

Also, from `man bash`...

> clear-screen (C-l) Clear the screen leaving the current line at the top of the screen. With an argument, refresh the current line without clearing the screen.

Re: Clear Your Terminal in Style

#117
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.

I use this too but on linux, I am constantly hitting cmd-k and control-l in a sort of futile attempt to reset the screen correctly.

I think this needs a solution -- a keymapping and a function that resets the terminal need to be consciously united.

actually, I think I need a full set of keystrokes for linux. Somehow on ubuntu pressing the command key leads to all the windows rearranging like expose on mac.

sigh.

Re: Clear Your Terminal in Style

#118
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.

When I switched from macOS to Linux, not having ⌘-K really bugged me.

However I found out that most terminal emus on Linux also have this feature as Ctrl-L.

In gnome-terminal you have to press Ctrl-K to clear the screen, and then Ctrl-L to redraw the prompt.

The bash manual documents Ctrl-L as "Clear the screen leaving the current line at the top of the screen."

Re: Clear Your Terminal in Style

#119
post #109
post #101

Earlier quoted context omitted.

Can substitute a forward slash for the 0 and remove the quotes printf \\33c Another way is to use a program that converts hex to binary. A short script to use when there is no clear, tput, etc, e.g., xxd or nc-data exec echo 1b63 |exec xxd -p -r echo -e '27\n99\n' |exec nc-data -g exec echo |exec sed '1i\ 27 \ 99 ' |exec nc-data -g

\ is a backslash / is a forward slash, a.k.a. simply “slash”

Not sure why I always get this wrong. Maybe it is because when I draw these characters on a surface, I start from the top not the bottom. Hence the line goes forward for a "backslash" and backward for a "forward slash". What is the etymology of these terms?

Probably better to just use "escape" for backslash and "slash" for forward slash.

Re: Clear Your Terminal in Style

#120
post #22
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.

A lot of people swear by stuff like iTerm2, but I'm almost a little ashamed to admit that even though I have iTerm configured to my taste, I often still reach for macOS' native terminal. It's not gloriously beautiful or anything (basic Zsh with powerline for the shell), but it just seems to work great without the frills. Little shortcuts that think of stuff like this without any configuration (iTerms is impressively…

I don’t even install any other terminal. I just update bash to latest and stick to stock terminal. I have come to believe that often tool overload adds to the clutter and complexity and problems that didn’t need solving in the first place.
Post reply on HN