Re:Unix Tricks
by tambourine_man on Thursday July 03, 2014 @10:33AM
(#7983261)
Mine seems escaped as hell, but still gets wrapped. Anything I'm missing?
edit: couldn't get UTF-8 branch symbol to be properly displayed here, but this is how it looks:
http://i.imgur.com/zuq24gV.png?1
function fancyPrompt {
local bgBlue="\[\033[48;5;31m\]"
local fgBlue="\[\033[38;5;31m\]"
local fgWhite="\[\033[38;5;231m\]"
local bgDarkBlue="\[\033[48;5;24m\]"
local fgDarkBlue="\[\033[38;5;24m\]"
local bgDarkGray="\[\033[48;5;237m\]"
local bgLightGray="\[\033[48;5;245m\]"
local fgLightGray="\[\033[38;5;245m\]"
local colorClear="\[\033[0m"
local branch
local branch_symbol="\[\] "
if branch=$( { git symbolic-ref --quiet HEAD || git rev-parse --short HEAD; } 2>/dev/null ); then
branch=${branch##*/}
export PS1="${bgBlue}${fgWhite}\h${colorClear}${fgBlue}${bgDarkBlue}\[\] ${fgWhite}\w${bgLightGray}${fgDarkBlue}\[\] ${fgWhite}${branch_symbol}${branch}${fgLightGray}${bgDarkGray}\[\] ${colorClear}"
else
export PS1="${bgBlue}${fgWhite}\h${colorClear}${fgBlue}${bgDarkBlue}\[\] ${fgWhite}\w${bgDarkGray}${fgDarkBlue}\[\] ${colorClear}"
fi
}That's quite pretty. How do you get the triangles?
I've been loving a prompt which color codes git branches (which, if I understand right, would be built-in if I used zsh instead of bash) [0], though I have to edit the last line in order to get my history appendation working as well.
Re:Unix Tricks
by staticshock on Thursday July 03, 2014 @02:29PM
(#7984792)
It's Powerline: https://powerline.readthedocs.org/en/latest/introduction.htm...
Try not escaping around the triangles and branch symbols.
Are you escaping your color codes in PS1 correctly?
Bad:
Good (notice the extra \[ and \]):