You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fish_config doesn't seem to install vars in prompts #1141
e.g. I run fish_config, under Informative Git Prompt I see:
set -g __fish_git_prompt_show_informative_status 1
set -g __fish_git_prompt_hide_untrackedfiles 1
set -g __fish_git_prompt_color_branch magenta bold
set -g __fish_git_prompt_showupstream "informative"
set -g __fish_git_prompt_char_upstream_ahead "↑"
set -g __fish_git_prompt_char_upstream_behind "↓"
set -g __fish_git_prompt_char_upstream_prefix ""
set -g __fish_git_prompt_char_stagedstate "●"
set -g __fish_git_prompt_char_dirtystate "✚"
set -g __fish_git_prompt_char_untrackedfiles "…"
set -g __fish_git_prompt_char_conflictedstate "✖"
set -g __fish_git_prompt_char_cleanstate "✔"
set -g __fish_git_prompt_color_dirtystate blue
set -g __fish_git_prompt_color_stagedstate yellow
set -g __fish_git_prompt_color_invalidstate red
set -g __fish_git_prompt_color_untrackedfiles $fish_color_normal
set -g __fish_git_prompt_color_cleanstate green bold
function fish_prompt --description 'Write out the prompt'
set -l last_status $status
if not set -q __fish_prompt_normal
set -g __fish_prompt_normal (set_color normal)
end
# PWD
set_color $fish_color_cwd
echo -n (prompt_pwd)
set_color normal
printf '%s ' (__fish_git_prompt)
if not test $last_status -eq 0
set_color $fish_color_error
end
echo -n '$ '
end
After clicking Use Prompt, the prompt is somewhat changed but the colors and symbols seem to be missing. The function has been added to ~/.config/fish/functions/fish_prompt.fish but not the set lines. Adding them to that file fixes the prompt.
Restarting fish did not seem to help.
Works just fine for me with latest fish (version 2.1.2-1225-g733108e). Global variables are set (and show up in the output of set -g), but are not in ~/.config/fish/functions/fish_prompt.fish. This is how it should be, since that file only stores the function, while the global vars go in ~/.config/fish/fishd.*
Yeah, this way to do it just isn't compatible with what webconfig.py currently does - it funcsaves the "fish_prompt" function after sourcing the file, so it won't save anything outside of it.
So we have two ways to solve it:
Audit all sample prompts and move everything into that function
Change webconfig to e.g. cp the file instead
Neither of those solutions will work with fish_right_prompt, though, but the former is more easily extended to also do that, and requires zero semantics changes.
So, I just completed the "audit", and only three prompts actually do something outside of fish_prompt (other than fish_right_prompt):
Informative Git - it sets a bunch of chars and colors for __fish_git_prompt, though I think they aren't different from the defaults anyway
Pythonista - it binds colors to variables and sets $VIRTUAL_ENV_DISABLE_PROMPT to "true", without using either of those - maybe they are used outside?
Terlar - it sets colors which I'm not sure we want the prompt to do
Others however also have comments outside of it, so those won't carry over to the user's copy of the prompt, so it's a bit hard to find out which prompt you're using by looking at the file.
I could now just push a simple move-into-function solution, but I'd rather look at it a bit deeper.
So, anyone know what $VIRTUAL_ENV_DISABLE_PROMPT is for?
Thanks for doing that @faho! From what I can tell, VIRTUAL_ENV_DISABLE_PROMPT is a virtualenv thing, used in Python development. It disables virtualenv replacing the prompt; that's justified since this prompt outputs data related to $VIRTUAL_ENV itself. I think we ought to keep that variable, though it can probably go inside the prompt if that's more convenient.
I've now pushed all necessary setup into the prompt functions, so no sample prompt should be doing anything outside of the fish_prompt or fish_right_prompt functions anymore.
In doing this, I've also removed what I deemed to be unnecessary (the pythonista prompt setting variables to colors and then not using them - I kept the virtualenv thing though) or wrong (the terlar prompt setting colors). If anyone takes issue with that, please open a dedicated issue.
Activity
snnw commentedon Mar 23, 2015
I'll take a look sometime this week.
snnw commentedon Mar 23, 2015
Works just fine for me with latest fish (version 2.1.2-1225-g733108e). Global variables are set (and show up in the output of set -g), but are not in ~/.config/fish/functions/fish_prompt.fish. This is how it should be, since that file only stores the function, while the global vars go in ~/.config/fish/fishd.*
walles commentedon Aug 28, 2015
I have the same issue with fish 2.2.0 on Mac OS X and "Informative Git Prompt".
The global vars aren't written to neither
~/.config/fish/functions/fish_prompt.fishnor~/.config/fish/fishd.*.It did work with the "Debian chroot" prompt, which makes me think it's the definition of Informative Git Prompt that is wrong in some way.
Those set commands for example, should they be "-g" or "-U"?
walles commentedon Aug 28, 2015
@mariuszs, do you know what's wrong here?
faho commentedon Aug 28, 2015
Yeah, this way to do it just isn't compatible with what webconfig.py currently does - it
funcsaves the "fish_prompt" function after sourcing the file, so it won't save anything outside of it.So we have two ways to solve it:
cpthe file insteadNeither of those solutions will work with fish_right_prompt, though, but the former is more easily extended to also do that, and requires zero semantics changes.
faho commentedon Aug 28, 2015
So, I just completed the "audit", and only three prompts actually do something outside of fish_prompt (other than fish_right_prompt):
Others however also have comments outside of it, so those won't carry over to the user's copy of the prompt, so it's a bit hard to find out which prompt you're using by looking at the file.
I could now just push a simple move-into-function solution, but I'd rather look at it a bit deeper.
So, anyone know what $VIRTUAL_ENV_DISABLE_PROMPT is for?
ridiculousfish commentedon Aug 31, 2015
Thanks for doing that @faho! From what I can tell,
VIRTUAL_ENV_DISABLE_PROMPTis a virtualenv thing, used in Python development. It disables virtualenv replacing the prompt; that's justified since this prompt outputs data related to$VIRTUAL_ENVitself. I think we ought to keep that variable, though it can probably go inside the prompt if that's more convenient.faho commentedon Aug 31, 2015
I've now pushed all necessary setup into the prompt functions, so no sample prompt should be doing anything outside of the fish_prompt or fish_right_prompt functions anymore.
In doing this, I've also removed what I deemed to be unnecessary (the pythonista prompt setting variables to colors and then not using them - I kept the virtualenv thing though) or wrong (the terlar prompt setting colors). If anyone takes issue with that, please open a dedicated issue.
Remove setup outside of fish_prompt from sample prompts