Last active
May 16, 2023 15:04
-
-
Save brianm/7684710 to your computer and use it in GitHub Desktop.
Encode $0 into color of hostname in PS1
This file contains hidden or 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
# assumes 256 color support, do your normal case thing, etc | |
local green="\[\033[38;5;156m\]" | |
local blue="\[\033[38;5;153m\]" | |
local red="\[\033[38;5;009m\]" | |
local reset="\[\033[00m\]" | |
local git_stuff='$(__git_ps1 "\[\033[31m\]<\[\033[01m\]%s\[\033[22m\]>\[\033[00m\]")' | |
local status_color="\$(if [ \$? = 0 ]; then echo \"${green}\"; else echo \"${red}\"; fi )" | |
PS1="${status_color}\h${reset}:${blue}\w${git_stuff}${reset}$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment