write a bash prompt that show the current git brach additionally in
- User
write a bash prompt that show the current git brach additionally in
Assistant
To display the current Git branch in your bash prompt, you can add the following code to your
.bashrcor.bash_profilefile:parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' } export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "Here's what each line does:
parse_git_branch()is a function that retrieves the current Git branch name.git branch 2> /dev/nulllists all the Git branches, but we redirect the error output to/dev/nullto hide any errors that might occur if Git is not in the current directory.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.