powerlevel9k icon indicating copy to clipboard operation
powerlevel9k copied to clipboard

+vi-git-untracked should quote output from `git ls-files`

Open tlrdstd opened this issue 6 years ago • 13 comments

https://github.com/bhilburn/powerlevel9k/blob/master/functions/vcs.zsh#L18 is:

local untrackedFiles=$(command git ls-files --others --exclude-standard "${repoTopLevel}" 2> /dev/null)

and should be:

local untrackedFiles="$(command git ls-files --others --exclude-standard "${repoTopLevel}" 2> /dev/null)"

per https://unix.stackexchange.com/a/208622 about Zsh word-splitting.

Simple repro:

POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir vcs)
# in a clean git repo
mkdir untrackedDir && touch untrackedDir/one && touch untrackedDir/two
+vi-git-untracked:local:8: not valid in this context: untrackedDir/two

Impact:

  • vi-git-untracked:local:8: not valid in this context: <file> printed after every execution in this repo
  • prompt coloring is trashed because prompt generation bails out early

tlrdstd avatar Apr 15 '19 19:04 tlrdstd

Believe this is the root cause of #1101

tlrdstd avatar Apr 15 '19 19:04 tlrdstd

I have this problem and the correction works for me. Thx

Turiok avatar Apr 29 '19 20:04 Turiok

@tlrdstd @Turiok What's the output of echo $ZSH_VERSION on your system?

romkatv avatar Apr 30 '19 07:04 romkatv

@romkatv 5.0.7 :-/ I have a weird mix of Zsh versions, and hadn't realized when I filed this ticket that my work system is actually launching the older one. If you need to close this due to lack of support for old versions, I understand.

tlrdstd avatar Apr 30 '19 12:04 tlrdstd

It's not my call (I'm not a Powerlevel9k dev) but https://github.com/bhilburn/powerlevel9k/wiki/Minimum-System-Requirements says the minimum supported version is 5.1.

romkatv avatar Apr 30 '19 12:04 romkatv

To the devs: In Powerlevel10k, to avoid confusion when people have multiple versions of zsh installed, I have this piece of code at the top:

if ! autoload -U is-at-least || ! is-at-least 5.1; then
  () {
    >&2 echo -E "You are using ZSH version $ZSH_VERSION. The minimum required version for Powerlevel10k is 5.1."
    >&2 echo -E "Type 'echo \$ZSH_VERSION' to see your current zsh version."
    local def=${SHELL:c:A}
    local cur=${${ZSH_ARGZERO#-}:c:A}
    local cur_v=$($cur -c 'echo -E $ZSH_VERSION' 2>/dev/null)
    if [[ $cur_v == $ZSH_VERSION && $cur != $def ]]; then
      >&2 echo -E "The shell you are currently running is likely $cur."
    fi
    local other=${${:-zsh}:c}
    if [[ -n $other ]] && $other -c 'autoload -U is-at-least && is-at-least 5.1' &>/dev/null; then
      local other_v=$($other -c 'echo -E $ZSH_VERSION' 2>/dev/null)
      if [[ -n $other_v && $other_v != $ZSH_VERSION ]]; then
        >&2 echo -E "You have $other with version $other_v but this is not what you are using."
        if [[ -n $def && $def != ${other:A} ]]; then
          >&2 echo -E "To change your user shell, type the following command:"
          >&2 echo -E ""
          if [[ $(grep -F $other /etc/shells 2>/dev/null) != $other ]]; then
            >&2 echo -E "  echo ${(q-)other} | sudo tee -a /etc/shells"
          fi
          >&2 echo -E "  chsh -s ${(q-)other}"
        fi
      fi
    fi
  }
  return 1
fi

Consider adding something like this.

romkatv avatar Apr 30 '19 12:04 romkatv

My version on centos is 5.0.2 and i cant upgrade from it. any leads on what i can do?

chandrahas-abburi avatar Aug 19 '19 06:08 chandrahas-abburi

@tlrdstd @Turiok What's the output of echo $ZSH_VERSION on your system?

Sorry @romkatv I didn't see your comment. My version of ZSH is 5.7.1

Turiok avatar Aug 19 '19 09:08 Turiok

@tlrdstd @Turiok What's the output of echo $ZSH_VERSION on your system?

Sorry @romkatv I didn't see your comment. My version of ZSH is 5.7.1

Did you get it from zsh --version or from echo $ZSH_VERSION?

romkatv avatar Aug 19 '19 09:08 romkatv

My version on centos is 5.0.2 and i cant upgrade from it. any leads on what i can do?

Hi @chandrahas-abburi,

For my case I compiled zsh with the version 5.7.1

Turiok avatar Aug 19 '19 09:08 Turiok

@tlrdstd @Turiok What's the output of echo $ZSH_VERSION on your system?

Sorry @romkatv I didn't see your comment. My version of ZSH is 5.7.1

Did you get it from zsh --version or from echo $ZSH_VERSION?

It was echo $ZSH_VERSION.

echo $ZSH_VERSION
5.7.1
zsh --version
zsh 5.7.1 (x86_64-pc-linux-gnu)

Turiok avatar Aug 19 '19 09:08 Turiok

@Turiok

You get an error on vi-git-untracked:local:8 when using zsh 5.7.1? This is surprising because that error is caused by a bug in ZSH that was fixed in 5.1.

Perhaps you can try adding echo $ZSH_VERSION to vi-git-untracked to make sure it's indeed zsh 5.7.1 that executes the function and produces the error?

romkatv avatar Aug 19 '19 09:08 romkatv

@chandrahas-abburi

My version on centos is 5.0.2 and i cant upgrade from it. any leads on what i can do?

There are a few options.

  • Find a way to upgrade ZSH. See https://github.com/Powerlevel9k/powerlevel9k/issues/1355#issuecomment-522494257.
  • Port Powerlevel9k to ZSH 5.0.2 yourself.
  • Persuade someone else to port Powerlevel9k to ZSH 5.0.2.
  • Don't use Powerlevel9k.

romkatv avatar Aug 19 '19 09:08 romkatv