Last active
December 5, 2023 16:38
-
-
Save arrase/7edafc36472ee079dd89c49f74891b5d to your computer and use it in GitHub Desktop.
Simple gcloud prompt for zsh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Copyright 2023 Juan Ezquerro LLanes | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# Debug | |
[[ -n $DEBUG ]] && set -x | |
_gcloud_ps1_init() { | |
setopt PROMPT_SUBST | |
zmodload -F zsh/stat b:zstat | |
zmodload zsh/datetime | |
} | |
# Set gcloud-ps1 shell defaults | |
_gcloud_ps1_init | |
# Build our prompt | |
gcloud_ps1() { | |
GCLOUD_PS1="$(gcloud config get project 2>/dev/null)" | |
echo "${GCLOUD_PS1}" | |
} |
Author
arrase
commented
Dec 5, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment