Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kube-ps1 #467

Open
dhoffi opened this issue Apr 15, 2020 · 3 comments
Open

kube-ps1 #467

dhoffi opened this issue Apr 15, 2020 · 3 comments

Comments

@dhoffi
Copy link

dhoffi commented Apr 15, 2020

Hi,

I would like to run git-prompt together with kube-ps1 https://github.com/jonmosco/kube-ps1

but any try f...s up the whole prompt.

Any ideas on who to best achieve this?

@askoriy
Copy link

askoriy commented May 5, 2020

Instead rewrite PS1 variable I achieved this by add kube_ps1 to PROMPT_COMMAND variable (with new line for better visibility):

if [[ -n "$PROMPT_COMMAND" ]]; then
    PROMPT_COMMAND="kube_ps1; echo; $PROMPT_COMMAND"
else
    PROMPT_COMMAND="kube_ps1"
fi

@agilgur5
Copy link

agilgur5 commented Jun 11, 2020

You need to configure prompt_callback for this because kube-ps1 is dynamic (configuring plain GIT_PROMPT_END won't work as it will get stale):

# customize Git prompt below with kube_ps1
function prompt_callback() {
  echo -n " $(kube_ps1)"
}

Full excerpt from my bash_profile:

# add kube_ps1 function for a Bash prompt / PS1 for k8s
if [ -f "$(brew --prefix)/opt/kube-ps1/share/kube-ps1.sh" ]; then
  source "$(brew --prefix)/opt/kube-ps1/share/kube-ps1.sh"
fi

# customize Git prompt below with kube_ps1
function prompt_callback() {
  echo -n " $(kube_ps1)"
}

# Bash prompt / PS1 for Git -- prompt is dynamic and uses prompt_callback above
if [ -f "$(brew --prefix)/opt/bash-git-prompt/share/gitprompt.sh" ]; then
  __GIT_PROMPT_DIR=$(brew --prefix)/opt/bash-git-prompt/share
  source "$(brew --prefix)/opt/bash-git-prompt/share/gitprompt.sh"
fi

@sastorsl
Copy link

sastorsl commented Nov 2, 2023

Seems to me that this issue could be closed with this solution.
Perhaps outline it in docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants