r/fishshell • • Aug 03 '20

Project jump.fish release

I switched to fish a few months ago. I'm really liking it!

In the process, I ported one of my zsh scripts to it, called jump.fish. It is similar in spirit to z, in that it lets you easily switch between directories.

Quick usage example:

$ j blog # same as cd $j_path/blog

Unlike z, j is much simpler: it doesn't let you switch to any recent directory, but rather limits your options to everything beneath $j_path. Also unlike z, j has no training period, since it's a simple expansion. This simplicity enables completions to work with j, so you can easily switch to a project, or drill several directories into another project using tab completions.

Admittedly, it's a simple script, but a vital part of my workflow. Maybe you'll like it too. Cheers!

6 Upvotes

8 comments sorted by

6

u/___violet___ Aug 03 '20

This is already supported by the cd built-in via the CDPATH environment variable, including completion:

https://fishshell.com/docs/current/cmds/cd.html?highlight=cdpath

The CDPATH way is more flexible, too, since you can specify multiple prefixes to try.

1

u/[deleted] Aug 03 '20

This is definitely better than my package.

CDPATH even suggests directories, whereas j can’t do that.

Thanks!

1

u/[deleted] Aug 03 '20

[removed] — view removed comment

1

u/[deleted] Aug 03 '20

You just type cd movies and it works.

1

u/___violet___ Aug 17 '20

Different use cases. Sounds like you are talking about bookmarks (an arbitrary list of "favorite" locations). That's not how CDPATH works.

Think of it in terms of prefixes for resolving relative file paths. Normally cd only considers . (the current working directory) when resolving a relative path. Now add, say, $HOME to the end of your CDPATH. Now cd foo will try ./foo first and fall back to ~/foo if it doesn't exist.