Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/progrhyme/gcloud-prompt
Show gcloud config info on Bash/Zsh prompt
https://github.com/progrhyme/gcloud-prompt
bash google-cloud-sdk zsh
Last synced: 4 days ago
JSON representation
Show gcloud config info on Bash/Zsh prompt
- Host: GitHub
- URL: https://github.com/progrhyme/gcloud-prompt
- Owner: progrhyme
- License: mit
- Created: 2020-05-17T06:59:02.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-26T11:42:15.000Z (over 4 years ago)
- Last Synced: 2024-12-23T23:16:18.884Z (about 2 months ago)
- Topics: bash, google-cloud-sdk, zsh
- Language: Shell
- Homepage:
- Size: 17.6 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
![test](https://github.com/progrhyme/gcloud-prompt/workflows/test/badge.svg)
# gcloud-prompt
Fetch gcloud client configuration information to show on shell prompt.
Currently, Bash & Zsh are supported.
# Usage
Zsh:
```sh
. path/to/gcloud-prompt/gcloud-prompt.sh
# Example prompt setting
PROMPT="%F{cyan}[\$(gcloud_prompt)]%f %n@%m%# "
```Bash:
```sh
. path/to/gcloud-prompt/gcloud-prompt.sh
# Example prompt setting
PS1="\[\e[0;36m\]<\$(gcloud_prompt)>\[\e[m\]\n\h:\W \u\$ "
```Execute `toggle_gcloud_prompt` function to hide/show gcloud information.
# Examples
Here are some output examples.
```sh
# Default setting & default configuration
$ gcloud_prompt
default|[email protected],my-project# GCLOUD_PROMPT_CONFIG_KEYS=(core.project compute.region)
$ gcloud_prompt
default|my-project,asia-northeast1# GCLOUD_PROMPT_SHOW_CONFIG_PARAMS=no
$ gcloud_prompt
default
```# Configuration
You can change below variables to customize the prompt output.
Variable | Default | Type | Description
----------|:-------:|:----:|---------------
GCLOUD_PROMPT_ENABLED | on | String | If this variable is not set, `gcloud_prompt` prints nothing
GCLOUD_PROMPT_SHOW_CONFIG_PARAMS | yes | String | If this variable doesn't equal to "yes", only current active configuration shows on prompt
GCLOUD_PROMPT_CONFIG_KEYS | `(core.account core.project)` | Array | When `GCLOUD_PROMPT_SHOW_CONFIG_PARAMS` is set to `yes`, these properties appears on prompt
GCLOUD_PROMPT_SEPARATOR | `\|` | String | Delimiter between active configuration and config propertiesFor available properties to set in `GCLOUD_PROMPT_CONFIG_KEYS`, refer to https://cloud.google.com/sdk/gcloud/reference/config/get-value
# Dependencies
This script depends on the current implementation of Cloud SDK; such as configuration
directory structure, configuration data structure etc.# License
The MIT License.
Copyright (c) 2020 IKEDA Kiyoshi.