pure icon indicating copy to clipboard operation
pure copied to clipboard

Add 🐍 to the virtualenv title so I know that's what I see

Open dwt opened this issue 3 years ago β€’ 4 comments

Env

Pure 4.1.1 Fish fish, version 3.4.1 OS/distribution uname -a Darwin Seneca.fritz.box 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64

Problem description

I work with both virtualenvs as well as with Kubernetes a lot. Always correctly keeping track what virtualenv and what Kubernetes context and namespace is active, is really important to me.

To prevent all possible confusion, it would be very helpful if the virtualenv display could include the symbol 🐍. This allows me to distinguish the Kubernetes context and namespace with ☸️.

Proposed Solution

Would you accept a pull request for this? I have so far just edited my local config file to include this, but would like to be able to just update without having to care about this. A feature flag to hide this behind would be fine with me.

dwt avatar May 18 '22 12:05 dwt

Hello @dwt, Sure, PRs are welcome :heart:

Suggestion

A variable defining the symbol for each indicator could do the trick, e.g declaring

 _pure_set_default pure_symbol_virtualenv "🐍"
 _pure_set_default pure_symbol_kubernetes "☸️"

By default, I would prefer having it empty for now, to have opt-in mechanism.

Could you try to update the test as well? They are still buggy when you run them all, but you should be able to run the one related to one feature, like:

❯ make dev-pure-on FISH_VERSION=3.1.2 CMD="fishtape tests/_pure_prompt_virtualenv.test.fish"

edouard-lopez avatar May 20 '22 08:05 edouard-lopez

Hm, that doesn't seem so easy, I'm getting hangs in the test suite with errors like this:

fish: Unknown command: _print_filename
/tmp/.pure/tests/migration-to-4.0.0.test.fish (line 1): 
_print_filename $current_filename
^
in command substitution
        called on line 2 of file /tmp/.pure/tests/migration-to-4.0.0.test.fish
/tmp/.pure/tests/migration-to-4.0.0.test.fish (line 2): Unknown command
@mesg (_print_filename $current_filename)
      ^

After that the test container just hangs indefinitely, until I manually kill the container. Any advice?

dwt avatar May 22 '22 18:05 dwt

Scratch that, the problem was that I was running ❯ make test-pure-on FISH_VERSION=3.3.1 CMD="fishtape tests/_pure_prompt_virtualenv.test.fish" - which actually runs all the tests instead of restricting them.

dwt avatar May 22 '22 18:05 dwt

I will add variable, so people can disable those features if need be:

_pure_set_default pure_enable_virtualenv true
_pure_set_default pure_enable_kubernetes true

edouard-lopez avatar Jun 21 '22 15:06 edouard-lopez

@edouard-lopez were you able to make any progress on this? I too am looking for this (similar) functionality but honestly don't see k8s context support in the current code base. Was that a plugin you added or something else?

zonywhoop avatar Jun 26 '23 17:06 zonywhoop

Hello @zonywhoop, no progress on my side @dwt was working on a PR, I believe.

However, I see two features in this issue:

  1. add a flag to control virtualenv display and add a customizable prefix (cf. functions/_pure_prompt_container.fish)
  2. add support for k8s context + customizable prefix. There are several prompts that offer k8s support, we can get inspired by them:
    • https://github.com/aluxian/fish-kube-prompt
    • https://github.com/jonmosco/kube-ps1
    • https://github.com/Ladicle/fish-kubectl-prompt

I'm going to create another issue for the kubernetes one.

edouard-lopez avatar Aug 02 '23 09:08 edouard-lopez

@dwt @zonywhoop K8s support has been shipped with https://github.com/pure-fish/pure/tree/v4.6.0

edouard-lopez avatar Aug 16 '23 12:08 edouard-lopez

I'm working on the Python/virtualenv feature on #325

edouard-lopez avatar Aug 21 '23 21:08 edouard-lopez