0

My current prompt looks like:

luke@Lukes-MacBook-Pro ~/Documents/abc %

which uses PROMPT='%n@%m %~ %# ' in my .zshrc file.

My .zshrc also contains cd abc since this is where I would like to start all terminal sessions from.

My aim is to have the prompt start at the abc directory and display subdirectories, always with abc as the starting point:

luke@Lukes-MacBook-Pro abc %

luke@Lukes-MacBook-Pro abc/subdirectory %

ie. remove ~/Documents/ from the prompt.

There are a number of posts which address similar issues, but these focus on shortening the length of prompt by limiting the number of characters (here for example)

AdminBee
  • 21,637
  • 21
  • 47
  • 71
lucas
  • 101
  • 2

1 Answers1

0

As for ZSH, I cannot get anything to work. I would assume that you could possibly do it if you could get the expression in tick marks (`) to expand into the variable, much like this:

Here is how to do it in BASH (put it in your .bashrc file):

cd /home/$USER/Documents/abc
export PS1='$USER@$HOSTNAME `echo $PWD | sed 's/\/home\/$USER\/Documents\/abc/abc/"` %~ %'

I apologize that this doesn't strictly answer your question, but I hope it does help.