Last active
June 15, 2018 08:59
-
-
Save AlexandroPerez/188dd7d5d7546009fb3c101837cb97f2 to your computer and use it in GitHub Desktop.
Cygwin and WSL colored bash prompt that shows current git branch if the folder is a git repo.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1]/' | |
} | |
# NOTE: The dollar sign ($) has to be escaped so that the above function is executed every time the prompt is shown | |
# like this: \$(git_branch) | |
export PS1="\[\e]0;\w\a\]\n\[\e[36m\]CygWin:\[\e[33m\]\w\[\e[0m\] \[\e[32m\]\[\e[1m\]\$(git_branch)\[\e[0m\]\n$ " | |
# For WSL | |
git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1]/' | |
} | |
# NOTE: The dollar sign ($) has to be escaped so that the above function is executed every time the prompt is shown | |
# like this: \$(git_branch) | |
export PS1="\[\e]0;\w\a\]\n\[\e[36m\]Bash:\[\e[33m\]\w\[\e[0m\] \[\e[35m\]\[\e[1m\]\$(git_branch)\[\e[0m\]\n$ " | |
# Change the way folders are displayed in terminal (green text green background) to just a teal text color) | |
LS_COLORS="ow=01;36;40" && export LS_COLORS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
color codes taken from: https://misc.flogisoft.com/bash/tip_colors_and_formatting