4

In bash I have my PROMPT set like so

PS1="$(scutil --get ComputerName) \W\\$ "

Where I only see the computer name and only the name of the current directory that I am in, not the full path and a $ sign.

my-computer my-folder$

My question is how can I set up my zsh prompt to be just like the bash one. I've been googling around, but the solutions I've found are not exactly what I am looking for.

  • Have you tried PS1='\h \W\$ ' in bash? – creidhne Aug 3 '16 at 20:16
11

See the EXPANSION OF PROMPT SEQUENCES and SIMPLE PROMPT ESCAPES sections of the zsh manual page at man zshmisc.

This prompt string, PS1='%m %1d$ ', displays the machine name (%m) and the trailing component of the current path (%1d).

|improve this answer|||||
  • 2
    man page are always good help indeed :) using %~ to have prompt with home replaced by ~. – nolazybits Dec 18 '18 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.