3

I'm trying out Fish shell in OS X and was wondering if there's the same kind of path replacement functionality as I believe there is in Zsh, i.e.

user@machine ~> % cd /usr/www/site1/current/log user@machine /usr/www/site1/current/log %> cd site1 site2 /usr/www/site2/current/log user@machine /usr/www/site2/current/log %> 

The example is taken - and customized - from the SlideShare Why Zsh is Cooler than Your Shell.

I tried that in Fish but it doesn't seem to work, at least using the same syntax. I haven't found anything with "path replacement" in Fish documentation, either.

1
  • 1
    You'll find that fish is very nice for colors and tab completion, but it does not have many of these kinds of features: fishshell.com/docs/current/design.html Commented Sep 11, 2015 at 21:30

1 Answer 1

5

Apparently Fish doesn't support path replacement out of the box.

I solved the problem by creating a simple custom function in ~/.config/fish/functionscalled cd.fish:

function cd if test (count $argv) -eq 2 builtin cd (echo $PWD|sed -e "s/$argv[1]/$argv[2]/") else builtin cd $argv end end 

This is probably not perfect for anyone who is used to Zsh but does make the example in the question work.

Note: Fish has its own version of the cd function already, so it's better to make this part of Fish's out-of-the-box version than replace it completely. This is only a partial example for clarity.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.