A Powerline segment for showing the venv prompt.
Project description
powerline-venvprompt
powerline-venvprompt is a Powerline status segment that displays the prompt set by the venv --prompt option.
For example, if a virtual environment was created with the command python3 -m venv venv --prompt "my_prompt", the prompt will be "my_prompt" instead of "venv" or the name of the folder containing venv.
Installation
-
Make sure Powerline is installed and functioning and that you have a custom configuration (most likely in ~/.config/powerline).
-
Install the package with
piporpipx.
pip install --user powerline-venvprompt
or
pipx install powerline-venvprompt
- Add to your theme.
Typically, the config.json file that controls your Powerline setup is in ~/.config/powerline. The theme itself will be in ~/.config/powerline/themes/shell. Add the following lines to your theme JSON file (note the segment specification uses an underscore, not a hyphen):
{
"function": "powerline_venvprompt.segments.prompt",
"priority": 10
},
Set the priority however you like.
powerline-venvprompt takes the place of the powerline.segments.common.env.virtualenv segment, so if that one is already in your config file you should remove it. If there is no prompt set in the venv, it will display the same thing that powerline.segments.common.env.virtualenv would have shown.
Options
The options for powerline-venvprompt are inherited from the default powerline.segments.common.env.virtualenv segment in version 2.8.3.
- ignore_venv
If true, the venv virtual environment will be ignored (including the --prompt option). Default value is false.
- ignore_conda
If true, the conda virtual environment will be ignored. Default value is false.
- ignored_names
A list of names that will be ignored. If a virtual environment has one of these names (and no explicit prompt defined), the prompt will be the name of the folder containing venv.
Here is an example configuration with the default values:
{
"function": "powerline_venvprompt.segments.prompt",
"priority": 10,
"args": {
"ignore_venv": false,
"ignore_conda": false,
"ignored_names": ["venv", ".venv"]
}
},
Troubleshooting
If you activate a virtual environment and the prompt isn't displayed, here are some potential solutions.
Restart Powerline
Use the command powerline-daemon -r to restart Powerline after any change to your configuration.
Check for errors
Use the command powerline-lint to display configuration errors.
You may see a number of unrelated issues (my installation has over a dozen errors in the stock colorschemes/vim/__main__.json file). Ignore those.
You will see the following message. You can ignore this. powerline-venvprompt uses the same virtualenv color scheme that the default powerline.segments.common.env.virtualenv uses.
found highlight group prompt not defined in the following colorschemes: default, solarized
(If not specified otherwise in documentation, highlight group for function segments
is the same as the function name.)
in "~/.config/powerline/themes/shell/steve.json", line 17, column 49:
... "powerline_venvprompt.segments.prompt",
If you see the message "failed to import module powerline_venvprompt.segments" that might mean Powerline is not searching the folder containing your powerline_venvprompt folder. If this is the case, add the folder to your config.json file. This folder will depend on how you installed powerline-venvprompt. Example:
"paths": [
"/path/to/folder"
],
If all else fails, use GitHub Issues to report your problem and I'll do my best to help.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file powerline-venvprompt-1.0.0.tar.gz.
File metadata
- Download URL: powerline-venvprompt-1.0.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eef425a9bd09530a31512e1dd0474fe14da76df324628db6977b4baf01209ff8
|
|
| MD5 |
8c1aa88b2232c459e6951b57e6ecd208
|
|
| BLAKE2b-256 |
92ebd3f54c1fa54de9329c0facfa2fd07f7c313402cbd6b60a12ac5879682b60
|
File details
Details for the file powerline_venvprompt-1.0.0-py3-none-any.whl.
File metadata
- Download URL: powerline_venvprompt-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2c846f334535885522f4cd4b2d67bfa758e03d0aba196fe92500d5a2cd04f2a
|
|
| MD5 |
ae95df7ab0429cd966e9621c0a00af1c
|
|
| BLAKE2b-256 |
d8b778a5c4aeaae059eb7c1a850b23aafe7ce33884fb574b4d8799a9bc706f63
|