-5

How to have a command prompt in zsh?

This is what I want to have -

[username@host]-[short-directory-path]-[time]$

Currently it just gives hostname with a different prompt -

think-debian% hostname
think-debian

Can somebody help?

Update - I had read the zsh manpage in the sense that I skimmed through it, saw that there are whole lot of sections which means different manpages. I did grep/using regular expression for PS1 using / and using PS1 as pattern in quite a few of the manpages and not finding anything hence put it above.

  • Read man zsh, look for PS1. – waltinator Dec 13 '16 at 19:52
  • I had read in the sense that I skimmed through it, saw that there are whole lot of sections. I did grep/using regular expression for PS1 using ` and using PS1` as pattern in quite a few of the manpages before putting it above. – shirish Dec 13 '16 at 19:58
  • @waltinator updated my query with what I had done. – shirish Dec 13 '16 at 20:00
  • A simple search lead me to man zshmisc, the EXPANSION OF PROMPT SEQUENCES section. – waltinator Dec 13 '16 at 20:53
  • thanx, saw that, now how do I run that once to see if the command prompt looks like what I want. Any ideas ? – shirish Dec 13 '16 at 21:32
0

As you mention you set the PS1 environment variable. I believe you would want

export PS1="\u@\h-\W-\A"

you can set that and then see if it displays what you want. If so, add that to one of your shell startup files (like .zshrc). If it is not exactly what you want then tweak it using information from the zsh man pages.

0

Zsh and Bash are different. For zsh try this:

[username@host]-[short-directory-path]-[time]$

export PROMPT='[${ret_status}%{$fg[magenta]%}%n@%{$fg[red]%}%m]-[%{$fg[cyan]%}%c%{$reset_color%}]%{$fg_bold[blue]%}-[%T]%{$reset_color%}$ '

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.