-1

I have the following aliases in my zsh:

alias -- -='cd -'
alias ..='cd ..'
alias ...='cd ../..'

When I switch to fish, by manually typing fish and pressing Return, the first alias causes an error:

- (line 1): function: -: invalid function name
function -  --description 'alias -=cd -';  cd - $argv

How to workaround this?

1
  • 1
    +1 because no one deserves downvotes without an explanatory comment. Such downvotes come from cowards. Commented Mar 2 at 19:48

1 Answer 1

2

Fish does not allow functions with the name -. Since aliases are just functions, that also goes for aliases.

Call the alias something else or use an abbreviation:

abbr --add -- - 'cd -'

Loading zsh configuration is not something that fish does by default, or has any functionality for. It is not recommended because it will not work except in very narrow circumstances.

Something on your system, in your configuration or a third-party plugin you installed, tries to read the zsh configuration (e.g. via source ~/.zshrc).

3
  • You mean that when I switch from zsh to fish, zsh aliases are automatically converted to fish functions? Commented Mar 1 at 19:28
  • 1
    No I mean something is loading this alias in fish, and in fish alias is just a cheesy function that creates functions. Loading zsh configuration does not happen by default (and is not recommended, and will not work in general), so you're running source somewhere. Commented Mar 1 at 19:29
  • Ah, yes, I have set -Ux SKIP_FISH yes and source ~/scripts/aliases in config.fish. The aliases file is currently used for both zsh and fish. Commented Mar 1 at 19:33

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.