{"thread":{"id":"20181","subject":"[PATCH] Show the presence of untracked files in the bash prompt.","startedAt":"2009-07-21T17:14:45Z","lastAt":"2009-07-24T15:03:17Z","messageCount":4,"participants":["Daniel Trstenjak","Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"118387","messageId":"20090721171445.GA25762@bug.science-computing.de","threadId":"20181","inReplyTo":null,"subject":"[PATCH] Show the presence of untracked files in the bash prompt.","fromName":"Daniel Trstenjak","fromEmail":"daniel.trstenjak@science-computing.de","sentAt":"2009-07-21T17:14:45Z","receivedAt":"2009-07-21T17:14:45Z","isPatch":true,"sender":{"key":"daniel.trstenjak@science-computing.de","avatar":null},"body":"Added the envvar GIT_PS1_SHOWUNTRACKEDFILES to 'git-completion.bash'.\nWhen set to a nonempty value, then the char '%' will be shown next\nto the branch name in the bash prompt.\n\nSigned-off-by: Daniel Trstenjak <daniel.trstenjak@science-computing.de>\n---\n contrib/completion/git-completion.bash |   16 ++++++++++++++--\n 1 files changed, 14 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 887731e..4c0f7d2 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -44,6 +44,10 @@\n #       GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed,\n #       then a '$' will be shown next to the branch name.\n #\n+#       If you would like to see if there're untracked files, then you can\n+#       set GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're\n+#       untracked files, then a '%' will be shown next to the branch name.\n+#\n # To submit patches:\n #\n #    *) Read Documentation/SubmittingPatches\n@@ -132,6 +136,7 @@ __git_ps1 ()\n \t\tlocal w\n \t\tlocal i\n \t\tlocal s\n+\t\tlocal u\n \t\tlocal c\n \n \t\tif [ \"true\" = \"$(git rev-parse --is-inside-git-dir 2>/dev/null)\" ]; then\n@@ -156,12 +161,19 @@ __git_ps1 ()\n \t\t\tif [ -n \"${GIT_PS1_SHOWSTASHSTATE-}\" ]; then\n \t\t\t        git rev-parse --verify refs/stash >/dev/null 2>&1 && s=\"$\"\n \t\t\tfi\n+\n+\t\t\tif [ -n \"${GIT_PS1_SHOWUNTRACKEDFILES-}\" ]; then\n+\t\t\t   local num_untracked_files=$(git ls-files --others --exclude-standard | wc -l)\n+\t\t\t   if [ $num_untracked_files -gt \"0\" ]; then\n+\t\t\t      u=\"%\"\n+\t\t\t   fi\n+\t\t\tfi\n \t\tfi\n \n \t\tif [ -n \"${1-}\" ]; then\n-\t\t\tprintf \"$1\" \"$c${b##refs/heads/}$w$i$s$r\"\n+\t\t\tprintf \"$1\" \"$c${b##refs/heads/}$w$i$s$u$r\"\n \t\telse\n-\t\t\tprintf \" (%s)\" \"$c${b##refs/heads/}$w$i$s$r\"\n+\t\t\tprintf \" (%s)\" \"$c${b##refs/heads/}$w$i$s$u$r\"\n \t\tfi\n \tfi\n }\n-- \n1.6.2\n\n\n-- \n                                                                                                                                           \n Daniel Trstenjak         Tel   : +49 (0)7071-9457-264\n science + computing ag   FAX   : +49 (0)7071-9457-511\n Hagellocher Weg 73       mailto: Daniel.Trstenjak@science-computing.de\n D-72070 Tübingen         WWW   : http://www.science-computing.de/                                                                      \n-- \nVorstand/Board of Management:\nDr. Bernd Finkbeiner, Dr. Roland Niemeier, \nDr. Arno Steitz, Dr. Ingrid Zech\nVorsitzender des Aufsichtsrats/\nChairman of the Supervisory Board:\nMichel Lepert\nSitz/Registered Office: Tuebingen\nRegistergericht/Registration Court: Stuttgart\nRegisternummer/Commercial Register No.: HRB 382196 \n"},{"id":"118388","messageId":"20090721171952.GS11191@spearce.org","threadId":"20181","inReplyTo":"20090721171445.GA25762@bug.science-computing.de","subject":"Re: [PATCH] Show the presence of untracked files in the bash prompt.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-07-21T17:19:52Z","receivedAt":"2009-07-21T17:19:52Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Daniel Trstenjak <daniel.trstenjak@science-computing.de> wrote:\n> Added the envvar GIT_PS1_SHOWUNTRACKEDFILES to 'git-completion.bash'.\n> When set to a nonempty value, then the char '%' will be shown next\n> to the branch name in the bash prompt.\n> @@ -156,12 +161,19 @@ __git_ps1 ()\n>  \t\t\tif [ -n \"${GIT_PS1_SHOWSTASHSTATE-}\" ]; then\n>  \t\t\t        git rev-parse --verify refs/stash >/dev/null 2>&1 && s=\"$\"\n>  \t\t\tfi\n> +\n> +\t\t\tif [ -n \"${GIT_PS1_SHOWUNTRACKEDFILES-}\" ]; then\n> +\t\t\t   local num_untracked_files=$(git ls-files --others --exclude-standard | wc -l)\n> +\t\t\t   if [ $num_untracked_files -gt \"0\" ]; then\n\nWouldn't using -n be easier here?\n\n   if [ -n \"$(git ls-files --others --exclude-standard)\" ]; then\n\n-- \nShawn.\n"},{"id":"118456","messageId":"20090722083134.GK24439@bug.science-computing.de","threadId":"20181","inReplyTo":"20090721171952.GS11191@spearce.org","subject":"Re: [PATCH] Show the presence of untracked files in the bash prompt.","fromName":"Daniel Trstenjak","fromEmail":"trsten@science-computing.de","sentAt":"2009-07-22T08:31:34Z","receivedAt":"2009-07-22T08:31:34Z","isPatch":true,"sender":{"key":"daniel.trstenjak@gmail.com","avatar":null},"body":"\nAdded the envvar GIT_PS1_SHOWUNTRACKEDFILES to 'git-completion.bash'.\nWhen set to a nonempty value, then the char '%' will be shown next\nto the branch name in the bash prompt.\n\nSigned-off-by: Daniel Trstenjak <daniel.trstenjak@science-computing.de>\n---\n contrib/completion/git-completion.bash |   15 +++++++++++++--\n 1 files changed, 13 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 887731e..745b5fb 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -44,6 +44,10 @@\n #       GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed,\n #       then a '$' will be shown next to the branch name.\n #\n+#       If you would like to see if there're untracked files, then you can\n+#       set GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're\n+#       untracked files, then a '%' will be shown next to the branch name.\n+#\n # To submit patches:\n #\n #    *) Read Documentation/SubmittingPatches\n@@ -132,6 +136,7 @@ __git_ps1 ()\n \t\tlocal w\n \t\tlocal i\n \t\tlocal s\n+\t\tlocal u\n \t\tlocal c\n \n \t\tif [ \"true\" = \"$(git rev-parse --is-inside-git-dir 2>/dev/null)\" ]; then\n@@ -156,12 +161,18 @@ __git_ps1 ()\n \t\t\tif [ -n \"${GIT_PS1_SHOWSTASHSTATE-}\" ]; then\n \t\t\t        git rev-parse --verify refs/stash >/dev/null 2>&1 && s=\"$\"\n \t\t\tfi\n+\n+\t\t\tif [ -n \"${GIT_PS1_SHOWUNTRACKEDFILES-}\" ]; then\n+\t\t\t   if [ -n \"$(git ls-files --others --exclude-standard)\" ]; then\n+\t\t\t      u=\"%\"\n+\t\t\t   fi\n+\t\t\tfi\n \t\tfi\n \n \t\tif [ -n \"${1-}\" ]; then\n-\t\t\tprintf \"$1\" \"$c${b##refs/heads/}$w$i$s$r\"\n+\t\t\tprintf \"$1\" \"$c${b##refs/heads/}$w$i$s$u$r\"\n \t\telse\n-\t\t\tprintf \" (%s)\" \"$c${b##refs/heads/}$w$i$s$r\"\n+\t\t\tprintf \" (%s)\" \"$c${b##refs/heads/}$w$i$s$u$r\"\n \t\tfi\n \tfi\n }\n-- \n1.6.2\n\n\n-- \n                                                                                                                                           \n Daniel Trstenjak         Tel   : +49 (0)7071-9457-264\n science + computing ag   FAX   : +49 (0)7071-9457-511\n Hagellocher Weg 73       mailto: Daniel.Trstenjak@science-computing.de\n D-72070 Tübingen         WWW   : http://www.science-computing.de/                                                                      \n-- \nVorstand/Board of Management:\nDr. Bernd Finkbeiner, Dr. Roland Niemeier, \nDr. Arno Steitz, Dr. Ingrid Zech\nVorsitzender des Aufsichtsrats/\nChairman of the Supervisory Board:\nMichel Lepert\nSitz/Registered Office: Tuebingen\nRegistergericht/Registration Court: Stuttgart\nRegisternummer/Commercial Register No.: HRB 382196 \n"},{"id":"118630","messageId":"20090724150317.GW11191@spearce.org","threadId":"20181","inReplyTo":"20090722083134.GK24439@bug.science-computing.de","subject":"Re: [PATCH] Show the presence of untracked files in the bash prompt.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-07-24T15:03:17Z","receivedAt":"2009-07-24T15:03:17Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Daniel Trstenjak <trsten@science-computing.de> wrote:\n> \n> Added the envvar GIT_PS1_SHOWUNTRACKEDFILES to 'git-completion.bash'.\n> When set to a nonempty value, then the char '%' will be shown next\n> to the branch name in the bash prompt.\n> \n> Signed-off-by: Daniel Trstenjak <daniel.trstenjak@science-computing.de>\n\nAcked-by: Shawn O. Pearce <spearce@spearce.org>\n\n\n> ---\n>  contrib/completion/git-completion.bash |   15 +++++++++++++--\n>  1 files changed, 13 insertions(+), 2 deletions(-)\n> \n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 887731e..745b5fb 100755\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -44,6 +44,10 @@\n>  #       GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed,\n>  #       then a '$' will be shown next to the branch name.\n>  #\n> +#       If you would like to see if there're untracked files, then you can\n> +#       set GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're\n> +#       untracked files, then a '%' will be shown next to the branch name.\n> +#\n>  # To submit patches:\n>  #\n>  #    *) Read Documentation/SubmittingPatches\n> @@ -132,6 +136,7 @@ __git_ps1 ()\n>  \t\tlocal w\n>  \t\tlocal i\n>  \t\tlocal s\n> +\t\tlocal u\n>  \t\tlocal c\n>  \n>  \t\tif [ \"true\" = \"$(git rev-parse --is-inside-git-dir 2>/dev/null)\" ]; then\n> @@ -156,12 +161,18 @@ __git_ps1 ()\n>  \t\t\tif [ -n \"${GIT_PS1_SHOWSTASHSTATE-}\" ]; then\n>  \t\t\t        git rev-parse --verify refs/stash >/dev/null 2>&1 && s=\"$\"\n>  \t\t\tfi\n> +\n> +\t\t\tif [ -n \"${GIT_PS1_SHOWUNTRACKEDFILES-}\" ]; then\n> +\t\t\t   if [ -n \"$(git ls-files --others --exclude-standard)\" ]; then\n> +\t\t\t      u=\"%\"\n> +\t\t\t   fi\n> +\t\t\tfi\n>  \t\tfi\n>  \n>  \t\tif [ -n \"${1-}\" ]; then\n> -\t\t\tprintf \"$1\" \"$c${b##refs/heads/}$w$i$s$r\"\n> +\t\t\tprintf \"$1\" \"$c${b##refs/heads/}$w$i$s$u$r\"\n>  \t\telse\n> -\t\t\tprintf \" (%s)\" \"$c${b##refs/heads/}$w$i$s$r\"\n> +\t\t\tprintf \" (%s)\" \"$c${b##refs/heads/}$w$i$s$u$r\"\n>  \t\tfi\n>  \tfi\n>  }\n> -- \n> 1.6.2\n> \n> \n> -- \n>                                                                                                                                            \n>  Daniel Trstenjak         Tel   : +49 (0)7071-9457-264\n>  science + computing ag   FAX   : +49 (0)7071-9457-511\n>  Hagellocher Weg 73       mailto: Daniel.Trstenjak@science-computing.de\n>  D-72070 T?bingen         WWW   : http://www.science-computing.de/                                                                      \n> -- \n> Vorstand/Board of Management:\n> Dr. Bernd Finkbeiner, Dr. Roland Niemeier, \n> Dr. Arno Steitz, Dr. Ingrid Zech\n> Vorsitzender des Aufsichtsrats/\n> Chairman of the Supervisory Board:\n> Michel Lepert\n> Sitz/Registered Office: Tuebingen\n> Registergericht/Registration Court: Stuttgart\n> Registernummer/Commercial Register No.: HRB 382196 \n> \n> \n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n\n-- \nShawn.\n"}]}