1

I am trying to create a keybinding for CMD (on Mac)/CTRL (on Linux) + Backspace to delete everything before the cursor. I cannot for the life of me figure out what key sequence I should use. I am currently trying this on a Mac but would like to learn about the correct sequence for Linux as well. I tried ^[[1;9~, ^[[3;9? and a few other, but nothing seems to work. I was able to verify the functionality of my widget by using ^? (just the backspace key) and it seems to work fine, I just can't figure out how to combine it with the CMD/CTRL key. Any help would be much appreciated.

On a side note, could you help me decode what the key sequences mean? I have figured out that the last number is the combination of modifier keys, and any letters that come after are the key being modified. What is the first number? What are the double square brackets? What is the semicolon? Why are some sequences only ^A while others are including all the other stuff?

4
  • Apparently different terminal emulators often generate different escape sequences, so you may need to search specifically for the ones you're using. Related: customizing some sequences on macOS and Wikipedia entry on ANSI escape sequences. Commented Jul 29, 2024 at 5:10
  • Similar: Where do I find a list of terminal key codes to remap shortcuts in bash? Commented Jul 29, 2024 at 5:46
  • 2
    Does your terminal even generate a different sequence for Ctrl-Backspace than ^? or ^H? Commented Jul 29, 2024 at 7:35
  • I am using Alacritty. I used "cat" to get the key sequences for the other keys. For Command + Backspace, I pressed Fn + Command + Backspace and got ^[[3;3~, but using that in bindkey did not work. I'll take a look at the posts you linked. Commented Jul 29, 2024 at 16:03

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.