37 ms·
Clear Your Terminal in Style
- Xophmeister 7y agoThe 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 ))
- kd5bjo 7y agoYou changed the probability here from 10% to 90% by inverting the test.
- bewuethr 7y ago$[...] 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 http://tiswww.case.edu/php/chet/bash/NEWS [2]: https://lists.gnu.org/archive/html/bug-bash/2012-04/msg00034.html https://lists.gnu.org/archive/html/bug-bash/2012-04/msg00034...
- artursapek 7y agoThis perfectly illustrates why I never bothered to learn bash syntax, and always just google for examples.
- raesene9 7y agoIt may not be stylish, but I was very happy when I realised that CTRL+L will clear the screen, decent speed up if you're doing a load of demos and want the cursor at the top of the terminal
- TeMPOraL 7y agoUnfortunately, 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.
- microcolonel 7y agoIt does a cycle in Emacs, actually. First it centers, then it puts the caret at the bottom, then it puts it an the top (like readline, in a way)
- TeMPOraL 7y agoYes (actually, it's center -> top -> bottom); I just didn't want to make the comment longer. Anyway, in Emacs, it's something I frequently do without thinking.
- airstrike 7y agoAll the more reason for you to finally bite the bullet and make the switch to the superior editor /s
- JdeBP 7y ago... where Control+L means repeat previous find/replace. (-:
- ASalazarMX 7y agoIt's not every day that you see someone abandoning Emacs for nano.
- bugmen0t 7y agoAny kind of delay will turn into an annoyance. 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.
- tra3 7y agoThat's what I thought too. It looks cute, but I normally turn down any animation delays I can. After the first dozen times it just becomes annoying.
- _eigenfoo 7y agoI've just used alias c=clear in my .bashrc and never looked back. Not even Ctrl+L feels as convenient as c+Enter
- adren123 7y agothe 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
- Fnoord 7y agosetterm does not work on macOS. I find reset(1) working fine. It already does clear, too.
- JdeBP 7y agoOne 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 http://jdebp.uk./Softwares/nosh/guide/commands/setterm.xml
- JdeBP 7y agoOne 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.
- bingerman 7y agoI have mapped capslock to ctrl (esc if used without modifiers) which made ctrl+L extremely comfortable for me.
- dmitshur 7y agoI don’t quite understand why. With one hand or two?
- rmetzler 7y agoI‘m not sure if I need an animation for clearing the terminal, but I enjoy having the ruby gem gti providing an animation and executing the respective command whenever I mistype git.
- mhd 7y agoI think an ideal clearing style would have the resulting shell prompt as an element of the animation. Let's say you've get the matrix digital rain, which resolves into just the prompt "raining" and then resolving into the regular text. Or just the prompt easing/fading in after the main loop. 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.
- pampa 7y agoI like the VT100 demo. I wonder if there are demos for the more advanced color VT340 terminals?
- torgoguys 7y agoANSI demos would be similar to your request, but use a different character set (IBM PC's default character mode--code page 437).
- pampa 7y agoI guess it is to late and nobody will read this. But anyway. 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.
- JdeBP 7y agoThey 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.
- pampa 7y agoI guess it is to late and nobody will read this. But anyway. 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.
- animalnewbie 7y agoUnrelated that some may find useful- type reset to actually clear scrollback too if you're confused after too much output
- chupasaurus 7y agoAnother list of terminal pretties missing lolcat.
- fmajid 7y agoI’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.
- Tyr42 7y agoIt's also super helpful when you want to run one command which spews out a bunch of errors, and then read the first error. Cmd-K, enter, and fling up the the trackpad. I think I'd have to pipe to less if I don't have cmd-K.
- bobbylarrybobby 7y agoCmd up and down navigates between prompts, so you don’t even have to scroll
- brigandish 7y agoI tried this and it even worked within the sqlite3 session I have open, very nice.
- mercer 7y agoThis changes everything!
- Tyr42 7y agoWhoa, someone downstream says `reset` clears scrollback.
- capn_cabbage 7y agoI 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.
- C1sc0cat 7y agoWow - if you go further down they mention there was a VT100 Demmo scene
- nickelcitymario 7y agoThis one should really have a massive "do not try this": [ $[$RANDOM % 6] = 0 ] && sudo rm -rf / || echo "Not today" An awful lot of people just copy and paste things to see what'll happen.
- bmgxyz 7y agoI agree. However, in this case I believe most versions of rm would complain about passing "/" as an argument without also passing "--no-preserve-root", so there's that at least.
- nyberg 7y agoI don't think it does. If one blindly copies a command to their terminal, this is a good lesson not to do so. Too many projects suggest `curl foo | sh` as the "quick and ready to go" method for installation which is equally as bad as rm -rf in the wild.
- qubex 7y ago83% of them wouldn’t see any effect. Unfortunately that might just compel them to keep trying.
- techslave 7y agoah my old friend `sl’ not to mention the first and only useful application if terminal gif html
- mmcgaha 7y agoI 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.
- myhf 7y agoIf you use a Dvorak keyboard layout, you will be immune to sl, without having to set any alias.
- deleted 7y ago[deleted]
- kempbellt 7y agoCool tool, but as someone who actually works in the terminal, I would hate this after one use. Maybe alias it to `explody_clear` for fun use every once in a while. 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.
- jolmg 7y ago> [ $[$RANDOM % 10] = 0 ] && do_this || do_that > 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.
- jgtrosh 7y agoAfaik this is common syntax for if/else based only on the the initial condition; I can't remember where it's documented but I think it requires the do_this part to be a single expression. However, bash pitfalls recommends against using && and || except for very basic logic.
- jolmg 7y ago> Afaik this is common syntax for if/else based only on the the initial condition 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 expression It'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.
- zwetan 7y agoahhh missing a great effect https://github.com/bartobri/no-more-secrets https://github.com/bartobri/no-more-secrets
- qubex 7y agoSETEC ASTRONOMY
- shyrka 7y agoCTRL+l gotta go fast!
- nixpulvis 7y agoWhile I was working on Alacritty's `clear` handling, I stumbled on a number of interesting details (including a recently fixed bug in `clear` itself). https://github.com/alacritty/alacritty/pull/2329#issuecomment-506591085 https://github.com/alacritty/alacritty/pull/2329#issuecommen...
- djsumdog 7y agoI don't think there's a way to map these cute animations to Ctrl+L is there?
- qubex 7y agocbeams? Isn’t that a Blade Runner reference?
- cyansmoker 7y agoIt absolutely is.
- iso1631 7y agoIn an average day I open more than 100 terminal windows (alt-escape which opens rxvt-unicode). Use most briefly, then they vanish behind other windows. 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.
- OrderlyTiamat 7y agoI use yakuake with a persistent tmux session for that, I just open my yakuake terminal and perform whatever I want in a new tmux pane (or window if preferred).
- gumby 7y agoWhat's wrong with control L? That's been the standard way since the 80s at least.
- gnachman 7y agoWhat 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.
- zozbot234 7y agoThat's just a form feed character, or CTRL+L.
- nice__two 7y agoNeat! I personally prefer the very quick vertical tab method: Ctrl+L. Quick and easy.
- tasty_freeze 7y agoI wonder if the train animation is a direct descendant of this program which was published by Processor Technology in their Access newsletter, Volume 1, No. 4. The author is "Newett Awl", which supposedly was the pseudonym of Gordon French, co-founder of the Homebrew Computer Club. PT was the maker of the Sol-20, a 1976-ish CP/M machine. demo: https://www.youtube.com/watch?v=UjiYQqTWHbo https://www.youtube.com/watch?v=UjiYQqTWHbo Source code: http://sol20.org/programs/train.asm http://sol20.org/programs/train.asm
- nineteen999 7y agoMy new favourite way: ttyfire https://i.imgur.com/c0VIJYg.mp4 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 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. https://news.ycombinator.com/item?id=18833765 https://news.ycombinator.com/item?id=18833765
- tomcatfish 7y agoDoes anyone have any idea why the download to the viewer needed for the Twilight Zone file gets flagged by Firefox as a virus? I can't see anything strange in it. http://artscene.textfiles.com/viewers/linux/slowcat.pl http://artscene.textfiles.com/viewers/linux/slowcat.pl
- AJCxZ0 7y agoIn times past, Solaris' /usr/bin/clear was a sh script which ran "tput clear", but the amusing parts was the notice which includes # Copyright (c) 1987, 1988 Microsoft Corporation # All Rights Reserved # This Module contains Proprietary Information of Microsoft # Corporation and should be treated as Confidential.