Created
September 20, 2018 20:51
-
-
Save ongun-kanat/4f6a731c6e1dc4413eebd22f0eb0a9c9 to your computer and use it in GitHub Desktop.
shellline
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
function git_branch_check { | |
branch=$(git branch 2>/dev/null | sed -n -e 's/^\* \(.*\)/\1/p') | |
if [ -z "$branch" ]; then | |
echo -e '\001\e[0;38;5;223;48;5;29m\002\001\e[1;38;5;15;48;5;29m\002' | |
else | |
echo -e '\001\e[0;38;5;223;48;5;166m\002\001\e[1;38;5;15;48;5;166m\002 '$branch' \001\e[0;38;5;166;48;5;29m\002\001\e[1;38;5;15;48;5;29m\002' | |
fi | |
} | |
user_block_start=$(if [[ ${EUID} == 0 ]]; then echo '\001\e[0;38;5;231;48;5;9;1m\002'; else echo '\001\e[0;38;5;231;48;5;31;1m\002'; fi) | |
user_block_end=$(if [[ ${EUID} == 0 ]]; then echo '\001\e[0;38;5;9;48;5;223m\002\001\e[1;38;5;0;48;5;223m\002'; else echo '\001\e[0;38;5;31;48;5;223m\002\001\e[1;38;5;0;48;5;223m\002'; fi) | |
PS1='$(if [[ $? -ne 0 ]]; then echo -e "\001\e[1;38;5;231;48;5;9m\002 ✗ \001\e[0;38;5;9;48;5;31m\002"; fi)'$user_block_start' \u '$user_block_end' \h $(git_branch_check) \W \[\e[0;38;5;29;49m\]\[\e[0m\] ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment