-1

Context

So I finally give a try to Fish, and as one would expect I encounter some frictions due to differences with my usual routines.

The most astonishing for me, as for many other, was the absence of the bang operator. I'm fine with the lose of sudo !!, as the suggested function replacement seems even better to me, I named it gar which means "To make, compel (someone to do something); to cause (something to be done." However I'll need a replacement for !<abc><enter> which grab the last history line starting with <abc> and run it without further ado, suggestions are welcome.

Now, for the more personal things: - I use a Typematrix 2030 keyboard - I use a bépo layout - I like to configure default finger position keys with the most used actions

Aims

As on my keybord <enter> is well positioned and is semantically relevant for that, ideally I would like to achieve the following key binding:

  • ctrl-enter: accept the whole suggestion and run it without further confirmation
  • ctrl-tab: accept the whole suggestion and wait for further edit
  • alt-enter: redo the last command without further confirmation

But according to xev it appears that, at least with Gnome-terminal, this combinations are not recognized. Are they terminal that supports it? For now I remapped these three to <ctrl>-i, <alt>-i and <alt>-I respectively:

bind --preset \ci forward-char execute
bind --preset \ei forward-char
bind --preset \eI forward-word

This works as expected, but it seems that now the tab key will also map to the first item. I guess that tab map to <alt>-i at some point in the shell stack. I wasn't aware of that, so I don't know yet if it will be possible for Fish to separate each of them.

To manage jobs, I also came with

bind --preset \es fg
bind --preset \eS bg

The first works as expected, but the second one doesn't. With application like vim, the binding should be operated in the application configuration itself of course. But for things as trivial as yes, <alt>-S won't work as expected while <crl>-z continue to operate normally.

I also would like to bind some commands like ls -alh and git status --short to a directly executed command, showing the result bellow the currently edited line, allowing to further type seamlessly, but didn't find the way to do it yet.

Summary of remaining question

So here are my more precise questions summarised:

  • how do I bind the sleep signal to <alt>-S?
  • is there a terminal I can use where <alt>-<enter> and <ctrl>-<enter> works?
  • how to seamlessly run command while maintaining the current line edition in place?
  • can you bind something to <alt>-i without altering <tab>?
psychoslave
  • 2,783
  • 3
  • 27
  • 44

1 Answers1

1

how do I bind the sleep signal to -S?

What you are doing with bind \es fg is to alter a binding inside the shell.

But when you execute yes, the shell isn't currently in the foreground, so shell bindings don't apply.

What you'd have to do instead is change the terminal settings via stty susp \cs, but fish resets the terminal settings when executing commands (so you can't accidentally break them and end up in an unusable environment), so there currently is no way to do this in fish.

can you bind something to <alt>-i without altering <tab>?

Sure. You bind \ei. Which is escape+i, which is alt-i (because in a terminal alt is escape).

Your problem is with ctrl-i, which in the way terminals encode control+character is tab. The application receives an actual tab character, and at that point the information has been lost.

is there a terminal I can use where - and - works?

Most terminals should send \e\r for alt-enter. ctrl-enter again is unencodable with the usual code (because \r is ctrl-m), just like ctrl-tab is.

Any fix to this requires the terminal to encode these combination differently.

how to seamlessly run command while maintaining the current line edition in place?

I don't know what you mean by this. I'm guessing you want fish to remain open and editable while a command also runs in the foreground. That can't work. There's no way to synchronize output from two commands to a terminal, not with cursor movement being what it is.

faho
  • 14,470
  • 2
  • 37
  • 47
  • Thanks for the reply. Regarding the last point, consider this scenario: you type `git commit -am'` but you are not sure what you are about to commit. You type say `-g`, you get the `git diff` diplayed, either bellow the current line or in your pager if it is too long, after what you continue to type your command where it was before `-g`. – psychoslave May 16 '20 at 08:57
  • 1
    In that case use something like `bind \cg 'git diff; commandline -f repaint'`. This will execute `git diff` and then repaint the commandline (because it's still *set*, but not visible because fish doesn't know the binding altered what is displayed) – faho May 16 '20 at 10:23