Alias how to in fish shell?

I want to run an alias in fish shell, so I don’t have to type zypperoni in full every time. .

I tried adding alias z=“zypperoni” to fish. conf but it’s not working when I type sudo z dup

Any suggestions??

Nice, I didn’t even know I have got this (in Leap). Did you use help ? Quite useful. You can search in the html docs. It will tell you that this is not stored in fish.conf - I actually don’t have that in fish 3.3.1. Here it’s ~/.config/fish/config.fish. But again, that’s not where the alias is stored. It’s in ~/.config/fish/fish_variables .
I tried the easy way, typing fish_config. This brings you a web-gui on localhost. There you go to “abbreviations” and enter your alias. I tried this with zz as alias for “zypper lr -d”.
It works like a charme. In in ~/.config/fish/fish_variables there’s now the line
SETUVAR _fish_abbr_zz:zypper\x20lr\x20\x2dd

No abbreviations shown in webui?

When you are using “sudo” it is likely to be using the aliases defined for root’s shell rather than for your shell.

I’ve used zyp too with same error, if it’s likely to be usingthe aliases defined for root’s shell what is a solution if any??

You could define a bash alias for the root user. My preference would be to not use aliases for this.

I found this blog post that might be helpful:

I do not run fish, but did you check with the fish documentation if it has such a feature as the alias?

I have no idea why you ever want to type zypperoni “all the time”, but when that is some executable program stored somewhere, then consider to change it’s name to z, or to make a symbolic (or even hard) link to it. Then all users can execute z as well as zypperoni as they like it.

And yes, creating an alias for user spaceboy (even if thatis possible for in fish ) does not mean that alias is also know in the environment of user root (which BTW des not use fish, but bash .

I never user sudo, so I may be wrong, but I read it will execute a command given in it’s invocation. Executing a command is just that, why do you think that a shell (even the startup shell of root ) is involved?

Yes, although from what I’ve read it’s not what I’m necessarily looking for. abbreviations are definitely nearer to what I want to do, possibly functions although I need to read up more on that.

Yes a hard/symbolic link would help problem. The link would have to reside in a /bin directory??? To be accessible to all users?

When you want to make it transparent to those who now (are able to) call zypperoni without full path, it is of course it is best to do that in the same directory as where zypperoni is so they can call z without full path.

You did not mention where it is, As you did not mention anything about that program. I can not see it in the OSS repo of Leap 15.5, thus, apart of it being something new in Slowroll, it is something you got elsewhere or of your own invention. Thus we know nothing of it.

1 Like

Symlinking worked without much issue, thanks. Now I just need to type zyp and I get zypper with parallel downloads and much much faster speeds

You are welcome.

I have no idea what you are talking about, but I assume that is not very important.

https://github.com/pavinjosdev/zypperoni

When it is simply one program put there, just giving it another name would have been sufficient, wouldn’t it?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.