1

I'm receiving the following error trying to customize my PS1 for git

Error:

bash: command substitution: line 1: syntax error near unexpected token `)'
bash: command substitution: line 1: `get_dir)'
bash: command substitution: line 1: syntax error near unexpected token `)'
bash: command substitution: line 1: `get_branch)'
bash: command substitution: line 1: syntax error near unexpected token `)'
bash: command substitution: line 1: `parse_git_dirty)'

My .bashrc

#...
function get_dir() {
    [[ ${PWD} == $HOME ]] && echo '~' || echo ${PWD##*/}
}
function get_branch() {
    [[ -d .git ]] && echo "$(git branch --show-current)" 
}
#...

Here's tricky! this first snipped worked perfectly on my Cygwin, but produce that error on Gitbash

export PS1="${LIGHTGREEN}\t${NC} ${PINK}\$(get_dir)${NC}${LIGHTBLUE} \$(get_branch) ${NC}${RED}\$(parse_git_dirty)${NC} \n${GREEN}$ ${NC}"

when I "fix it" using this syntax, I've got no error but it's NOT working dynamically. I Need to reload my .bashrc each time that I change the directory

export PS1="${LIGHTGREEN}\t${NC} ${PINK}`get_dir`${NC}${LIGHTBLUE} `get_branch` ${NC}${RED}`parse_git_dirty`${NC} \n${GREEN}$ ${NC}"

i.e. changed \$(get_dir) to get_dir

Result on Cygwin: PS1 result

0 Answers0