I received this excellent answer on how to convert a zsh function to a fish function. Now I have another question. How do I call that function from another function, passing on the argument?
I have tried this:
function ogf
echo "Cloning, your editor will open when clone has completed..."
source (env TARGET_DIRECTORY=~/students EDITOR=$EDITOR clone_git_file -ts $argv[1] | psub)
end
function wogf
env EDITOR=webstorm ogf "$argv[1]"
end
but I get "env: ogf: No such file or directory".
The goal is only to change the EDITOR
environment variable for this one execution, and then call ogf
.
The env
command can only run other external commands. It cannot call shell builtins or functions; regardless whether the shell is fish, bash, or something else. The solution is to define the function being called with the --no-scope-shadowing
flag and use set -l
in the calling function:
function ogf --no-scope-shadowing
echo "Cloning, your editor will open when clone has completed..."
source (env TARGET_DIRECTORY=~/students EDITOR=$EDITOR clone_git_file -ts $argv[1] | psub)
end
function wogf
set -l EDITOR webstorm
ogf $argv
end