Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
spacecowboy opened this issue Mar 9, 2017 · 17 comments
Closed

Comments

@spacecowboy
Copy link

spacecowboy commented Mar 9, 2017

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  }
@spacecowboy spacecowboy changed the title Alt-Left/Right and Home/End don't work Alt-Left/Right and Home/End don't work and prevent alacritty from closing Mar 9, 2017
@gmile
Copy link

gmile commented Apr 9, 2017

I would add that that changing language via Cmd Space while in alacritty also doesn't work in macOS.

@jonhoo
Copy link
Contributor

jonhoo commented Jun 2, 2017

FWIW, I've only noticed this in bash, and not in fish. Not sure what the difference there is..

@areading
Copy link

areading commented Jun 6, 2017

Also FWIW, the case for bash seems to depend on your readline settings. I too had the issue where Home/End didn't work properly (I don't use Alt-Left or Alt-Right), and fixed it by editing my ~/.inputrc. I added the lower two lines below -- you'll notice they correspond to the same sequence in the config, as well as the returned values from showkey -a:

$if Bash
"C-i":      beginning-of-line
"C-a":      end-of-line
"\e[1~":    beginning-of-line
"\e[4~":    end-of-line
$endif

@danyim
Copy link

danyim commented Oct 23, 2017

@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 #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.

@danyim
Copy link

danyim commented Sep 15, 2018

I'm very close to getting the delete line (Cmd+Delete) working via this keybinding:

  - { key: Back,     mods: Command, chars: "\x1b[K",  mode: AppCursor  }

I know the value should be \x1b[2K because of what @jwilm mentioned here and the ANSI terminal escape sequence for delete line; however, it seems like this escape sequence isn't recognized. I've also tried \x1b[J.

Debugging via

- { key: Back,     mods: Command, chars: "foo",  mode: AppCursor  }

seems to print foo, so I'm almost certain it's the sequence.

Any ideas?

@voigt
Copy link

voigt commented Jan 15, 2019

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

  - { key: Left,     mods: Alt,     chars: "\x1bb"                       }
  - { key: Right,    mods: Alt,     chars: "\x1bf"                       }
  - { key: Left,     mods: Command, chars: "\x1bOH",   mode: AppCursor   } # Home
  - { key: Right,    mods: Command, chars: "\x1bOF",   mode: AppCursor   } # End

(thanks to #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)

Worked perfectly for me. However, I needed to uncomment following lines as they would overwrite the settings:

#  - { key: Left,     mods: Alt,     chars: "\x1b[1;3D"                   }
#  - { key: Right,    mods: Alt,     chars: "\x1b[1;3C"                   }

@chrisduerr
Copy link
Member

@spacecowboy I've just tested this and Alacritty behaves exactly the same way as XTerm. Is this still an issue?

@spacecowboy
Copy link
Author

spacecowboy commented Mar 23, 2019 via email

@spacecowboy
Copy link
Author

Closing since it's no longer reproducible

@chrisduerr
Copy link
Member

Thanks for the update!

@Empty2k12
Copy link

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

@lemeb
Copy link

lemeb commented Oct 4, 2019

Can reproduce the bug here, just after I installed Alacritty on my Mac (Catalina beta).

Kickass work though! Really impressive :)

@kchibisov
Copy link
Member

@lemeb Are you on master or on latest release? It should be fixed on master.

@lemeb
Copy link

lemeb commented Oct 6, 2019

I was on the latest release!

@kchibisov
Copy link
Member

kchibisov commented Oct 6, 2019

@lemeb so, Is it working for you on the latest master? You can launch cat and type Alt+Left/Alt+Down and so on, you should see something like this.

^[[1;3D^[[1;3B^[[1;3A^[[1;3C[[1;3F^[[1;3H

Also, try launching alacritty --config-file /dev/null to test if your configuration is the issue here.

@lemeb
Copy link

lemeb commented Oct 7, 2019

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
Copy link

danyim commented Sep 19, 2021

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests