-1

as explained in https://stackoverflow.com/a/2763014/2891692 i created for days many alias in my config file ~/.config/fish/config.fish and it works.

every new alias i add today don't work.

Example of not working alias:

alias bla  = "cd ~/Desktop" 
alias bla2  = "ls -a" 

enter image description here

but the alias i added before today. for example: alias gitStatus="git status"

enter image description here

full ~/.config/fish/config.fish here:

function fish_greeting
     echo 'try nr 5'
end
alias bla2  = "ls -a" 
alias gitStatus="git status"

each try i update the welcome message. this works

How could i fix this?

Error

if used alias bla = "cd ~/Desktop"

bla
Command 'bla' not found, did you mean:
  command 'bls' from deb bacula-sd (9.4.2-2ubuntu5)
...

if type part of the alias is first red. but its not a error (confused me first)

Operating System:

Kubuntu 20.04
KDE Plasma Version: 5.18.8
KDE Frameworks Version: 5.68.0
Qt Version: 5.12.8
Kernel Version: 5.13.0-41-generic
OS Type: 64-bit
3
  • 3
    You have spaces around the = , does it work if you write the alias with no spaces, like this: alias bla2="ls -a"?
    – terdon
    May 16 at 8:51
  • 1
    Then please edit your question to include that and the exact error you get when you try.
    – terdon
    May 16 at 11:35
  • While it doesn't contribute to your problem, I really suggest you read my answer to that same question on why you should not define aliases in your config.fish. That's the "bash/zsh" way of doing things -- Fish has better methods available. May 16 at 12:16

1 Answer 1

4

alias in fish takes arguments in one of two forms:

  • As two arguments, the name and the code (the csh syntax)
  • As one argument with a = separating the name and the code (the ksh syntax)

In your case, because you have spaces around the =, this passes it as three arguments to alias, which it won't understand.

In fact it should be printing an error:

alias: expected <= 2 arguments; got 3

So: Do

alias bla "cd ~/Desktop" 
alias bla2 "ls -a" 

or

alias bla="cd ~/Desktop" 
alias bla2="ls -a" 
2
  • found that it works also without the = with many spaces alias bla "cd ~/Desktop" yes now this error makes since to me alias: expected <= 2 arguments; got 3
    – SL5net
    May 16 at 12:22
  • 1
    Yes, that is how argument passing in shells typically works. Spaces outside of quotes separate words, but how many there are doesn't matter.
    – faho
    May 16 at 12:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.