{"action":"created","issue":{"url":"https://api.github.com/repos/magicmonty/bash-git-prompt/issues/163","labels_url":"https://api.github.com/repos/magicmonty/bash-git-prompt/issues/163/labels{/name}","comments_url":"https://api.github.com/repos/magicmonty/bash-git-prompt/issues/163/comments","events_url":"https://api.github.com/repos/magicmonty/bash-git-prompt/issues/163/events","html_url":"https://github.com/magicmonty/bash-git-prompt/issues/163","id":106405574,"number":163,"title":"RFE: highlight directory component of git root","user":{"login":"jlebon","id":11934099,"avatar_url":"https://avatars.githubusercontent.com/u/11934099?v=3","gravatar_id":"","url":"https://api.github.com/users/jlebon","html_url":"https://github.com/jlebon","followers_url":"https://api.github.com/users/jlebon/followers","following_url":"https://api.github.com/users/jlebon/following{/other_user}","gists_url":"https://api.github.com/users/jlebon/gists{/gist_id}","starred_url":"https://api.github.com/users/jlebon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlebon/subscriptions","organizations_url":"https://api.github.com/users/jlebon/orgs","repos_url":"https://api.github.com/users/jlebon/repos","events_url":"https://api.github.com/users/jlebon/events{/privacy}","received_events_url":"https://api.github.com/users/jlebon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-14T18:54:08Z","updated_at":"2015-09-15T18:59:23Z","closed_at":null,"body":"It would be great if when inside a git repository, instead of just printing the current directory, it also highlights the part of the path corresponding to the repository's root directory. For example,\r\n\r\n> 14:46 $ cd tmp\r\n> ✔ /tmp/tmp \r\n> 14:46 $ git init myrepo\r\n> Initialized empty Git repository in /tmp/myrepo/.git/\r\n> ✔ /tmp \r\n> 14:47 $ cd myrepo/\r\n> ✔ /tmp/**myrepo** [master|✔] \r\n> 14:47 $ mkdir subdir\r\n> ✔ /tmp/**myrepo** [master|✔] \r\n> 14:47 $ cd subdir/\r\n> ✔ /tmp/**myrepo**/subdir [master|✔] \r\n> 14:47 $ \r\n\r\n(Notice the bolding). That way, we can quickly know (1) which repository we're in, and (2) how deep we are (useful when typing relative paths)."},"comment":{"url":"https://api.github.com/repos/magicmonty/bash-git-prompt/issues/comments/140501697","html_url":"https://github.com/magicmonty/bash-git-prompt/issues/163#issuecomment-140501697","issue_url":"https://api.github.com/repos/magicmonty/bash-git-prompt/issues/163","id":140501697,"user":{"login":"ogr3","id":564204,"avatar_url":"https://avatars.githubusercontent.com/u/564204?v=3","gravatar_id":"","url":"https://api.github.com/users/ogr3","html_url":"https://github.com/ogr3","followers_url":"https://api.github.com/users/ogr3/followers","following_url":"https://api.github.com/users/ogr3/following{/other_user}","gists_url":"https://api.github.com/users/ogr3/gists{/gist_id}","starred_url":"https://api.github.com/users/ogr3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ogr3/subscriptions","organizations_url":"https://api.github.com/users/ogr3/orgs","repos_url":"https://api.github.com/users/ogr3/repos","events_url":"https://api.github.com/users/ogr3/events{/privacy}","received_events_url":"https://api.github.com/users/ogr3/received_events","type":"User","site_admin":false},"created_at":"2015-09-15T18:59:23Z","updated_at":"2015-09-15T18:59:23Z","body":"A little test theme that does what you want. It might be slow - if there is a way to determine if we are inside a repo we should't do that check again here for instance, but it might be a way forward.\r\n\r\n```bash\r\noverride_git_prompt_colors() {\r\n  GIT_PROMPT_THEME_NAME=\"Custom\"\r\n\r\n #Overrides the prompt_callback function used by bash-git-prompt\r\n function prompt_callback {\r\n    local repo=$(git rev-parse --show-toplevel 2> /dev/null)\r\n    if [[ -n \"$repo\" ]]; then\r\n      #Get name of git root\r\n      local current=$(basename $repo)\r\n      #Use sed to highlight first occurrence of git root:\r\n      echo -n ${PWD} |sed \"s/${current}/$(tput bold)${current}$(tput sgr0)$(tput setaf 3)/1\"\r\n    else\r\n      echo -n ${PWD}\r\n    fi\r\n}\r\n\r\n  Time12a=\"\\$(date +%H:%M)\"\r\n  \r\n  GIT_PROMPT_START_USER=\"_LAST_COMMAND_INDICATOR_ ${Yellow}\"\r\n  GIT_PROMPT_START_ROOT=\"${GIT_PROMPT_START_USER}\"\r\n  GIT_PROMPT_END_USER=\"\\n${White}${Time12a}${ResetColor} $ \"\r\n  GIT_PROMPT_END_ROOT=\"\\n${White}${Time12a}${ResetColor} # \"\r\n}\r\n\r\nreload_git_prompt_colors \"Custom\"\r\n```"}}