Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [BUG]Filename autocompletion using git-bare repos (--git-dir=... --work-tree=...)
- X-seq: zsh-workers 51545
- From: Oliver Kiddle <opk@xxxxxxx>
- To: eliasghafari <eliasghafari@xxxxxxxxxxx>
- Cc: zsh-workers@xxxxxxx
- Subject: Re: [BUG]Filename autocompletion using git-bare repos (--git-dir=... --work-tree=...)
- Date: Thu, 09 Mar 2023 20:27:48 +0100
- Archived-at: <https://zsh.org/workers/51545>
- In-reply-to: <20230309123303.77hztdd63lvxafg4@eliaspc>
- List-id: <zsh-workers.zsh.org>
- References: <20230309123303.77hztdd63lvxafg4@eliaspc>
eliasghafari wrote:
> I'm using a git bare repo to manage my files with this alias: "alias config='git --git-dir=$HOME/.local/share/dotfiles --work-tree=$HOME'",
> While using git bare repo:
> config rm --cached <tab> doesn't show anything.
> So after investigating a bit, I found that the problem lied in the
> expansion of the address of the git-dir and I found that by modifying
> this line:
> (( $+opt_args[--git-dir] )) && local -x GIT_DIR=${(Q)${~opt_args[--git-dir]}} && printf("\n${(Q)${~opt_args[--git-dir]}}\n")
> which shows that the address passed to GIT_DIR is "$HOME/.local/share/dotfiles" without the "$HOME" being expanded to "/home/user".
>
> I fixed this by replacing the Q modifier with e, but please note that I
I would suggest you try using ~ instead of $HOME in your alias:
alias config='git --git-dir=~/.local/share/dotfiles --work-tree=~'
The tilde in ${~opt_args[--git-dir]}} ensures that tildes are expanded.
While using (e) is arguably the right thing to do, it will expand things
like command-substitution and we've always intentionally shied away
from expanding anything that could have side-effects when parsing the
command-line for completion.
The modifiers don't allow you to pick-and-choose expansions so there
isn't a trivial way to expand variable references without expanding more
problematic things.
Oliver
Messages sorted by:
Reverse Date,
Date,
Thread,
Author