From b88d77fb2d0d5028a6f5670695dee6bec129501f Mon Sep 17 00:00:00 2001 From: Ryan Schanzenbacher Date: Fri, 5 Apr 2024 11:57:45 -0400 Subject: ahhh sloppy fish, still needs fixing, esp with the vars --- home-config/fish/functions/_tide_item_python.fish | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 home-config/fish/functions/_tide_item_python.fish (limited to 'home-config/fish/functions/_tide_item_python.fish') 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 @@ +function _tide_item_python + if test -n "$VIRTUAL_ENV" + if command -q python3 + python3 --version | string match -qr "(?[\d.]+)" + else + python --version | string match -qr "(?[\d.]+)" + end + string match -qr "^.*/(?.*)/(?.*)" $VIRTUAL_ENV + # pipenv $VIRTUAL_ENV looks like /home/ilan/.local/share/virtualenvs/pipenv_project-EwRYuc3l + # Detect whether we are using pipenv by looking for 'virtualenvs'. If so, remove the hash at the end. + if test "$dir" = virtualenvs + string match -qr "(?.*)-.*" $base + _tide_print_item python $tide_python_icon' ' "$v ($base)" + else if contains -- "$base" virtualenv venv .venv env # avoid generic names + _tide_print_item python $tide_python_icon' ' "$v ($dir)" + else + _tide_print_item python $tide_python_icon' ' "$v ($base)" + end + else if path is .python-version Pipfile __init__.py pyproject.toml requirements.txt setup.py + if command -q python3 + python3 --version | string match -qr "(?[\d.]+)" + else + python --version | string match -qr "(?[\d.]+)" + end + _tide_print_item python $tide_python_icon' ' $v + end +end -- cgit v1.2.3