diff options
author | Ryan Schanzenbacher <ryan@rschanz.org> | 2024-04-05 11:57:45 -0400 |
---|---|---|
committer | Ryan Schanzenbacher <ryan@rschanz.org> | 2024-04-05 11:57:45 -0400 |
commit | b88d77fb2d0d5028a6f5670695dee6bec129501f (patch) | |
tree | 2536b0461d297e647cf07157641c9b1223339adf /home-config/fish/functions/_tide_item_python.fish | |
parent | 776a7ca55d2d2c3f396de91db1c6c3c5065012cd (diff) |
ahhh sloppy fish, still needs fixing, esp with the vars
Diffstat (limited to 'home-config/fish/functions/_tide_item_python.fish')
-rw-r--r-- | home-config/fish/functions/_tide_item_python.fish | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/home-config/fish/functions/_tide_item_python.fish b/home-config/fish/functions/_tide_item_python.fish new file mode 100644 index 0000000..57f7075 --- /dev/null +++ b/home-config/fish/functions/_tide_item_python.fish | |||
@@ -0,0 +1,27 @@ | |||
1 | function _tide_item_python | ||
2 | if test -n "$VIRTUAL_ENV" | ||
3 | if command -q python3 | ||
4 | python3 --version | string match -qr "(?<v>[\d.]+)" | ||
5 | else | ||
6 | python --version | string match -qr "(?<v>[\d.]+)" | ||
7 | end | ||
8 | string match -qr "^.*/(?<dir>.*)/(?<base>.*)" $VIRTUAL_ENV | ||
9 | # pipenv $VIRTUAL_ENV looks like /home/ilan/.local/share/virtualenvs/pipenv_project-EwRYuc3l | ||
10 | # Detect whether we are using pipenv by looking for 'virtualenvs'. If so, remove the hash at the end. | ||
11 | if test "$dir" = virtualenvs | ||
12 | string match -qr "(?<base>.*)-.*" $base | ||
13 | _tide_print_item python $tide_python_icon' ' "$v ($base)" | ||
14 | else if contains -- "$base" virtualenv venv .venv env # avoid generic names | ||
15 | _tide_print_item python $tide_python_icon' ' "$v ($dir)" | ||
16 | else | ||
17 | _tide_print_item python $tide_python_icon' ' "$v ($base)" | ||
18 | end | ||
19 | else if path is .python-version Pipfile __init__.py pyproject.toml requirements.txt setup.py | ||
20 | if command -q python3 | ||
21 | python3 --version | string match -qr "(?<v>[\d.]+)" | ||
22 | else | ||
23 | python --version | string match -qr "(?<v>[\d.]+)" | ||
24 | end | ||
25 | _tide_print_item python $tide_python_icon' ' $v | ||
26 | end | ||
27 | end | ||