Added bash PS1 prompt script
This commit is contained in:
11
.bashrc
Normal file
11
.bashrc
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Function to parse and display the current Git branch
|
||||||
|
parse_git_branch() {
|
||||||
|
# Check if inside a Git repository, suppress errors (2>/dev/null)
|
||||||
|
# Get branch list, filter for the line starting with '*', and remove the first two characters '* '
|
||||||
|
git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Define your custom PS1
|
||||||
|
# The format is: [Green]user@host [Blue]pwd[Yellow] (git-branch)[Default]$
|
||||||
|
export PS1="\\[\\033[01;32m\\]\\u@\\h\\[\\033[0m\\]:\\[\\033[01;34m\\]\\w\\[\\033[0;33m\\]\$(parse_git_branch)\\[\\033[0m\\]\\$ "
|
||||||
|
|
||||||
Reference in New Issue
Block a user