1

I'm trying to save some time in Fish Shell by setting an abbreviation (nu) to expand to the string:

my-username@my-ip-address:/home/my-username

What I'm hoping to achieve is to enter:

scp some-file nu

...then tab- or space- complete the nu abbreviation to expand it to the string I set in my config.fish.

I have more use cases for this functionality, but Fish doesn't seem to cover it. It offers abbreviations, but they only seem to work at the beginning of a command; I can't get them to work inline. Any ideas?

  • 2
    If all else fails, you could always set an environment variable and use $nu. – AFH Mar 17 at 14:43
  • I think this is what variables are for ;) unless you want to write a completion functionality just for this use case. Doesn't sound like fun. – Guy Gastineau Mar 17 at 15:02
1

Fish currently only allows abbreviation expansion in the command position. Which means, for example, it works after the | (pipe) symbol but not in the middle of a command. There have been many issues opened about it over the years. See

https://github.com/fish-shell/fish-shell/issues/5003

https://github.com/fish-shell/fish-shell/issues/1963

https://github.com/fish-shell/fish-shell/issues/1220

And probably several others. Also, note that abbreviation expansion only supports literal string substitution with no customization of the result (and that is unlikely to ever change). So if you want parts of the expansion (e.g., my-ip-address) to vary depending on factors like the system you're on you'll need to create the abbreviation when you start the shell.

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.