Skip to main content

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

  1. Make sure Powerline is installed and functioning and that you have a custom configuration (most likely in ~/.config/powerline).

  2. Install the package with pip or pipx.

pip install --user powerline-venvprompt

or

pipx install powerline-venvprompt
  1. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

powerline-venvprompt-1.0.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

powerline_venvprompt-1.0.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

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

Hashes for powerline-venvprompt-1.0.0.tar.gz
Algorithm Hash digest
SHA256 eef425a9bd09530a31512e1dd0474fe14da76df324628db6977b4baf01209ff8
MD5 8c1aa88b2232c459e6951b57e6ecd208
BLAKE2b-256 92ebd3f54c1fa54de9329c0facfa2fd07f7c313402cbd6b60a12ac5879682b60

See more details on using hashes here.

File details

Details for the file powerline_venvprompt-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for powerline_venvprompt-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b2c846f334535885522f4cd4b2d67bfa758e03d0aba196fe92500d5a2cd04f2a
MD5 ae95df7ab0429cd966e9621c0a00af1c
BLAKE2b-256 d8b778a5c4aeaae059eb7c1a850b23aafe7ce33884fb574b4d8799a9bc706f63

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page