{"thread":{"id":"37751","subject":"__git_ps1_colorize__gitstring() in git_prompt.sh: colors are hardcoded?","startedAt":"2014-10-17T17:30:52Z","lastAt":"2014-10-20T14:45:35Z","messageCount":2,"participants":["nathdwek","Michael J Gruber"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"250798","messageId":"5441524C.6040302@ulb.ac.be","threadId":"37751","inReplyTo":null,"subject":"__git_ps1_colorize__gitstring() in git_prompt.sh: colors are hardcoded?","fromName":"nathdwek","fromEmail":"nathdwek@ulb.ac.be","sentAt":"2014-10-17T17:30:52Z","receivedAt":"2014-10-17T17:30:52Z","isPatch":false,"sender":{"key":"nathdwek@ulb.ac.be","avatar":null},"body":"Hello,\n\nIt seems to me that the colors used to indicate the repo's state in the\nprompt are hardcoded although the top comment says otherwise.\n\n>From contrib/completion/git-contrib.sh:\n\n[83]# If you would like a colored hint about the current dirty state, set\n# GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on\n# the colored output of \"git status -sb\" and are available only when\n# using __git_ps1 for PROMPT_COMMAND or precmd.\n\n[228]__git_ps1_colorize_gitstring ()\n{\n\tif [[ -n ${ZSH_VERSION-} ]]; then\n\t\tlocal c_red='%F{red}'\n\t\tlocal c_green='%F{green}'\n\t\tlocal c_lblue='%F{blue}'\n\t\tlocal c_clear='%f'\n\telse\n\t\t# Using \\[ and \\] around colors is necessary to prevent\n\t\t# issues with command line editing/browsing/completion!\n\t\tlocal c_red='\\[\\e[31m\\]'\n\t\tlocal c_green='\\[\\e[32m\\]'\n\t\tlocal c_lblue='\\[\\e[1;34m\\]'\n\t\tlocal c_clear='\\[\\e[0m\\]'\n\tfi\n\tlocal bad_color=$c_red\n\tlocal ok_color=$c_green\n\tlocal flags_color=\"$c_lblue\"\n\n\tlocal branch_color=\"\"\n\n\nAs expected upon seeing this snippet, the color.status.<slot> entries in\nthe git config file do modify the git status -sb output but don't modify\nthe colors used in the prompt.\n\nRegards,\n\nNathan\n"},{"id":"250855","messageId":"5445200F.1030003@drmicha.warpmail.net","threadId":"37751","inReplyTo":"5441524C.6040302@ulb.ac.be","subject":"Re: __git_ps1_colorize__gitstring() in git_prompt.sh: colors are hardcoded?","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2014-10-20T14:45:35Z","receivedAt":"2014-10-20T14:45:35Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"nathdwek schrieb am 17.10.2014 um 19:30:\n> Hello,\n> \n> It seems to me that the colors used to indicate the repo's state in the\n> prompt are hardcoded although the top comment says otherwise.\n> \n> From contrib/completion/git-contrib.sh:\n> \n> [83]# If you would like a colored hint about the current dirty state, set\n> # GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on\n> # the colored output of \"git status -sb\" and are available only when\n> # using __git_ps1 for PROMPT_COMMAND or precmd.\n\nThat should have said \"... on the default colors used for the colored\noutput of...\"\n\n> [228]__git_ps1_colorize_gitstring ()\n> {\n> \tif [[ -n ${ZSH_VERSION-} ]]; then\n> \t\tlocal c_red='%F{red}'\n> \t\tlocal c_green='%F{green}'\n> \t\tlocal c_lblue='%F{blue}'\n> \t\tlocal c_clear='%f'\n> \telse\n> \t\t# Using \\[ and \\] around colors is necessary to prevent\n> \t\t# issues with command line editing/browsing/completion!\n> \t\tlocal c_red='\\[\\e[31m\\]'\n> \t\tlocal c_green='\\[\\e[32m\\]'\n> \t\tlocal c_lblue='\\[\\e[1;34m\\]'\n> \t\tlocal c_clear='\\[\\e[0m\\]'\n> \tfi\n> \tlocal bad_color=$c_red\n> \tlocal ok_color=$c_green\n> \tlocal flags_color=\"$c_lblue\"\n> \n> \tlocal branch_color=\"\"\n> \n> \n> As expected upon seeing this snippet, the color.status.<slot> entries in\n> the git config file do modify the git status -sb output but don't modify\n> the colors used in the prompt.\n> \n> Regards,\n> \n> Nathan\n\nThe script could query config for these colors, but that would amount to\n4 additional forks and \"git config\" calls each time a prompt is\ngenerated. If you want the colors to be configurable, you should\nprobably rather introduce environment variables - or edit your copy of\nthe script ;)\n\nCheers,\nMichael\n"}]}