powerline-inject
powerline-inject is a Powerline status segment addon for showing ENV with extra knobs.
This can be natively done with powerline.segments.common.env.environment if knobs aren't needed:
{
"segments":
{
"left":
[
{ "function":
"powerline.segments.common.env.environment",
"name": "aws",
"priority": 20,
"before": "⩜ ",
"args": {
"variable": "SOME_ENV"
}
}
]
}
}
Couple knobs featured that powerline-inject has are:
- The ability to toggle on or off the powerline-inject segment using an environment variable which can easily be mapped to a function in your
~/.bash_profile. - The ability to show only a symbol when the variables holds value. (SECRET KEYS, TOKENS, etc.)
- Multiple different highlighter profiles for your ENV lists.
The screenshot below demonstrates this functionality:
Installation
- Add the Python package. powerline-inject is available on pypi so you can install it with pip:
pip install --user powerline-inject
- Create a user configuration directory.
Once powerline-inject has been installed, we'll need to add it to our powerline shell's theme and colorscheme.
Alter your powerline user config:
If you don't already have a ~/.config/powerline/ folder, create it. Next we'll be copying some of the default powerline configs into this location. Find where powerline is installed by using pip show powerline-status | grep 'Location', then navigate to the config_files/ folder there. We'll be copying config.json, themes/shell/default.json, and colorschemes/shell/default.json to our ~/.config/powerline/ folder, adding the necessary folders to match that original file structure (i.e. adding the themes/ and colorschemes/ folders, etc.
- Add powerline-inject to your user config.
Within our user config, we'll need to add the powerline-inject segment to our shell by adding the following lines to our ~/.config/powerline/themes/shell/default.json:
{
"function": "powerline_inject.context",
"priority": 30,
"args": {
"show_env": true,
"env_list": ["AWS_PROFILE", "TOKEN_X"]
}
}
Next we'll add the highlighting colors we'll use to our ~/.config/powerline/colorschemes/shell/default.json:
{
"name": "Default",
"groups": {
"powerline_inject": { "fg": "white", "bg": "red", "attrs": [] },
"powerline_inject_bold": { "fg": "white", "bg": "brightred", "attrs": [] },
}
}
-
You will need to reload powerline with
powerline-daemon --replaceto load the new settings. That's it! -
(Optional) By default powerline-inject will render the environment variable if
RENDER_POWERLINE_INJECTSis either set toYESor is not set at all. Rather than setting this variable manually, you can create a simplepowerline-inject-togglefunction by placing the following in your~/.bash_profile:
function powerline-injects-toggle() {
if [[ $RENDER_POWERLINE_INJECTS = "NO" ]]; then
export RENDER_POWERLINE_INJECTS="YES"
else
export RENDER_POWERLINE_INJECTS="NO"
fi
}
Confidential ENV use
You may find you want to know when you have SECRETS loaded into your ENVIRONMENT. This will show only a symbol ⩜ when the SECRET_TOKEN or AWS_PROFILE is loaded.
{
"function": "powerline_inject.context",
"priority": 30,
"args": {
"show_env": false,
"env_list": ["SECRET_TOKEN", "AWS_PROFILE"],
"before": "⩜ "
}
},
You can further add a second call to powerline_inject.context with a different before symbol and/or env_highlighter in args like the powerline_inject_bold defined above.
{
"function": "powerline_inject.context",
"priority": 30,
"name": "second_injection",
"args": {
"show_env": false,
"env_list": ["SECRET_TOKEN", "AWS_PROFILE"],
"env_highlighter": "powerline_inject_bold"
}
},
Used with PROMPT_COMMAND for ENV refresh
You may want to use this with a PROMPT COMMAND that updates the ENVs being checked everytime. As an example aws-test-authentication sets AWS_EPOCH and AWS_PROFILE.
Put this in your ~/.bash_profile
export PROMPT_COMMAND="eval \$(aws-test-authentication); $PROMPT_COMMAND"
You're all set up! Happy coding!
License
Licensed under the Apache License 2.0.
Original fork is at https://github.com/zcmarine/powerkube.
Metadata
Release files for powerline-inject 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| powerline-inject-0.1.6.tar.gz | 4.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| powerline_inject-0.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.5 kB
Release files / powerline-inject-0.1.6.tar.gz
| Download URL | powerline-inject-0.1.6.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8733928f0db4dccf291c6a60a33abaf6f91354c755b49002398e7ddf21855504
|
|
BLAKE2b-256 checksum How to use checksums |
6fcd038c611102f852e1b89042789f1c59480082b516a963acf7e2931de6271c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.5
|
Release files / powerline_inject-0.1.6-py3-none-any.whl
| Download URL | powerline_inject-0.1.6-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
93dc5b0b1ed69be5ace2c931a6911020c448aa86ae5bdccfa19b228c697f8db7
|
|
BLAKE2b-256 checksum How to use checksums |
986dbfb4ac9a9e7d724cb9a28ae0a63572ff4e45c935244baa5b8cd681bc5488
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.5
|
Security for powerline-inject 0.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.