You are not logged in.

#1 2013-04-27 05:10:56

livinglifeback
Member
Registered: 2009-10-24
Posts: 29

[SOLVED] git script doesn't update prompt in zsh

I followed instructions on the wiki page for git copied the git-promp.sh to my home dir, source it .zshrc and then added the variables to my prompt.  The git status prompt does not update when I switch in or out of a directory or execute a command, but it does properly update if I source the .zshrc file manualy.

Shouldn't it update on every command or did i miss something?

Last edited by livinglifeback (2013-05-02 01:52:59)

Offline

#2 2013-04-27 10:21:27

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,553
Website

Re: [SOLVED] git script doesn't update prompt in zsh

It depends how the variables are used in your zshrc.  As a basher,  I don't remember exactly what they are called, but there are functions that are run before each command - you need to define your prompt there.  Also improper quoting will make these variables only be expanded once when the file is read rather than every time the prompt is evaluated.

I suspect the latter is the problem - but in either casse, posting the relevant part of your zshrc will sort it out.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2013-05-02 00:28:48

livinglifeback
Member
Registered: 2009-10-24
Posts: 29

Re: [SOLVED] git script doesn't update prompt in zsh

Sorry for taking so long to responding.

My prompt which I suppose would be an example of improper quoting is:

PROMPT="%{$terminfo[bold]%}%{$fg[blue]%}[%m]%{$fg[magenta]%}%1~%{$fg[green]%}$(__git_ps1 " (%s)")%{$fg[blue]%}>>%{$reset_color%} "

Switching either set of quotes to single quotes doesn't fix the issue.

How do I go about setting it to run after every command?

Offline

#4 2013-05-02 01:02:28

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,553
Website

Re: [SOLVED] git script doesn't update prompt in zsh

google quickly gave me this: http://unix.stackexchange.com/questions … the-prompt

The `setopt prompt_subst` looks to be exactly what you need - but as a non-zsh'er I can't verify this myself.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2013-05-02 01:52:32

livinglifeback
Member
Registered: 2009-10-24
Posts: 29

Re: [SOLVED] git script doesn't update prompt in zsh

Thanks, it was a combination of problems I solved it with

local gitval='%{$fg[green]%}$(__git_ps1 " (%s)")'

PROMPT="%{$terminfo[bold]%}%{$fg[blue]%}[%m]%{$fg[magenta]%}%1~${gitval}%{$fg[blue]%}>>%{$reset_color%} "

setopt promptsubst

Offline

Board footer

Powered by FluxBB