Parentheses are the fish syntax for command substitution. You have no choice but to escape the parentheses or quote the argument:
calc sqrt\(4\)
calc 'sqrt(4)'
In a simple case like this, you might prefer an abbreviation:
abbr -a calc 'octave --eval'
Then when you type calcspace, fish replaces that text with "octave --eval". (Still need to protect the parentheses in the argument though)
Can I make abbr to add " " automatically. So when i type calc Space i will apear 'octave --eval " " ' and my cursor will be in the quotes?
No, but you can do this with a key binding and a commandline
function.
function calc_binding
commandline -r 'octave --eval ""'
commandline -C (math (commandline -C) - 1)
end
# bind Alt+c to that function
bind \ec calc_binding
When you hit Alt-C, the current command line is replaced by octave --eval ""
and the cursor is placed one character back, before the ending double quote.
See bind --help
and bind -a
to see the current key bindings: think of a key sequence that's memorable for you, and bind -a
will show if it's available.