Home

Awesome

telepresence-ps1.sh -- Telepresence prompt for Zsh and Bash

Description

This script lets you add the current Telepresence connection status and context to your Zsh or Bash prompt.

Inspired by kube-ps1.

Demo

Demo

Installation from source

Download and source the script into your ~/.zshrc or ~/.bashrc file

Zsh

git clone https://github.com/alexgervais/telepresence-ps1.git ~/telepresence-ps1

source ~/telepresence-ps1/telepresence-ps1.sh
PROMPT='$(telepresence_ps1)'$PROMPT

Bash

git clone https://github.com/alexgervais/telepresence-ps1.git ~/telepresence-ps1

source ~/telepresence-ps1/telepresence-ps1.sh
PS1='[\u@\h \W $(telepresence_ps1)]\$ '

Requirements

The script assumes you have the telepresence and jq binaries installed and executable from your $PATH.

Customization

The default settings can be overridden in ~/.zshrc or ~/.bashrc by setting the following environment variables:

VariableDefaultDescription
TELEPRESENCE_PS1_TELEPRESENCE_BINARYtelepresenceLocation of the telepresence binary. The script assumes it is available in your $PATH and executable.
TELEPRESENCE_PS1_JQ_BINARYjqLocation of the jq binary. The script assumes it is available in your $PATH and executable.
TELEPRESENCE_PS1_SYMBOL_ENABLEtrueDisplay the prompt symbol. If set to false, this will also disable TELEPRESENCE_PS1_SEPARATOR.
TELEPRESENCE_PS1_CONNECTION_ENABLEtrueDisplay the connection status.
TELEPRESENCE_PS1_CONTEXT_ENABLEtrueDisplay the context to which Telepresence is connected.
TELEPRESENCE_PS1_PREFIX(Prompt opening character.
TELEPRESENCE_PS1_SUFFIX)Prompt closing character.
TELEPRESENCE_PS1_SEPARATOR|Separator between the symbol and status.
TELEPRESENCE_PS1_DIVIDER:Separator between the connection status and context.
TELEPRESENCE_PS1_SYMBOL_DEFAULTDefault prompt symbol. Unicode \u29D3
TELEPRESENCE_PS1_SYMBOL_PADDINGfalseAdds a space (padding) after the symbol to prevent clobbering prompt characters
TELEPRESENCE_PS1_SYMBOL_COLORmagentaSet default color of the Telepresence symbol
TELEPRESENCE_PS1_DISCONNECTED_COLORredSet default color of the disconnected status
TELEPRESENCE_PS1_CONNECTED_COLORmagentaSet default color of the connected status
TELEPRESENCE_PS1_CONTEXT_COLORcyanSet default color of the context
TELEPRESENCE_PS1_BG_COLORSet default color of the prompt background

License

This script is licensed under the Apache License.