dotfiles icon indicating copy to clipboard operation
dotfiles copied to clipboard

[BUG] Virtual environment indicator is not present in terminal

Open Koushikg88 opened this issue 1 year ago • 3 comments

Describe the bug

Hi, I have created a separate virtual environment for my project. but whenever I am activating the env , no indication is showing in terminal that I am inside it. At this stage it is very risky to operate. I accidentally type any command that could break the entire os itself . for now I am using the deactivate command before using any sensitive command. Expecting fix soon, likely different theme that has an indication for virtual environment.

Steps to reproduce

  1. open terminal
  2. create a virtual environment using 'python3 -m venv ~/py3venv'
  3. activate the virtual environment using 'source ~/py3venv/bin/activate
  4. see in terminal any indication is came or not

Expected behavior

An indication for virtual environment should come.

Image

Image

Screenshots

Image

Image

Distribution

Arch Linux

If Other, specify

No response

Additional context

No response

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

Koushikg88 avatar Feb 05 '25 07:02 Koushikg88

@Koushikg88 Thanks for testing. But in this case I need your help because I am not developing in this way. Can you check the oh-my-posh documentation and see if you can add this information to the prompt? Then you can share your results and I can add it to the dotfiles.

mylinuxforwork avatar Feb 05 '25 08:02 mylinuxforwork

@mylinuxforwork Hi thanks for reply. I have gone through some options but the one partially worked for me is mentioned below:

{ "type": "python", "style": "powerline", "powerline_symbol": "\uE0B0", "foreground": "#100e23", "background": "#906cff", "template": " \uE235 {{ .Full }} {{ if .Venv }}{{ .Venv }}{{ end }}", "properties": { "fetch_virtual_env": true } },

I have added above code to the ohmyposh theme file, which is a json. I have added this inside "segments" under "blocks". `now the activated environment is showing on the right side as shown in picture. Only problem is if no virtual env is activated it still showing the default python version which i need to fix.

status without activating virtual environment:

Image

status with virtual environment activated:

Image

The link from where i got it is mentioned below:

https://stackoverflow.com/questions/75718484/how-can-i-see-conda-env-in-oh-my-posh-theme-in-powershell

Koushikg88 avatar Feb 06 '25 11:02 Koushikg88

Ok, I have restructured the theme file and the final result is shown in pic. I am sharing the theme file too.

Image

EDM115-newline.omp.json

Koushikg88 avatar Feb 06 '25 12:02 Koushikg88