Live data from Hacker News

Clear Your Terminal in Style

adammusciano.com

91–100 of 133 posts

Re: Clear Your Terminal in Style

#91
post #84
post #73

Earlier quoted context omitted.

The terminal can optionally catch some characters and convert them to signals. By default, ^C sends SIGINT, ^\ sends SIGQUIT, and ^Z sends SIGTSTP. Programs can disable that for their own purposes (stty -isig) and you can rebind them to other characters if you want (stty intr, stty quit, stty susp) but I don't know why anyone would these days.

In Linux and UNIX you enable or disable use of ctrl+c (effectively setting the tty into a raw mode) via syscalls against the tty file descriptor - it is not handled by the terminal emulator at all (in fact if you read the man page for `stty` you'd see it's changing the your terminals fd and not the terminal emulator). Sure, theoretically terminal emulators could capture and even rebind those keys via the APIs of what…

Good point, I should have said TTY driver (all my information is from half-remembered reading of https://www.linusakesson.net/programming/tty/index.php, any mistakes are my own).

With respect to rebinding, what is "stty intr ^D" doing if not rebinding the interrupt character to ^D?

I feel your pain about not having SIGINFO though.

Re: Clear Your Terminal in Style

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

> A lot of people swear by stuff like iTerm2 Actually, I've been using Terminal for years. I usually try to use default apps as much as possible (Safari, Mail, Notes, Terminal) to reduce configuration overhead. I switched to iTerm2 a few days ago after reading an article on HN... not sure if it worth the change, but haven't tried anything fancy yet. What would be the killer feature of iTerm2?

I use profile triggers to change the color scheme of the shell when I SSH to a production server. The color I chose is different from my regular scheme so that it reminds me I am in production and things can break if I'm not careful.

Re: Clear Your Terminal in Style

#93

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

This perfectly illustrates why I never bothered to learn bash syntax, and always just google for examples.

Re: Clear Your Terminal in Style

#94

Earlier quoted context omitted.

> A lot of people swear by stuff like iTerm2 Actually, I've been using Terminal for years. I usually try to use default apps as much as possible (Safari, Mail, Notes, Terminal) to reduce configuration overhead. I switched to iTerm2 a few days ago after reading an article on HN... not sure if it worth the change, but haven't tried anything fancy yet. What would be the killer feature of iTerm2?

For me it is its integration with tmux, and therefore being able to use the command line in a remote computer as if you were using it locally.

I just use tramp for this.

Re: Clear Your Terminal in Style

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

Reset takes at least a couple seconds though, I’m not sure I’d swap it with clear in something like:

    clear && make test

Re: Clear Your Terminal in Style

#97
post #52

I hate sl. I always alias it and I will purge it from any system that I am in charge of. It is not fun nor cute and I do not want to waste my time watching it.

If you use a Dvorak keyboard layout, you will be immune to sl, without having to set any alias.

Re: Clear Your Terminal in Style

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

Re: Clear Your Terminal in Style

#99
What would you think of a command that clears the screen but first pushes the contents onto a stack so you could return to it later? The thought crosses my mind once in a while but I wonder if I’m the only one who wants it.

Re: Clear Your Terminal in Style

#100

What would you think of a command that clears the screen but first pushes the contents onto a stack so you could return to it later? The thought crosses my mind once in a while but I wonder if I’m the only one who wants it.

That's just a form feed character, or CTRL+L.
Post reply on HN