agkozak / zsh-z

Jump quickly to directories that you have visited "frecently." A native Zsh port of z.sh with added features.
MIT License
2.02k stars 76 forks source link

allow manually adding an alias for a directory #68

Closed jesseduffield closed 2 years ago

jesseduffield commented 2 years ago

For a while I've been using z api to go to my 'api' repo, however recently another path has ended up having a higher precedence and so I end up being sent to there. I would like to be able to do something like the following:

z --alias api /path/to/api

So that I'm locking the api string to that particular path.

Alternatively I can use a different tool to achieve this, but I feel like this functionality makes sense for z to include itself, if only for the sake of relying on muscle memory.

agkozak commented 2 years ago

My recommendation would be to use the Zsh builtin feature of named directories:

hash -d api=/path/to/api

That way you can type

 cd ~api

And you're there. If you enable setopt CDABLE_VARS, you don't have to type the tilde:

cd api

And if you enable setopt AUTOCD, you can just type

api
jesseduffield commented 2 years ago

Thanks for the quick response, I'll take that approach