290 points · by signa11 · 6y ago · 130 comments
Little shortcuts that think of stuff like this without any configuration (iTerms is impressively extensive) are just a cherry on top. It kind of bums me out that's not linux native. Do you know of any other useful shortcuts specific to macOS? I've been using ctrl+L for the longest time. Thank you for sharing!
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?
https://www.marcjenkins.co.uk/drop-down-terminal-with-iterm2...
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.
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.
That typo has a nice program of its own: https://github.com/p-e-w/ternimal
EDIT: On my windows machine I think it is ALT+F8 in Git Bash. May be similar in other terminal emulators.
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.
Ctrl + l is in Bash, in your case.
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).
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 forward slash, a.k.a. simply “slash”
Sounds like your terminal clears everything? vt100 variants are a, uh, delightful mix of nearly-compatible dialects...
The command "tput clear" should work everywhere though. And frankly, while obviously more work than a keyboard shortcut, it's not that much of an effort.
$ clear; printf '\e[3J'
(edit: whoops wrong URL, sorry https://apple.stackexchange.com/a/113168 )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.
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."
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.
It's too bad it's so slow though (in terms of throughput, that is; latency is pretty okay).
[ $[$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 )) $[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...
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.
But yes, most of the animations are quite a bit too long. I wouldn't mind a quick Star Wars diagonal wipe, though, to be honest.
If I want the terminal cleared, I want it cleared immediately so that I can go about my next task, or wipe sensitive data from my screen. Adding a delay to the task will annoy me immediately.
doesn't only clear the screen, but also escape any "broken" terminal configuration such as output of a binary on the tty
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.
* http://jdebp.uk./Softwares/nosh/guide/commands/setterm.xml
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.
EDIT: After a suggestion from another user, I just remapped my Caps Lock to CTRL. That seems a lot easier to deal with. I'll try that for a bit and see how it goes.
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.
ctrl+l allows to clear when the prompt is non-empty, maybe parent poster meant that
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 again and killed another 10 hanging around. Most of the rest are idle, but sshed to other servers, so they don't get reaped.
https://i.imgur.com/c0VIJYg.mp4
Video is of it running in gnome-terminal, where the terminal window is scaled right down with ctrl-minus.
Source is here: https://github.com/dmo9000/ttyfire
So far its been able to run on Linux, FreeBSD, Solaris and OpenBSD with minor patches. NetBSD xterm doesn't seem to support Unicode for some reason.
This was inspired by the Javascript DOOM fire effect that was posted here a bit over a year ago.
A couple of years ago i bought a new old stock DEC VT340 terminal, complete with a set of manuals. It can do much more than ANSI. Wikipedia says it can to bitmap and vector graphics "ReGIS, Sixel and Tektronix 4010". I wonder if there are scripts or tools to demo those capabilities.
A couple of years ago i bought a new old stock DEC VT340 terminal, complete with a set of manuals. It can do much more than ANSI. Wikipedia says it can to bitmap and vector graphics "ReGIS, Sixel and Tektronix 4010". I wonder if there are scripts or tools to demo those capabilities.
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
https://github.com/alacritty/alacritty/pull/2329#issuecommen...
# Copyright (c) 1987, 1988 Microsoft Corporation
# All Rights Reserved
# This Module contains Proprietary Information of Microsoft
# Corporation and should be treated as Confidential.> This gives roughly a 1 in 10 chance of do_this running, and a 9 in 10 chance of do_that running.
`do_that` having a 9 in 10 chance depends on `do_this` having a 0 chance of returning a falsy status.
You're right that it's common, but you're wrong saying that it's based only on the initial condition:
$ true && cat nonexistent.txt || echo "shouldn't have run"
cat: nonexistent.txt: No such file or directory
should't have run
> I can't remember where it's documented but I think it requires the do_this part to be a single expressionIt's not documented like you said because it's a hack. &&/|| aren't meant to simulate if/else. These aren't expressions either. And they aren't really limited either:
$ true && { echo "true condition ran"; cat nonexistent.txt; } || echo "false condition ran"
true condition ran
cat: nonexistent.txt: No such file or directory
false condition ran
> However, bash pitfalls recommends against using && and || except for very basic logic.The fact that people end up thinking that it's an ok substitute for if/else syntax is the reason why it's recommended against.
[ $[$RANDOM % 6] = 0 ] && sudo rm -rf / || echo "Not today"
An awful lot of people just copy and paste things to see what'll happen.
Unfortunately that might just compel them to keep trying.
Quick and easy.
not to mention the first and only useful application if terminal gif html