Comments (7)
So I got a custom command working (almost). The part in the [python] section isn't supported - I guess I would have to break out the top level format string, which seems complicated.
[custom.venv]
description = "Show qualified virtualenv dir, if not IN the dir tree where it is resides"
# from directory ../project-name/, . ~/some/other/.venv/bin/activate -- displays 'other/.venv'
# from directory .../other/src, .../other, etc. , -- displays just .venv
command = """
qual=$(basename $(dirname "$VIRTUAL_ENV"));
venv=$(basename "$VIRTUAL_ENV");
pat=".*/${qual}/*(/.*)?$";
[[ "$PWD" =~ $pat ]] && printf "($venv)" || printf "($qual/$venv)"
"""
when = '''[[ -n "$VIRTUAL_ENV" ]]'''
format = '[$output](blue)'
[python]
format = '\[[${symbol}${pyenv_prefix}(${version})(\(${custom.venv}\))]($style)\]'
from starship.
Maybe as an alternative solution: use --prompt "name"
to set a different name?
[22:01:57] λ python -m venv .venv --prompt "whatever"
~/projects/whatever on feature/pagination (c2c6c249) v3.12.2 (venv:whatever) took 5s
[22:02:10] λ
The first venv:
comes from my format definition:
[python]
format = "[$symbol$version( \\(venv:$virtualenv\\))]($style) "
from starship.
Interesting. But what really motivated this was several times vscode somehow getting the venv wrong, or just changing directories. I'm sort of fine with what I already did. But I think it is a generally useful idea. I'm happy to close it if you think it's pointless, or not useful enough. As an aside, is there a way to do something like my custom command, or do I have to just rewrite the top level format string.
Btw, starship is killer.
from starship.
And here's an example of how my (badly integrated) custom venv looks...
~/g/sample-python (0bdef92) 3? [🐍 v3.12.2]
08:53:46 ❯ . ./.venv/bin/activate
~/g/sample-python (0bdef92) 3? [🐍 v3.12.2](.venv)
08:53:59 ❯ cd ../tws-stack-deployment
~/g/tws-stack-deployment develop 2$ 1? [🐍 v3.12.2](sample-python/.venv)
08:54:20 ❯ . .venv/bin/activate
~/g/tws-stack-deployment develop 2$ 1? [🐍 v3.12.2](.venv)
08:54:26 ❯ cd -
~/git/sample-python
~/g/sample-python (0bdef92) 3? [🐍 v3.12.2](tws-stack-deployment/.venv)
Could keep all the config the same (just change the behavior of $virtualenv) or maybe add a flag option like warn_by_qualifying_virtualenv_with_directory_when_it_seems_like_it_might_be_wrong_venv: true
Again, starship is a great package, I'm fine if you prefer to "close won't fix". If I can figure out the proper way to include it in the [python] configuration, I'll add it to that issue for examples of custom scripts.
from starship.
And, BTW, here was my motivator -- I guess I should debug why my vscode config is broke
![image](https://private-user-images.githubusercontent.com/216707/317734702-5b2acc6d-cd58-4d10-84db-4af39c4f9ea4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkwNjk2NDgsIm5iZiI6MTcxOTA2OTM0OCwicGF0aCI6Ii8yMTY3MDcvMzE3NzM0NzAyLTViMmFjYzZkLWNkNTgtNGQxMC04NGRiLTRhZjM5YzRmOWVhNC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjIyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYyMlQxNTE1NDhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zZGRiYjMyOTYyZTlkMjRkMGU3M2EwZGMyZTExZGZkNmQ1NDIwZDhhZGIxMmYwZmFjZDdhN2FkZWIzZGFiNGUwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.gOSqjg4l48WfOqJxQN6p_mXzkGDVc76aS51bQ7DJzGc)
I don't know where it is getting its "memory" of the correct venv to use, and it isn't always wrong...
from starship.
Just want to +1 this, stumbled upon this after dealing with the same issue as @marvingreenberg. I'd love the ability to show a bit more information about the virtualenv - I name all of mine .venv
, so just showing that isn't really enough for me to know that I'm in the absolutely wrong virtual environment for absolutely no reason. Also, agreed with the above, starship is killer
Edit: Maybe another potential solution would be showing the value in a certain environment variable, such as VENV_NAME or VENV_PROMPT or STARSHIP_VENV_{NAME/PROMPT} - that would let users set this on their own using whatever logic they want
from starship.
@marvingreenberg BTW your config works well enough for me, thank you for sharing it, I can finally stop wasting time finding a way to warn myself when I'm in the wrong one
from starship.
Related Issues (20)
- custom commands not working inside starship bash shell HOT 4
- Fortune equivalent for starship?
- detect_input
- starship in Windows PowerShell only shows the current directory
- Current interface with IP Address info
- Windows: Escape Sequences Issue with `starship init nu` in Nushell HOT 3
- trailing spaces being removed from prompt when using nix_shell in tmux HOT 1
- Extra empty line at the top of the terminal HOT 1
- Init.nu fails after upgrading nushell from v0.93.0 to v0.94.1 HOT 2
- No Git Information/Status Shown in Prompt When Inside Git Repo With SHA256 Hashing
- [BUG] direnv style specifies a non-standard color HOT 1
- [custom] Inconsistent handling of colors from subshell when using custom module HOT 2
- Add option for aliasing known hostnames in config
- `starship module ...` not displaying any output to stdin with the exception of `starship module character`
- Kubernetes module not working on Powershell
- .gitconfig file triggers "git" section HOT 1
- [Feat.Req] P10k like instant prompt
- Starship not honoring `add_newline = false`
- over-eager language detection logic causes noisy, false info in prompts
- kubernetes module ignores detect_files setting HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from starship.