bash - Append git's branch name to command prompt -
I have a guitar-completion. I want to use one of Bash features, but I can not customize the look I like. Here is the relevant part of my .bash_profile:
source ~ / .git-completion.bash function prompt {local WHITE = "\ [\ 033 [1; 37 m]" local GREEN = " \ [\ 033 [0; 32m] \ "Local CYAN =" \ [\ 033 [0; 36m] \ "local gray \" [\ 033 [0; 37m] \ "local blue \" \ [\ 033 [0, 34m] "Export PS1 =" $ {GREEN} \ u $ {CYAN} @ $ {BLUE} \ HK $ {CYAN} \ w $ (__ git_ps1 '(% s)') $ {GRAY } $ "} Prompt and it does not show the name of the branch.
However, if I export the above PS1 with one below, then it works as expected:
I think this is the subject of some apostrophe / quotation marks.
How to make it work 1 version to correct?
The trick to get quote rights to $ (__ git_ps1 "(% s)" Except double-quoted) , which is single-quoted
source ~ / .git-completion.bash function prompt {local WHITE = "\ [033 [1; 37 m]" local GREEN = "\ [\ 033 [0; 32 m] ] \ "Local CYAN =" \ [\ 033 [0; 36m] \ "local gray \" \ [\ 033 [0; 37 m] \ "local blue =" \ [\ $ 0 (0; 34 m) \ "Export PS1 =" $ {GREEN} \ u $ {CYAN} @ $ {BLUE} \ HK $ {CYAN} \ w $ "$ (__ git_ps1" (% s) ") '' $ {GRAY}"} Prompt is to replace \ $ (in the code in question) with $ ().
Background information : Two replacements take place: first exporting PS1 = ... ... on time and later when prompted The sign is displayed. You want to execute __git_ps1 is displayed every time, so you have to make sure that the first replacement $ (...) remains intact If you live then you type either '$ (...)' or "\ $ (...)" . I have two basic ideas behind the proposed solutions .
Comments
Post a Comment