Live data from Hacker News

Clear Your Terminal in Style

adammusciano.com

61–70 of 133 posts

Re: Clear Your Terminal in Style

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

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.

Re: Clear Your Terminal in Style

#62
post #7

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

the full monty: alias c='echo -e "\033c" ; stty sane; setterm -reset; reset; tput reset; clear' doesn't only clear the screen, but also escape any "broken" terminal configuration such as output of a binary on the tty

One can spot cargo cult command-line use when two pairs of the commands overlap functionally, and another triplet is the same program by different names.

Also note that RIS is a bad idea, discouraged since 1983 I recently discovered, although DEC did not think to tell people outside DEC this for half a decade. Use DECSTR.

Re: Clear Your Terminal in Style

#63
post #30
post #7

Earlier quoted context omitted.

the full monty: alias c='echo -e "\033c" ; stty sane; setterm -reset; reset; tput reset; clear' doesn't only clear the screen, but also escape any "broken" terminal configuration such as output of a binary on the tty

setterm does not work on macOS. I find reset(1) working fine. It already does clear, too.

One of these days, someone will take my portable setterm, which compiles fine on FreeBSD, and compile it on MacOS. (-:

* http://jdebp.uk./Softwares/nosh/guide/commands/setterm.xml

Re: Clear Your Terminal in Style

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

Is it possible to bring it back? I’ve pressed it accidentally on server window and lost the whole svr output ( I know I could look at logs but it would still be nice to quickly bring back stdout)

Re: Clear Your Terminal in Style

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

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 can give it a shortcut key but it does not appear to ship with one configured by default.

Re: Clear Your Terminal in Style

#66

The square brackets for arithmetic conditionals in bash are deprecated. Rather than: [ $[$RANDOM % 10] = 0 ] ...you can use double-parentheses. Therein, you can omit the `$` on variables and, remember, the expression evaluates to true for any non-zero value. Thus, instead: (( RANDOM % 10 ))

$[...] also establishes an arithmetic context, so

  $[RANDOM % 10]
works fine – but you're right, $[...] is not even mentioned in the manual any longer. The release notes[1] say that it's "no longer supported" in the changes for Bash 2.0 (that's 1996!), and Chet Ramey talks about it in the bug-bash mailing list[2].

[1]: http://tiswww.case.edu/php/chet/bash/NEWS

[2]: https://lists.gnu.org/archive/html/bug-bash/2012-04/msg00034...

Re: Clear Your Terminal in Style

#67
post #11

I like the VT100 demo. I wonder if there are demos for the more advanced color VT340 terminals?

They actually aren't VT100 demos, if you look at them. Several of them use SGR control sequences to set colour. I suspect that quite a few of them would not have worked on an actual VT100 series terminal.

Re: Clear Your Terminal in Style

#69
post #65

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.

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…

I may have changed the key binding after installation. It has been a while so it feels like it has always been that way.

Re: Clear Your Terminal in Style

#70
post #27
post #26

Earlier quoted context omitted.

You changed the probability here from 10% to 90% by inverting the test.

True, you can just invert: alias clear='if ! (( RANDOM % 10 )); then timeout 3 cmatrix; clear; else clear; fi'

((RANDOM % 10)) || timeout 3 cmatrix ; clear
Post reply on HN