7 ms·
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
by fmajid 7y ago
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.
- 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.
- microcolonel 7y agoIt's actually an Emacs keybinding, that was added to GNU readline, which is used by Bash; most shells followed suit (either by using readline, or implementing it themselves). Ctrl + l is in Bash, in your case.
- LukeShu 7y agoWhile many of the readline keybindings come from Emacs, I would have said the common shell handling of Ctrl-L comes from that ^L is ASCII form-feed, which is "clear the page; start a new page" (in the same way that ^H is ASCII backspace). 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).
- OrderlyTiamat 7y agoC-l doesn't clear anything in it's default behavior right? It changes the line-at-poit to be at the center of the screen, bottom, or top, depending on how often yoi press it. 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.
- jerf 7y agoCTRL-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.
- capn_cabbage 7y agoI may have changed the key binding after installation. It has been a while so it feels like it has always been that way.
- CSSer 7y agoA 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 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!
- oefrha 7y agoThe fact that Ternimal.app and iTerm2 use different keyboard shortcuts for clearing scrollback buffer (⌥⌘K vs ⇧⌘K) is a constant frustration of my spotty use of Terminal.app. I would instinctively hit the iTerm2 shortcut, which brings up a connect to server panel or something.
- makecheck 7y agoYou can use System Preferences (Keyboard -> Shortcuts, “App Shortcuts” in the list) to change any binding in any menu item in any app. In this case you could force both apps to use the same keys for those commands.
- oefrha 7y agoGood point. I used that feature in the past but somehow haven’t touched it in years.
- CUViper 7y ago> The fact that Ternimal.app That typo has a nice program of its own: https://github.com/p-e-w/ternimal https://github.com/p-e-w/ternimal
- Flow 7y agoSince cmd+<number> 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.
- microcolonel 7y agoAlso, Terminal.app seems to implement almost as many extensions as XTerm, and does them pretty well. It's too bad it's so slow though (in terms of throughput, that is; latency is pretty okay).
- blattimwind 7y agoKonsole has that since forever.
- kdeldycke 7y agoYou can make your life easier on macOS by aliasing the `⌘-K` shortcut, as in: https://github.com/kdeldycke/dotfiles/blob/23ac0cd2a6c9442420537ca4058ef9e4eeb1b33d/dotfiles/.zshrc#L226-L230 https://github.com/kdeldycke/dotfiles/blob/23ac0cd2a6c944242...
- deleted 7y ago[deleted]
- texorcist 7y agoYou don't know ctrl+L?
- notatoad 7y agoIt looks like you're getting downvoted without explanation: Ctrl+L doesn't clear the scrollback, it just scrolls the terminal down.
- jchook 7y agoAlacritty clears with Ctrl-L, out-of-the-box. 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.
- SonicSoul 7y agoIs 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)
- plq 7y agoKDE's Konsole has it at CTRL+ALT+K by default. 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.
- ranger207 7y agoprintf "\033c"? I don't know if it resets, but it does clear the scroll buffer. I use it before compiling (printf "\033c"; make) so that I don't have to search for the first error or warning, I can just scroll all the way up.
- samatman 7y agoOn iTerm, that clears everything visible on the screen, but not the scroll history. Sounds like your terminal clears everything? vt100 variants are a, uh, delightful mix of nearly-compatible dialects...
- 3xblah 7y agoCan substitute a forward slash for the 0 and remove the quotes 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
- teddyh 7y ago\ is a backslash / is a forward slash, a.k.a. simply “slash”
- 3xblah 7y agoNot sure why I always get this wrong. Maybe it is because when I draw these characters on a surface, I start from the top not the bottom. Hence the line goes forward for a "backslash" and backward for a "forward slash". What is the etymology of these terms? Probably better to just use "escape" for backslash and "slash" for forward slash.
- JdeBP 7y agoAs I said elsewhere in this discussion, use DECSTR instead of RIS unless you really need all of the things that RIS does to actual terminals, like performing selftests and resetting the serial connection. Habitual use of RIS is a bad habit to get into.
- mzs 7y agoUse clear and the flush_scrollback escape: $ clear; printf '\e[3J' (edit: whoops wrong URL, sorry https://apple.stackexchange.com/a/113168 https://apple.stackexchange.com/a/113168 ) https://unix.stackexchange.com/a/530146 https://unix.stackexchange.com/a/530146
- m463 7y agoI use this too but on linux, I am constantly hitting cmd-k and control-l in a sort of futile attempt to reset the screen correctly. 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.
- jchook 7y agoWhen I switched from macOS to Linux, not having ⌘-K really bugged me. 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."