I'm trying to map ⌘+Delete (backspace) to delete to the beginning of the line (like it works in browsers and text editors) in iTerm2 and I'm unable to find a working escape code for it. I tried 1K (^[1K
) based on what I read in Wikipedia. It just prints a "K".
Edit: I found Ctrl+U. Now to find out how to map it. Maybe Hex code 21 (U being 21st letter), so 0x15?
By the way, if you want to kill text from the cursor to the end of the line, you can press Ctrl - k . So instead of doing the binding described above, you can kill a whole line by pressing Ctrl - u Ctrl - k .
In OSX, ⌥+⌫ and ⌘+⌫ are the shortcuts for deleting a word and deleting a line respectively. ⌘+ ← and ⌘+ → are for going to the beginning and end of lines.
The rm command is used to delete one or more files located in the current directory – this operation is permanent. For that reason, you may need to use rm with the -i flag so that you can be prompted for confirmation.
I got it. I have no idea why Hex Code mappings in iTerm2 produce the associated Ctrl+key mappings, but they do. No idea what 0x00 means, either, as it's not assigned to A as might be expected. (though I do believe Unix has its own conventions relating to treating null bytes -- we have e.g. xargs
accepting a null byte delimiting format from find
for example -- It would be neat if we can bind this to a hotkey with iTerm2)
I was able to find that Ctrl+U does nearly the exact task I want (it deletes the entire line rather than deleting only what is before cursor, but whatever... Ctrl+Y as a bonus can bring it all back). Then I curiously saw that I had hex codes 0x1
and 0x5
mapped to ^A
and ^E
respectively, for my Cmd+Left and Cmd+Right... so 0x15
is for ^U
!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With