git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Show the presence of untracked files in the bash prompt.

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jul 21, 2009, 17:19 UTC
Message-ID
<20090721171952.GS11191@spearce.org>
In-Reply-To
<20090721171445.GA25762@bug.science-computing.de>
Daniel Trstenjak <daniel.trstenjak@science-computing.de> wrote:
Show 11 quoted lines
> Added the envvar GIT_PS1_SHOWUNTRACKEDFILES to 'git-completion.bash'.
> When set to a nonempty value, then the char '%' will be shown next
> to the branch name in the bash prompt.
> @@ -156,12 +161,19 @@ __git_ps1 ()
>  			if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
>  			        git rev-parse --verify refs/stash >/dev/null 2>&1 && s="$"
>  			fi
> +
> +			if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
> +			   local num_untracked_files=$(git ls-files --others --exclude-standard | wc -l)
> +			   if [ $num_untracked_files -gt "0" ]; then
Wouldn't using -n be easier here?
   if [ -n "$(git ls-files --others --exclude-standard)" ]; then
-- 
Shawn.
Previous: Daniel TrstenjakNext: Daniel Trstenjak
Message 2 of 4 in “Show the presence of untracked files in the bash prompt.”
  1. Show the presence of untracked files in the bash prompt.Daniel Trstenjak, Jul 21, 2009
  2. Shawn O. PearceJul 21, 2009
  3. Daniel TrstenjakJul 22, 2009
  4. Shawn O. PearceJul 24, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.