Live data from Hacker News

Clear Your Terminal in Style

adammusciano.com

101–110 of 133 posts

Re: Clear Your Terminal in Style

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

printf "\033c"? I don't know if it resets, but it does clear the scroll buffer. I use it before compiling (printf "\033c"; make) so that I don't have to search for the first error or warning, I can just scroll all the way up.

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

Re: Clear Your Terminal in Style

#102
post #98
post #22

Earlier quoted context omitted.

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

Re: Clear Your Terminal in Style

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

Use clear and the flush_scrollback escape:

  $ clear; printf '\e[3J'
(edit: whoops wrong URL, sorry https://apple.stackexchange.com/a/113168 )

https://unix.stackexchange.com/a/530146

Re: Clear Your Terminal in Style

#104
post #65

Earlier quoted context omitted.

CTRL-l is a standard "clear the screen" keystroke, and should work in all terminals, but it does not necessarily clear the scrollback buffer. Since "scrollback" is something implemented by the emulator itself, you'll have to look up how to do it there. I use konsole, and it's CTRL-SHIFT-k there by default, I believe. I just ran gnome-terminal, and I see in Edit -> Preferences -> Terminal -> Reset and Clear that you c…

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" command in it directly. There are plenty of other indications that scrollback is basically a hack.

Re: Clear Your Terminal in Style

#105
post #3

Earlier quoted context omitted.

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

It's not every day that you see someone abandoning Emacs for nano.

Re: Clear Your Terminal in Style

#106
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…

Tried it on konsole 19.12.2 (on Arch), it works for me.

Re: Clear Your Terminal in Style

#107
post #12

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 feels as convenient as c+Enter I learned to hit Ctrl with my palms, and never looked back. Do you use your pinky? If so, I agree c+Enter is more convenient than ctrl+L.

I use my left pinky to press Ctrl, and I use the right hand for L (index finger), so it makes no difference whether I press L or Enter using my right hand. I would probably use the right pinky for the Enter key. Works either way to me, but I am used to pressing Ctrl-L (left pinky for Ctrl, right index finger for L).

Re: Clear Your Terminal in Style

#108
post #61
post #22

Earlier quoted context omitted.

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…

Since cmd+ now switches tab in Terminal.app, and the other few things I like, such as remembering the scrollbacks, number of tabs and cwd's, I find I have no use of iTerm2 any longer. Plus, Terminal.app feels much faster. Using terminal Emacs feels very different in the two terminals.

Plus, Terminal.app feels much faster. Using terminal Emacs feels very different in the two terminals.

I recently switched back to Terminal from iTerm, and was amazed by the speed increase.

When entering commands, it is visibly a little "snappier." But where it really shines is in the output.

I have a few of batch processes that I have to run once a week, and they're all pretty heavy on the debug output, with lots of VT100 eye candy. One process that used to take close to six hours in iTerm got significantly shaved when I switched to Terminal.

Since I only run this once a week, I haven't had a chance to benchmark it, but my guess is that Terminal shaved 40 minutes off the job.

The only thing I miss from iTerm is having two sessions open in a single window. I suspect this is possible in Terminal, but I haven't figured it out yet. When I click the "Split Pane" button, I get two panes of the same session, instead of a new session in the new pane.

Re: Clear Your Terminal in Style

#109
post #101

Earlier quoted context omitted.

printf "\033c"? I don't know if it resets, but it does clear the scroll buffer. I use it before compiling (printf "\033c"; make) so that I don't have to search for the first error or warning, I can just scroll all the way up.

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”

Post reply on HN