[gelöst] Pfeiltasten in zle binden

Du hast Probleme mit Deinem eMail-Programm, Webbrowser oder Textprogramm? Dein Lieblingsprogramm streikt?
Antworten
reox
Beiträge: 2459
Registriert: 06.06.2006 22:09:47
Lizenz eigener Beiträge: MIT Lizenz

[gelöst] Pfeiltasten in zle binden

Beitrag von reox » 11.01.2019 21:18:02

Ich möchte gerne das Ctrl+PfeilLinks backward-word ausführt und Ctrl+PfeilRechts forward-word.
Leider ist das scheinbar nicht ganz einfach... in oh-my-zsh ist das hier drin:

Code: Alles auswählen

bindkey '^[[1;5C' forward-word                        # [Ctrl-RightArrow] - move forward one word
bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word
funktionieren tuts nur nicht.
Wenn ich mir anschaue was für die arrow keys derzeit eingestellt ist, schaut das so aus:

Code: Alles auswählen

$ bindkey | grep backward-char
"^B" backward-char
"^[OD" backward-char
"^[[D" backward-char
aber das hier klappt dann nicht:

Code: Alles auswählen

bindkey '\C^[OD' backward-word
Ich sehe dann nur ein ;5D auf dem Terminal wenn ich Ctrl+LeftArrow drücke.
Vermutlich weil \C^[ eben Ctrl und die Escape sequenz schluckt aber OD nicht gesendet wird sondern ;5D?
Aber

Code: Alles auswählen

bindkey '\C^[;5D' backward-word
funktioniert auch nicht - aber ich habe auch kein ;5D mehr auf der konsole.

So ganz versteh ich das nicht :/ Was mach ich denn da falsch?

edit: Ich hab das nochmal am laptop probiert.
Dort funktioniert immerhin:

Code: Alles auswählen

bindkey '\C\eOd' backward-word
Hab ich vllt ein Problem mit dem keyboard?
Zuletzt geändert von reox am 12.01.2019 10:54:00, insgesamt 1-mal geändert.

reox
Beiträge: 2459
Registriert: 06.06.2006 22:09:47
Lizenz eigener Beiträge: MIT Lizenz

Re: Pfeiltasten in zle binden

Beitrag von reox » 12.01.2019 10:53:37

Aha, also darauf muss man auch erstmal kommen....
Es ist scheinbar case sensitiv, obwohl immer OD angezeigt wird, funktioniert nur Od...

dH diese beiden Einträge funktionieren bei mir:

Code: Alles auswählen

bindkey '\C-\eOd' backward-word
bindkey '\C-\eOc' forward-word
Es steht ja sogar hier: http://zsh.sourceforge.net/Guide/zshguide04.html
The two most common conventions for cursor keys are where the up key sends `\e[A' and the other three the same with B, C and D at the end, and the convention where the `[' is replaced by an `O' (uppercase letter `O'). In old versions of zsh, the only convention supported was the first of those two. The second, and any other convention, were not supported at all and you had to bind the keys yourself. This was done by something like:

bindkey "\eOA" up-line-or-history
bindkey "\eOB" down-line-or-history
bindkey "\eOC" forward-char
bindkey "\eOD" backward-char
Und ich sehe sonst auch immer nur uppercase A-D.

interessant wäre auch zu wissen warum die Sequenz aus der oh-my-zsh nicht funktioniert?

Antworten