Skip to content

Instantly share code, notes, and snippets.

@hangingman
Created March 7, 2022 04:22
Show Gist options
  • Save hangingman/7dfad7c71ad72366722a763ebfacba2e to your computer and use it in GitHub Desktop.
Save hangingman/7dfad7c71ad72366722a763ebfacba2e to your computer and use it in GitHub Desktop.
kube-ps1の設定

kube-ps1を使いたかったが、デフォルトだとクラスタ名が長いため「/」の後だけ表示する

# kubectx
source "/usr/local/opt/kube-ps1/share/kube-ps1.sh"

# 短いnamespace
function get_cluster_name() {
  name2=`echo $1 | awk -F '/' '{print $2}'`
  echo $name2
}

export KUBE_PS1_CLUSTER_FUNCTION=get_cluster_name
export PS1='\[$(kube_ps1)\]$ '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment