markeissler / gvm2

Go enVironment Manager - Revision 2 (GVM2)
Other
38 stars 5 forks source link

gvm2 messes with my prompt #4

Open ghost opened 7 years ago

ghost commented 7 years ago
wes at Wes-Outreach-Macbook in ~ ⌚ 11:55:59 ‹ruby-2.3.3›
$ source "$HOME/.gvm/scripts/gvm"

[magenta]wes at [yellow]Wes-Outreach-Macbook in [green]~ ⌚ [red]11:56:01 [red]‹ruby-2.3.3›
$
markeissler commented 7 years ago

Hrmm. That's odd because GVM2 does not actually do anything to change the prompt, or at least shouldn't be. I'll have to take a look.

ghostsquad commented 6 years ago

I just tried this on the most recent release (as I was also having an installation problem, see #3). This is still a problem.

This is my oh-my-zsh theme

# vim:ft=zsh ts=2 sw=2 sts=2

ruby_version() {
  echo `rbenv version | sed -e 's/ .*//'`
}

rbenv_version() {
  rbenv version 2>/dev/null | awk '{print $1}'
}

ruby_prompt_info() {
  if [ -e ~/.rvm/bin/rvm-prompt ]; then
    echo "%{$fg_bold[red]%}‹$(rvm_current)›%{$reset_color%}"
  elif which rbenv &> /dev/null; then
    echo "%{$fg_bold[red]%}$(rbenv_version)%{$reset_color%}"
  fi
}

PROMPT='
%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$(git_prompt_info) ⌚ %{$fg_bold[red]%}%*%{$reset_color%} $(ruby_prompt_info)
$ '

# Must use Powerline font, for \uE0A0 to render.
ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}\uE0A0 "
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}!"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?"
ZSH_THEME_GIT_PROMPT_CLEAN=""
ghostsquad commented 6 years ago

I think maybe the load order of scripts is affecting variables or something?

ghostsquad commented 6 years ago

I'm still not sure, I've done some searching for fg and reset_color, but I don't see anything like that. It seems that $fg and/or $reset_color are not working when the gvm source line is uncommented from my .zshrc profile. I've looked through the various scripts that get sourced starting with the gvm script entrypoint. Nothing stands out.

[[ -s "$HOME/.gvm/scripts/gvm" ]] && source "$HOME/.gvm/scripts/gvm"

image

markeissler commented 6 years ago

Hi @ghostsquad. I haven't looked further into this prompt problem yet. I wanted to get the code base into better shape. Thanks for the oh-my-zsh theme snippet. That will be helpful.

markeissler commented 6 years ago

Prompt problems have been identified as reported in #3 (Installation fails in zsh). While the exact issue reported in this issue has not been duplicated I'm wondering if it's the same but that the different theme variation just displays the problem in a different way.

It's going to take some time to refactor the code to address this problem: it stems from array incompatibility between bash and zsh. I'm scheduling a fix for 0.10.8.

ghostsquad commented 6 years ago

I recently realized this array problem in some other scripts of mine. Would it be easier to write this code in Go and distribute a static binary instead of using shell scripts?

markeissler commented 6 years ago

For GVM3 I'm considering a rewrite in Go exactly because it would provide better portability. Support for zsh was not on my radar when I started the rewrite for GVM2. The current plan is to finish GVM2 with zsh compatibility and then sometime in 2018 I will start the journey towards GVM3.

arminbalalaie commented 5 years ago

I am facing this problem as well. Is there any update on this? Is there any workaround that we can apply locally ?

keonjeo commented 4 years ago

@markeissler how about this issue now :-)

ghostsquad commented 4 years ago

I moved on to use https://asdf-vm.com/#/ which support go among many other things.

keonjeo commented 4 years ago

I moved on to use https://asdf-vm.com/#/ which support go among many other things.

asdf is a very nice tool to manager other versions for many languages. Thanks

keonjeo commented 4 years ago

@ghostsquad @arminbalalaie @markeissler @fd @skiz @manveru @dol @manveru @juvenal

I found the reason why gvm2 messes with the prompt of the zsh.

it is going to setopt KSH_ARRAYS on the scripts/function/_shell_compat file.

[[ -n $ZSH_VERSION ]] && setopt KSH_ARRAYS

when I comment this line, my ohmyzsh comes normally. So I think here the problem is. Hope it can help other guys to use gvm2 tool.

image

keonjeo commented 4 years ago

I have fixed this issue related to the zsh compatibility on my repository => https://github.com/keonjeo/gvm.