The man page of bash has a section PROMPTING (shouting in the original), from which I only cite the beginning:
PROMPTING
When executing interactively, bash displays the primary prompt PS1 when it is ready to read a command,
and the secondary prompt PS2 when it needs more input to complete a command. Bash allows these prompt
strings to be customized by inserting a number of backslash-escaped special characters that are decoded
as follows:
\w the current working directory, with $HOME
abbreviated with a tilde (uses the value of the
PROMPT_DIRTRIM variable)
\W the basename of the current working directory,
with $HOME abbreviated with a tilde
You can include the result for a command - since I don't know git well enough, I use $(date +%S) as example:
PS1='\w $(date +%S) > '
I don't understand requirement 3. Is this a request how to define colors for ls?
Ah - from the question on U&L, I think you're asking for such a thing:
In ~/.bashrc I have an entry:
# enable color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ]; then
eval "`dircolors -b`"
alias ls='ls --color=auto'
fi
to use ls per default with --color=auto.
The Windows Git shell, which is really just bash, sets the prompt $PS1
to a long string that includes $(__git_ps1)
.
__git_ps1
is defined as a function, nearly 100 lines long, that prints the name of the current branch in parentheses.
/etc/profile
(which is C:\Program Files (x86)\Git\etc\profile
, at least on my system)) invokes /etc/git-completion.bash
, which defines the __git_ps1
function, sets $PS1
, defines some git-specific completions, among other things.
The git-completion.bash
used by Git Bash appears to be based on this.
Best Answer
Use the
vcs_info
function in the zsh user contributions (included in thezsh
package). Quick start:It's likely that you'll want to make the output prettier. Since that's matter of personal taste, I refer you to the examples in the documentation.