Skip to content

Commit

Permalink
Merge pull request #202 from devppratik/fix-kube-ps1-with-zsh
Browse files Browse the repository at this point in the history
Updated PS1 Setup to work with ZSH
  • Loading branch information
openshift-merge-robot committed Sep 21, 2023
2 parents 26e1081 + 5467247 commit 949ee51
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion docs/PS1-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ PS1='[\u@\h \W $(kube_ps1)]\$ '

## Zsh

### With `oh-my-zsh` enabled
kube-ps1 is included as a plugin in the oh-my-zsh project. To enable it, edit your `~/.zshrc` and add the plugin:

```
Expand All @@ -45,6 +46,21 @@ function cluster_function() {
echo $clustername.$baseid
}
KUBE_PS1_BINARY=oc
KUBE_PS1_CLUSTER_FUNCTION=cluster_function
export KUBE_PS1_CLUSTER_FUNCTION=cluster_function
PROMPT='$(kube_ps1)'$PROMPT
~~~
### Without `oh-my-zsh` enabled
Save the [kube-ps1](https://raw.githubusercontent.com/jonmosco/kube-ps1/master/kube-ps1.sh) script to local, and append the below to `~/.zshrc`.
~~~
source /path/to/kube-ps1.sh ##<---- replace this to your location
function cluster_function() {
info="$(ocm backplane status 2> /dev/null)"
if [ $? -ne 0 ]; then return; fi
clustername=$(grep "Cluster Name" <<< $info | awk '{print $3}')
baseid=$(grep "Cluster Basedomain" <<< $info | awk '{print $3}' | cut -d'.' -f1,2)
echo $clustername.$baseid
}
KUBE_PS1_BINARY=oc
export KUBE_PS1_CLUSTER_FUNCTION=cluster_function
PS1='[\u@\h \W $(kube_ps1)]\$ '
~~~

0 comments on commit 949ee51

Please sign in to comment.