July 2018
Intermediate to advanced
354 pages
10h 57m
English
To make use of the Command Prompt, we must change the PS1 variable; usually this is set to something like the following:
PS1='u@h:w$ '
The preceding command shows the current user, an @ sign, the hostname, the current working directory relative to the user's home directory, and finally, the $ character:
john.doe@yggdrasil:~/cookbook-tips-tricks$
We can change this to add a branch name after the working directory by adding $(__git_ps1 " (%s)") to the PS1 variable:
PS1='u@h:w$(__git_ps1 " (%s)") $ '
Our prompt will now look like this:
john.doe@yggdrasil:~/cookbook-tips-tricks (master) $
It is also possible to show the state of the working tree, the index, and so on. We can enable these features by exporting some environment ...
Read now
Unlock full access