Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash/zsh prompt displaying Git repository data right-aligned

Tags:

git

bash

prompt

zsh

I saw this in a Github video and would like the same right-aligned prompt in my shell.

How can I accomplish it?

or even better

Which prompt is used here?

enter image description here

like image 445
Hedge Avatar asked Feb 18 '16 08:02

Hedge


Video Answer


1 Answers

You do this by setting the RPROMPT zsh variable. Example: to display the current time,

RPROMPT='$(date +%T)'

Make sure the promptsubst option is set by looking at the output of setopt. If it isn't, use setopt promptsubst in your .zshrc or equivalent.

In your case, use the appropriate git command telling you the branch.

For the gory details, read man zshmisc, especially the section EXPANSION OF PROMPT SEQUENCES.

like image 114
Jens Avatar answered Oct 22 '22 00:10

Jens