zsh-workers
 help / Atom feed
* ZSH vcs_info are not updated if alias is used
@ 2019-04-23  8:52 Goetz Epperlein
  2019-04-23  9:03 ` Roman Perepelitsa
  0 siblings, 1 reply; 5+ messages in thread
From: Goetz Epperlein @ 2019-04-23  8:52 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1.1: Type: text/plain, Size: 1316 bytes --]

Hello ZSH maintainers,

I have a bug regarding the vcs_info extension.

When I change my branch inside my zsh sadly it is not reflecting the
current branch if I use an alias, but works if I use git checkout <branch>
I traced the problem down to vcs_info as my theme is using it to render the
branch name, but do not know how to solve this.

[image: image.png]

I use oh-my-zsh and my custom theme for oh-my-zsh hosted on github
<https://github.com/lony/dotFiles/blob/master/ansible/roles/dotfiles/src/bash_zsh/.zsh_oh-my-zsh/themes/lony.zsh-theme>
.

My current zsh version is:

    ❯ zsh --version
    zsh 5.7.1 (x86_64-apple-darwin18.2.0)

My aliases look like the following:

    ❯ alias | grep gc
    gc='git checkout'
    gco='git commit'

My git version is:

    ❯ git --version
    git version 2.21.0

I run zsh inside tmux on a Mac using iTerm2, as everything is installed
with homebrew it is updated to the latest version.

Any ideas what could cause this and how to fix it?

I also posted this question on stackoverflow, if this is easier to answer
somehow:
https://stackoverflow.com/questions/55131008/zsh-vcs-info-are-not-updated-if-alias-is-used

This bug maybe related to users/20807

Any help would be appreciated.

Thank you and kind regards,
lony

[-- Attachment #1.2: Type: text/html, Size: 2525 bytes --]

[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 36609 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: ZSH vcs_info are not updated if alias is used
  2019-04-23  8:52 ZSH vcs_info are not updated if alias is used Goetz Epperlein
@ 2019-04-23  9:03 ` Roman Perepelitsa
  2019-04-23 10:39   ` Roman Perepelitsa
  0 siblings, 1 reply; 5+ messages in thread
From: Roman Perepelitsa @ 2019-04-23  9:03 UTC (permalink / raw)
  To: Goetz Epperlein; +Cc: zsh-workers

[-- Attachment #1.1: Type: text/plain, Size: 1907 bytes --]

The problem is here:
https://github.com/lony/dotFiles/blob/f5f1691499e7a95a3a2e4f1e0970f0ae46f4b40e/ansible/roles/dotfiles/src/bash_zsh/.zsh_oh-my-zsh/themes/lony.zsh-theme#L69
.

This code tries to avoid calling `vcs_info` unless the last command in the
history was a `git` command. This is liable to break in corner cases. E.g.,
if you change the state of a git repo in one shell, it won't be updated in
another.

Roman.

On Tue, Apr 23, 2019 at 10:54 AM Goetz Epperlein <lony_@gmx.de> wrote:

> Hello ZSH maintainers,
>
> I have a bug regarding the vcs_info extension.
>
> When I change my branch inside my zsh sadly it is not reflecting the
> current branch if I use an alias, but works if I use git checkout <branch>
> I traced the problem down to vcs_info as my theme is using it to render the
> branch name, but do not know how to solve this.
>
> [image: image.png]
>
> I use oh-my-zsh and my custom theme for oh-my-zsh hosted on github
> <https://github.com/lony/dotFiles/blob/master/ansible/roles/dotfiles/src/bash_zsh/.zsh_oh-my-zsh/themes/lony.zsh-theme>
> .
>
> My current zsh version is:
>
>     ❯ zsh --version
>     zsh 5.7.1 (x86_64-apple-darwin18.2.0)
>
> My aliases look like the following:
>
>     ❯ alias | grep gc
>     gc='git checkout'
>     gco='git commit'
>
> My git version is:
>
>     ❯ git --version
>     git version 2.21.0
>
> I run zsh inside tmux on a Mac using iTerm2, as everything is installed
> with homebrew it is updated to the latest version.
>
> Any ideas what could cause this and how to fix it?
>
> I also posted this question on stackoverflow, if this is easier to answer
> somehow:
>
> https://stackoverflow.com/questions/55131008/zsh-vcs-info-are-not-updated-if-alias-is-used
>
> This bug maybe related to users/20807
>
> Any help would be appreciated.
>
> Thank you and kind regards,
> lony
>

[-- Attachment #1.2: Type: text/html, Size: 3579 bytes --]

[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 36609 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: ZSH vcs_info are not updated if alias is used
  2019-04-23  9:03 ` Roman Perepelitsa
@ 2019-04-23 10:39   ` Roman Perepelitsa
  2019-04-28 18:05     ` Goetz Epperlein
  0 siblings, 1 reply; 5+ messages in thread
From: Roman Perepelitsa @ 2019-04-23 10:39 UTC (permalink / raw)
  To: Goetz Epperlein; +Cc: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1217 bytes --]

On Tue, Apr 23, 2019 at 11:03 AM Roman Perepelitsa
roman.perepelitsa@gmail.com <http://mailto:roman.perepelitsa@gmail.com>
wrote:

The problem is here:
> https://github.com/lony/dotFiles/blob/f5f1691499e7a95a3a2e4f1e0970f0ae46f4b40e/ansible/roles/dotfiles/src/bash_zsh/.zsh_oh-my-zsh/themes/lony.zsh-theme#L69
> .
>
I should’ve mentioned how you can fix it. The simplest fix is to add your
git aliases to the linked code. This, however, won’t fix all corner cases.
It might be possible to expand aliases there but it still won’t for
functions and scripts that call git.

An alternative solution is to call vcs_info from precmd hook on every
prompt. This will be correct but slow.

To solve the performance problem you can replace vcs_info with gitstatus
<https://github.com/romkatv/gitstatus>, which is over 10x faster. There is
an example
<https://github.com/romkatv/gitstatus/blob/master/zsh-prompt-example.zsh>
you can follow.

Powerlevel10k <https://github.com/romkatv/powerlevel10k> provides a turnkey
solution. It’s already integrated with gitstatus, it’s very fast, and very
flexible. You can configure Powerlevel10k to look like your current scheme,
if you like.

Roman.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: ZSH vcs_info are not updated if alias is used
  2019-04-23 10:39   ` Roman Perepelitsa
@ 2019-04-28 18:05     ` Goetz Epperlein
  2019-04-28 18:22       ` Roman Perepelitsa
  0 siblings, 1 reply; 5+ messages in thread
From: Goetz Epperlein @ 2019-04-28 18:05 UTC (permalink / raw)
  To: Roman Perepelitsa; +Cc: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1784 bytes --]

Hello Roman,

I looked into your solutions and found the brute force the easiest for me
<https://github.com/lony/dotFiles/blob/master/ansible/roles/dotfiles/src/bash_zsh/.zsh_oh-my-zsh/themes/lony.zsh-theme>
.

As match I liked your solution I do not like to install additional software.
Do you know if there will be any "merge" into vcs_info from your
enhancements?

Kind regards and thanks again,
Goetz

Am Di., 23. Apr. 2019 um 12:39 Uhr schrieb Roman Perepelitsa <
roman.perepelitsa@gmail.com>:

> On Tue, Apr 23, 2019 at 11:03 AM Roman Perepelitsa
> roman.perepelitsa@gmail.com <http://mailto:roman.perepelitsa@gmail.com>
> wrote:
>
> The problem is here:
>> https://github.com/lony/dotFiles/blob/f5f1691499e7a95a3a2e4f1e0970f0ae46f4b40e/ansible/roles/dotfiles/src/bash_zsh/.zsh_oh-my-zsh/themes/lony.zsh-theme#L69
>> .
>>
> I should’ve mentioned how you can fix it. The simplest fix is to add your
> git aliases to the linked code. This, however, won’t fix all corner cases.
> It might be possible to expand aliases there but it still won’t for
> functions and scripts that call git.
>
> An alternative solution is to call vcs_info from precmd hook on every
> prompt. This will be correct but slow.
>
> To solve the performance problem you can replace vcs_info with gitstatus
> <https://github.com/romkatv/gitstatus>, which is over 10x faster. There
> is an example
> <https://github.com/romkatv/gitstatus/blob/master/zsh-prompt-example.zsh>
> you can follow.
>
> Powerlevel10k <https://github.com/romkatv/powerlevel10k> provides a
> turnkey solution. It’s already integrated with gitstatus, it’s very fast,
> and very flexible. You can configure Powerlevel10k to look like your
> current scheme, if you like.
>
> Roman.
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: ZSH vcs_info are not updated if alias is used
  2019-04-28 18:05     ` Goetz Epperlein
@ 2019-04-28 18:22       ` Roman Perepelitsa
  0 siblings, 0 replies; 5+ messages in thread
From: Roman Perepelitsa @ 2019-04-28 18:22 UTC (permalink / raw)
  To: Goetz Epperlein; +Cc: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1415 bytes --]

On Sun, Apr 28, 2019 at 8:05 PM Goetz Epperlein <lony_@gmx.de> wrote:

> Hello Roman,
>
> I looked into your solutions and found the brute force the easiest for me
> <https://github.com/lony/dotFiles/blob/master/ansible/roles/dotfiles/src/bash_zsh/.zsh_oh-my-zsh/themes/lony.zsh-theme>
> .
>

> As match I liked your solution I do not like to install additional
> software.
>

That makes two of us.

Unfortunately, it's really difficult to use zsh without having to rely on
extra code from various git repositories. Things
like zsh-syntax-highlighting and zsh-autosuggestions are incredibly
convenient yet they aren't built-in. Everyone has to figure out a way to
install these plugins and to keep them up to date. Hence the proliferation
of plugin manager for ZSH. My favorite solution is put all your dotfiles in
a git repo (preferably a bare git repo, so that you can track your dotfiles
right where they are) and set up dependencies as git submodules. As long as
your dependencies don't require post-clone/post-pull processing, this works
well. Whatever your method is, you can use it to install gitstatus, too.
It's compatible with all plugins managers out there.

Do you know if there will be any "merge" into vcs_info from your
> enhancements?
>

I don't think anyone is working on it. If anyone decides to start this
effort, I'll support them as I can but I cannot commit to driving this
effort.

Roman.

>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-23  8:52 ZSH vcs_info are not updated if alias is used Goetz Epperlein
2019-04-23  9:03 ` Roman Perepelitsa
2019-04-23 10:39   ` Roman Perepelitsa
2019-04-28 18:05     ` Goetz Epperlein
2019-04-28 18:22       ` Roman Perepelitsa

zsh-workers

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-workers

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


AGPL code for this site: git clone https://public-inbox.org/ public-inbox