Home > Blockchain >  zsh prompt replace named directory with it's alias
zsh prompt replace named directory with it's alias

Time:05-21

As I understand, if you create an alias for a directory in your .zshrc file, that directory is now considered a "named directory". I could be mistaken there, so let me know.

Based on the documentation here, it sounds like if you use "%~" in your zsh prompt and the current working directory is a named directory, then the prompt should show the alias for the directory, rather than the full path (i.e. ~{alias}). This does not seem to be working for me currently and I'm having a hard time finding examples or posts regarding this.

In my .zshrc file I have an alias like repo = "~/src/apps/repo". My hope is that when I am in that directory, the zsh prompt would show ~repo, but it always shows the full thing.

Any help is greatly appreciated!

CodePudding user response:

In zsh, you can add a named directory with hash -d repo=~/src/apps/repo (not an alias). Also, ~ isn't expanded inside quotes, so you should remove them or use $HOME instead.

  • Related