How to rebind space to enter in fish shell when in normal mode (vi bindings) - fish

I want to be able to run the current command (as I would by hitting enter) bu hitting space while in normal mode, and while running the vi keybindings, in the fish shell.

You're looking for:
bind --mode default ' ' execute
You can add that to the fish_user_key_bindings function, or in config.fish.

Related

Run (neo)vim motions, both insert and normal mode headlessly through commands with stdin

I'm creating a vim game where the purpose is to use vim motions to alter a buffer. It's a web game so I would have to emulate the inputs being sent from the client to the server, one challenge is going from insert mode to normal mode somehow. I'm running neovim behind an API, and this is how I'm able to run things from the app/frontend:
$ echo "foo" | nvim --headless --clean +"norm l" +"%print" +"echo getpos('.')" +q! -
I'm echoing "foo" into vim and using the norm command to alter it.
Inside the +"norm l" command I'm able to input vim motions, in this case moving the cursor right one character.
It works well, however, it can only handle things through normal mode. If I were to input ifoo<Esc>, which for me would translate to i, foo and then hitting the escape key, <Esc> is treated as an literal. Same thing with <C-c> and jj.
$ echo "foo" | nvim --headless --clean +"norm ifoo<Esc>" +"%print" +"echo getpos('.')" +q! -
foo<Esc>foo
[0, 1, 8, 0]
Is there a way to do this that I'm not seeing?

Neovim: how to send keys to terminal emulator

When I open up a nvim terminal emulator and enter the following command, trying to execute command 'python':
:normal! ipython
It turned out the register content is pasted onto the screen, as if 'p' is pressed under normal mode, even if 'i' has been pressed in prior to (supposedly) enter terminal-insert mode.
This does not help either:
:execute "normal! ipython\<CR>"
Where have I gone wrong, and how could I do it correctly?
Alternatively I used termopen() to execute a command in the terminal on start, something like
:call termopen('python')
But still, no idea about how to do so with normal!.
:normal! ipython
doesn't mean "run the program". It means "switch to Normal mode and run !" which is a filter command; then run i that is switch to Insert mode and insert "python".
To run a command from the vim command line use
:!ipython

Fish is not returning to new line after executing bind

I'm binding Ctrl+f to fg so I can Ctrl+z and Ctrl+f back into vim. However after two times doing the combo twice, it ruins the terminal:
user#pc:~$ vim
Job 1, 'vim' has stopped
user#pc:~$ Send job 1, “vim” to foreground
Job 1, 'vim' has stopped
^F▉
Cursor is now not on a line (which begins with user#pc) and executing any command show it as string (^Fas example).
Pressing enter fixes this, but there should be a better solution.
Edit: using bind \cf 'fg; commandline -f repaint' shows the PS1, but it's still in text mode, meaning pressing Ctrl+f, doesn't run fg but outputs ^F.
Solution was to instad of using:
bind \cf 'fg'
use:
bind \cf 'fg; commandline -f execute'
It ocassionaly does an extra enter, but whatever.

Bind Ctrl-C in fish vi-mode to switch from insert mode to normal mode

I would like to use Ctrl-C to go from insert to normal mode in fish vi-mode, as I do in vim. I'm fairly new to fish and couldn't get it to work, though I tried this in my config.fish:
bind -M insert \cc set fish_bind_mode 'default'
Strangely I am able to go from Visual to Normal mode with Ctrl-C.
Thanks
Binding [ctrl-C] would require that you also change the stty intr character. Something that is currently impossible from within fish due to how it handles tty modes. You could, however, change it before starting fish. That would then free the character to be bound as you wish. Though you'll need to do this to get the correct behavior:
bind -M insert \cc 'set fish_bind_mode default; commandline -f repaint'

Emacsclient called by applescript can't find emacs server socket

The shell command
emacsclient -n -e '(make-remember-frame)'
works.
But the applescript
do shell script "emacsclient -n -e '(make-remember-frame)'"
just returns
emacsclient: can't find socket; have you started the server?
To start the server in Emacs, type \"M-x server-start\".
emacsclient: No socket or alternate editor. Please use:
--socket-name
--server-file (or environment variable EMACS_SERVER_FILE)
--alternate-editor (or environment variable ALTERNATE_EDITOR)
I rarely use this, but it has worked successfully in the past for various purposes. Perhaps you can modify it to suit your needs. The init.el or .emacs file must have (server-start) inside in order to make everything work. I have lots of stuff that loads when Emacs is activated for the first time, so I need a 5 second delay before emacsclient is called -- you can adjust the delay downward if your Emacs loads faster. If Emacs is already running, there is no need for a delay. You can comment out the verbal messages generated by say -- I used them this morning to test the conditions and make a minor adjustment to the script. The script contains a command-line example on line 4, which calls two Emacs functions. Of course, the path to your Emacs and emacsclient will need to be adjusted to wherever you have installed them on your computer.
# `(server-start)` must be inside `init.el` or `.emacs` file.
# This script can be used in the terimal: osascript path-to-script arguments
# Terminal Example:
# osascript /Users/HOME/.0.data/.0.emacs/.emacsclient.applescript "-e '(progn (dired \"/Applications\") (message \"Hello-World\!\"))'"
on run argv
set arg to item 1 of argv
set emacs to application "Emacs"
set appIsRunning to emacs is running
if appIsRunning then
say "Emacs is already running."
do shell script "/Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/MacOS/bin/emacsclient " & arg
else
tell application "/Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/MacOS/Emacs" to activate
say "Please wait five seconds for Emacs to load."
delay 5
do shell script "/Users/HOME/.0.data/.0.emacs/Emacs_06_01_2014.app/Contents/MacOS/bin/emacsclient " & arg
end if
end run