So, I recently downloaded a cli which shares a lot of commands similar to linux.
Like mega-login
: login
& mega-logout
:logout
and I am too tired of writing mega every time I need to use the cli.
I thought of using alias but I don't want to screw some other program that use the some other command I don't know of.
Like if I create an alias login
then what will happen to the system login
command? Plus there are a lot of commands in the cli.
So, I thought of using a script, but I didn't know how to do it.
Here what I had in my mind.
So when I use m login
or m logout
it will search if a command mega-login
or mega-logout
exists and then call it.
So I tried hours coming up with various functions while learning fish and this is what I wrote.
function m --argument value $argv
echo value $value $argv
if type mega-$value
set MEGA
for temp in $argv
set MEGA $MEGA$temp
echo $MEGA
end
echo MEGA \n\n $MEGA
eval $MEGA
end
end
This still doesn't work. PS: I wrote this on my first try, but I dropped it once I couldn't figure it out.
function m --argument value $argv
echo value $value $argv
if type mega-$value
set MEGA mega-$argv
echo $argv \n\n\n $MEGA
eval $MEGA
end
end