Clear Your Terminal in Style
adammusciano.com
adammusciano.com
EDIT: On my windows machine I think it is ALT+F8 in Git Bash. May be similar in other terminal emulators.
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).
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.
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.
clear && make testMy 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.
ED 3 isn't actually in the [ECMA-048] spec.
It was an xterm feature introduced in June 1999. Several terminal developers later adopted the feature. In April 2011, a Red Hat developer submitted a patch to the Linux kernel, modifying its console driver to do the same thing.
So it's not a formal standard, but it's universal on Linux since 3.0 and many terminal emulators have adopted it.
This history is covered in [clear(1)] from the ncurses project.
[ECMA-48]: http://www.ecma-international.org/publications/files/ECMA-ST...
[clear(1)]: http://man7.org/linux/man-pages/man1/clear.1.html#HISTORY
EDIT: Fix wording and formatting.
* https://unix.stackexchange.com/a/375784/5132
* http://jdebp.uk./Softwares/nosh/guide/commands/setterm.xml
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!
That typo has a nice program of its own: https://github.com/p-e-w/ternimal
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.
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.
It's too bad it's so slow though (in terms of throughput, that is; latency is pretty okay).
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.
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.
Sounds like your terminal clears everything? vt100 variants are a, uh, delightful mix of nearly-compatible dialects...
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”
Probably better to just use "escape" for backslash and "slash" for forward slash.
$ 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."
[ $[$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
* http://jdebp.uk./Softwares/nosh/guide/commands/setterm.xml
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.
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
Sure, theoretically terminal emulators could capture and even rebind those keys via the APIs of whatever graphical toolkit they're built in....but if you wanted to rebind SIGINT to another key in the terminal emulator, that terminal emulator would still have to transmit ^c to the tty.
As for rebinding those keys in the kernel, Linux simply doesn't support doing that and nor does it support binding other keys to different signals. In fact I've tried to do this on a tool I was working on to emulate BSD's SIGINFO in Linux (turned out not to be possible) as as well part of the job control (SIGSTSP et al) support in my $SHELL (https://github.com/lmorg/murex).
This is also why you can throw signals over an SSH (or other remote shell) session when the terminal emulator itself would have no knowledge of the commands running on the remote host.
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.
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