mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-23 14:20:08 +00:00
feat(oc): supporting OPENSHIFT_NAMESPACE variable
This commit is contained in:
parent
203369b0f9
commit
b67d2f6cf6
1 changed files with 30 additions and 0 deletions
|
@ -5,4 +5,34 @@
|
|||
if [ $commands[oc] ]; then
|
||||
source <(oc completion zsh)
|
||||
compdef _oc oc
|
||||
|
||||
OC_PLUGIN_INITIALIZED=no
|
||||
|
||||
function oc_prompt_info() {
|
||||
[ -n "$OPENSHIFT_NAMESPACE" ] && echo -ne "\n(openshift: $OPENSHIFT_NAMESPACE)\n\x00"
|
||||
}
|
||||
|
||||
# TODO Completion
|
||||
function oc-namespace() {
|
||||
# TODO -h / --help
|
||||
# TODO "--clear" should unset variable
|
||||
# when nothing passed should show usage
|
||||
# TODO Rename this to "oc" and call binary oc with full path
|
||||
# so this can become a subcommand: "oc localenv namespace xyz"
|
||||
|
||||
[ -n "$1" ] \
|
||||
&& export OPENSHIFT_NAMESPACE="$1" \
|
||||
|| unset OPENSHIFT_NAMESPACE
|
||||
|
||||
[ "$OC_PLUGIN_INITIALIZED" = "no" ] && {
|
||||
export PROMPT='$(oc_prompt_info)'"$PROMPT"
|
||||
# TODO Check if text "oc_prompt_info" is in "$PROMPT"
|
||||
# instead set this variable
|
||||
export OC_PLUGIN_INITIALIZED=yes
|
||||
}
|
||||
}
|
||||
|
||||
alias oc='oc ${OPENSHIFT_NAMESPACE:+"--namespace=$OPENSHIFT_NAMESPACE"}'
|
||||
else
|
||||
echo "oc plugin error: oc command not found..."
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue