oh-my-fish / plugin-sudope

sudope plugin for Oh-My-Fish. Quickly put 'sudo' in your command

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

alt-s is bound to scrollback search in urxvt

JAicewizard opened this issue · comments

I cannot use alt-s in my normal terminal since alt-s is already used for searchable scrollback in urxvt.
without changing the keybinding in urxvt I cannot use alt-s.
Maybe make it configurable so that you can change the binding?

You can set your own binding by changing sudope_sequence.

That probably needs to be added to the docs :)

@bobthecow how can I change it to double esc like in oh-my-zsh?

Add the config:

set -g sudope_sequence \e\e

... somewhere, probably ~/.config/omf/init.fish, then restart fish.

@bobthecow thanks a ton, works like a charm!

I am defeated. There is no way to make sudope work in Mac OS. I've hunted for unused control characters, made custom keyboard layouts, changed key bindings in iterm2, unmapped functions in fish, implemented my own "sudone" function. There is just no way around it, on a Mac, you must cursor backwards and type "sudo" :-(

@daveman1010221 I definitely have it working in iterm2, macOS, fish 3.0, and current version of OMF and Sudope.

The only non-standard thing I've done is add the line above to set the sudope_sequence.

I finally got this to work, it was a collision with fish_vi_mode_keybindings. If you use fish vi mode, you will run into this. In my case, I fixed this by mapping left option key to 'Esc+' in iTerm2, setting sudope_sequence to \es, and un-binding 's' from vi_key_bindings.fish, located at /usr/local/Cellar/fish/VERSION/share/fish/functions. This will whack the vi binding for 's', but I can't say I ever used that particular command anyway. I figured it out because I was able to get it to work occasionally, which made me think there might be some sort of race on the keybinding. So, in case anyone else runs into this, hope this helps. ;-)

I have tried adding set -g sudope_sequence \e\e in both ~/.config/omf/init.fish and ~/.config/omf/before.init.fish with no luck, ESC+ESC just doesn't seem to work.
Am I doing something wrong here?

fish, version 3.1.2
macos, 10.15.4

heh.

"escape escape" as a key binding was always a little weird, and it only worked because in a terminal, alt is the same as escape.

so when looking at key bindings, when the shell sees, for example, \es, it figures either you pressed "alt+s", or you pressed "escape", waited a bit, then pressed "s". and it should do different things depending on which of those two you did.

prior to fish 3.1, the heuristic it used to distinguish between the two was "did the second keystroke happen within 300ms?". longer: you pressed escape-then-character. shorter: you pressed alt-character.

we've been exploiting this ambiguity a bit by binding something to it. as long as you hit escape twice, within 300 ms, the shell read it as alt+escape rather than escape pause escape, and executed whatever you had bound to alt+escape. you can test this out and confirm that it still works (by pressing alt+escape after binding \e\e).

unfortunately, having such a long delay causes trouble for other things. specifically, for vi mode, where it's far more likely that you'll type something like escape pause h, intending to treat them as separate keystrokes and not alt+h (see fish-shell/fish-shell#3904 for more). so in 3.1 fish changed the default delay to 30ms instead of 300, effectively closing the loophole we were exploiting.

technically, it still works. as long as you can rapid-fire hit escape twice within 30ms, you'll get sudope. unfortunately, that's pretty much impossible :)

luckily when they closed the loophole, they added an override. you can set -g fish_escape_delay_ms 300 somewhere in your config to restore the previous delay. or you can change it to any number between 10 and 5000 to tune it for how fast you double-escape!

Interesting! I can confirm that "Press and hold ESC" did work. Anyway I'd like to keep the default delay as it is. I'll just set the keybinding to something else. Cheers for the info @bobthecow