Command-L "Clear to the previous mark" equivalent in iTerm2

6

In Mac OSX there is the command-L command to "clear to the previous mark"

I was curious if there is a command equivalent to this in the iTerm2 terminal because I would like to switch over, but I use this command a lot in the normal terminal.

Thank you for the help.

Avir94

Posted 2017-03-23T23:01:57.300

Reputation: 61

2what is previous mark? – Ken Ratanachai S. – 2017-03-23T23:12:32.847

Sounds like a known issue https://superuser.com/questions/1178934/iterm2-ctrl-c-doesnt-work-sometimes

– primohacker – 2019-01-24T01:33:46.967

see also https://stackoverflow.com/questions/15733312/iterm2-delete-line

– primohacker – 2019-01-24T01:38:37.100

@KenRatanachaiS. previous mark is usually the last line the cursor is at. You can obviously mark/unmark places as you wish, https://support.apple.com/guide/terminal/keyboard-shortcuts-trmlshtcts/mac#trmlcbe3aa09

– Devy – 2019-04-17T17:13:13.277

Answers

0

Clear the screen/pane (when Ctrl + L won't work) ⌘ + K

Here's a cheatsheet for iTerm2.

Honestly, I think clearing lines this way is a bad habit. It's not universal.

If you have a injected proc in metasploit with a terminal, and you hit your habitual keyboard interrupt sequence of choice.... Well, keyboard interrupt in this context will kill your shell and could kick you out of the injected process. (So much for your exploit. Sure hope someone restarts that box without getting suspicious...) It took me a year to get out of this habit and I still catch myself. Same problems with commands that don't terminate on their own like ping without specifying a count. Do that in metasploit without doing ping -c 4 <ip> and you'll remember how screwed you are because you have to do an interrupt to stop it, and that interrupt will kill your session.

Instead, I would recommend using the home key, entering a comment character, then enter. This has the added benefit of saving the long line in history. You worked hard to type that line. There's probably some goodness in there you might need later. And, once in your history, you can arrow up to it and simply home and delete the # character. Think of it like an arm/disarm toggle.

In bash that would be home and #. Oddly enough, I don't see a comment character for iTerm2...

Anyhow, when Ctrl + L does't work) try ⌘ + K. Considering using home comment char enter instead.

primohacker

Posted 2017-03-23T23:01:57.300

Reputation: 119