alacritty: Alt-Left/Right and Home/End don't work and prevent alacritty from closing

Not sure what’s up but Alt-Left, Alt-Right, Home, and End do not work as expected.

For example: hitting Alt-Left will make the terminal flash and then type a literal D.

However hitting Alt-b works and does the config suggets Alt-Left should do. Issue with escaping somehow?

Even weirder is that after I try any of those “faulty” shortcuts typing exit does not quit the terminal and the entire program seems to freeze. It’s not even possible to close the window by hitting the “X” in the corner. I have to manually kill the process.

Config is pretty much default:

key_bindings:
  - { key: V,        mods: Shift|Control, action: Paste                        }
  - { key: C,        mods: Shift|Control, action: Copy                         }
  - { key: Home,                    chars: "\x1b[H",   mode: ~AppCursor  }
  - { key: Home,                    chars: "\x1b[1~",  mode: AppCursor   }
  - { key: End,                     chars: "\x1b[F",   mode: ~AppCursor  }
  - { key: End,                     chars: "\x1b[4~",  mode: AppCursor   }
  - { key: PageUp,                  chars: "\x1b[5~"                     }
  - { key: PageDown,                chars: "\x1b[6~"                     }
  - { key: Left,     mods: Shift,   chars: "\x1b[1;2D"                   }
  - { key: Left,     mods: Control, chars: "\x1b[1;5D"                   }
  - { key: Left,     mods: Alt,     chars: "\x1b[1;3D"                   }
  - { key: Left,                    chars: "\x1b[D",   mode: ~AppCursor  }
  - { key: Left,                    chars: "\x1bOD",   mode: AppCursor   }
  - { key: Right,    mods: Shift,   chars: "\x1b[1;2C"                   }
  - { key: Right,    mods: Control, chars: "\x1b[1;5C"                   }
  - { key: Right,    mods: Alt,     chars: "\x1b[1;3C"                   }
  - { key: Right,                   chars: "\x1b[C",   mode: ~AppCursor  }
  - { key: Right,                   chars: "\x1bOC",   mode: AppCursor   }
  - { key: Up,       mods: Shift,   chars: "\x1b[1;2A"                   }
  - { key: Up,       mods: Control, chars: "\x1b[1;5A"                   }
  - { key: Up,       mods: Alt,     chars: "\x1b[1;3A"                   }
  - { key: Up,                      chars: "\x1b[A",   mode: ~AppCursor  }
  - { key: Up,                      chars: "\x1bOA",   mode: AppCursor   }
  - { key: Down,     mods: Shift,   chars: "\x1b[1;2B"                   }
  - { key: Down,     mods: Control, chars: "\x1b[1;5B"                   }
  - { key: Down,     mods: Alt,     chars: "\x1b[1;3B"                   }
  - { key: Down,                    chars: "\x1b[B",   mode: ~AppCursor  }
  - { key: Down,                    chars: "\x1bOB",   mode: AppCursor   }
  - { key: F1,                      chars: "\x1bOP"                      }
  - { key: F2,                      chars: "\x1bOQ"                      }
  - { key: F3,                      chars: "\x1bOR"                      }
  - { key: F4,                      chars: "\x1bOS"                      }
  - { key: F5,                      chars: "\x1b[15~"                    }
  - { key: F6,                      chars: "\x1b[17~"                    }
  - { key: F7,                      chars: "\x1b[18~"                    }
  - { key: F8,                      chars: "\x1b[19~"                    }
  - { key: F9,                      chars: "\x1b[20~"                    }
  - { key: F10,                     chars: "\x1b[21~"                    }
  - { key: F11,                     chars: "\x1b[23~"                    }
  - { key: F12,                     chars: "\x1b[24~"                    }
  - { key: Back,                    chars: "\x7f"                        }
  - { key: Delete,                  chars: "\x1b[3~",  mode: AppKeypad   }
  - { key: Delete,                  chars: "\x1b[P",   mode: ~AppKeypad  }

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 17 (5 by maintainers)

Most upvoted comments

@spacecowboy I added the following lines to support skipping words via Alt+Left and Alt+Right on macOS:

  - { key: Left,     mods: Alt,     chars: "\x1bb"                       } # Skip word left
  - { key: Right,    mods: Alt,     chars: "\x1bf"                       } # Skip word right
  - { key: Left,     mods: Command, chars: "\x1bOH",   mode: AppCursor   } # Home
  - { key: Right,    mods: Command, chars: "\x1bOF",   mode: AppCursor   } # End
  - { key: Back,     mods: Command, chars: "\x15"                        } # Delete line
  - { key: Back,     mods: Alt,     chars: "\x1b\x7f"                    } # Delete word

(thanks to https://github.com/jwilm/alacritty/issues/93)

~I’m still trying to figure out how to get Command+Left (home), Command+Right (End), Command+Delete (delete line) to work, however.~ (Edited)

EDIT (2021): Updated to include all macOS bindings.

~can confirm that it works :)~

EDIT: @kchibisov Doesn’t work.

  • I reinstalled alacritty by using the cargo install method. (My version is alacritty 0.3.3 (24651a6)).
  • cat and Alt-Left/Alt-Down did print out the characters you indicated.
  • If I type a command (say, echo -e "\e[1mbold\e[0m"), and I try to move the cursor to the previous/next work with Alt-Left/Alt-Down, the terminal prints the last letter of the ANSI Code (D, B, A, C, and so on).
  • My key bindings are squeaky clean. I guess I’ll have to use the alternative key bindings again!

Thanks 😃

@danyim Did you ever figure out delete line (CMD+Backspace)? Yep!

    # Delete line
  - { key: Back,     mods: Command, chars: "\x15"                       }

There are now “quality of life” keybindings on the official docs which include these: https://github.com/alacritty/alacritty/wiki/Keyboard-mappings#macos

@danyim Did you ever figure out delete line (CMD+Backspace)?