I am a heavy Git on command line user. Since I work a lot with branches it is important to know which branch I am currently on. Here's a nifty trick for all of you juggling many branches simultaneously. While I could type git branch
every time and have a look at the result, this is pretty tedious. As there is always a command prompt visible on the command line, I was wondering what if the prompt instead of
MacDietrich:xtext-core dietrich$
would look like
MacDietrich:xtext-core[master] dietrich$
There is a solution for that: The magic PS1
environment variable that defines the prompt. We can simply change it to include the current git branch if there is one. I added following lines to my ~/.bash_profile
file
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1]/'
}
export PS1="\h:\W\$(parse_git_branch) \u$ "
and reloaded the ~/.bash_profile
file by typing source ~/.bash_profile
.
Problem solved.
Egal, ob in der Finanzbranche, im Versicherungswesen oder im Telekommunikationssektor, überall findest du Software mit einer langen Lebensdauer und einem hohen Anteil an Fachlichkeit. Diese Kombination im Legacy System kann zu Problemen führen, die du am besten ...
itemis AG
Am Brambusch 15
Lünen NRW 44536
+49-231-9860-606
info@itemis.com
Comments