Function bound to a key in Fish shell requires me to press enter, how to avoid that? - fish

I have the following fish shell function
# gohome.fish
function gohome
cd ~
end
When I bind it with bind \eg gohome and press Alt+G I still have to press enter to invoke it. Is it possible to execute gohome immediately upon pressing Alt+G?

When I bind it with bind \eg gohome and press Alt+G I still have to press enter to invoke it.
You don't. The function is executed as soon as you press the key.
What happens is that your prompt isn't repainted to update the current directory, and pressing enter triggers that.
Do commandline -f repaint either in
bind \eg 'gohome; commandline -f repaint'
or in the function.

Related

What function does evil mode run when I press :w?

I was wondering what function evil mode ran when I pressed :w. I tried using C-h k and then I pressed :w but it only registed the : I pressed and showed me information about evil-ex function instead of showing me what function is run when I save the file using :w.
It's evil-write.
As you know, : call the function evil-ex, You can try to find related evil-ex-* variable which save the association list of command bindings and functions and I found it's evil-ex-commands.

VsCode Vim Extension command to enter insert mode

I am wondering what is the vim command that one can use to enter the insert mode? In other words, what command is executed when you press "i" from normal mode. I want to use this command to construct custom actions using "extension.multiCommand.execute". In particular, I want to bind cmd+D in visual mode such that after selecting a text, pressing cmd+D will first put me in the insert mode without changing the selection and then will add another cursor each time I press cmd+D to the next found instance of the selected text.
Thanks

How to create a key binding that inserts text in the Fish shell

I would like to save typing in the Fish shell by binding a key to a text. When I press the key, the text should be inserted into the shell. The effect should be the same as typing that text.
One of the problems is that the text should not be executed, just inserted. The closest I came is this experiment where the text "whoami" is inserted when I press Alt+G:
bind \eg "echo -n whoami"
However, when I press enter the command is not executed, so the effect is not the same as typing the text directly in the shell.
You want to modify the commandline, which incidentally is possible with the commandline builtin.
bind \eg "commandline -i whoami"

Expand completions automatically in fish shell?

I wonder if its possible to automatically expand completions menu, which arrives if you hit <tab>? To basically check for autocompletion under cursor every time you enter character, and not only when you hit tab? Thx.
Internaly fish tab completions are done by a fish binding:
bind -k btab complete-and-search
The wildcard binding is bound to self-insert:
bind '' self-insert
self insert adds the captured char passed from bind '' to the current command,
so when a is pressed it inserts a.
The bind command accepts more than one command, so to do this you would need
to wrap __fish_complete_command (Or whatever internal completion fucntion)
and bind it something like this bind '' self-insert command_complete_wrapper
Because in reality, youd would not want to bind to every input, only
a sane subset.
Good luck.

CMD Batch File With Muliple Inputs

I am trying to automate a command that prompts the users for their pin, the command in question;
tpmvscmgr.exe create /name "vSmartcard" /pin prompt /adminkey default generate
at this point you press enter, the next thing you see is
Enter Pin:
You enter the pin and press enter, then you get asked to confirm the pin before pressing enter again.
How can I automate this in a batch file, or in powershell? I haven't been able to find any commands that work in a similar way to even get a start on it.
I am not sure if the trick below work with your particular program; but even in this case, if the program prompts for an additional input it must be placed inside the parenheses next to the pin number. Perhaps this is enough for your needs...
#echo off
(
echo pinnum
echo pinnum
) | tpmvscmgr.exe create /name "vSmartcard" /pin prompt /adminkey default generate