Skip to content

Commit

Permalink
fix python vs python3 in python item (fixes #459)
Browse files Browse the repository at this point in the history
  • Loading branch information
IlanCosman committed Dec 23, 2023
1 parent c7edb99 commit 1ec5448
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
13 changes: 10 additions & 3 deletions functions/_tide_item_python.fish
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
function _tide_item_python
if test -n "$VIRTUAL_ENV"
python --version | string match -qr "(?<v>[\d.]+)"

if command -q python3
python3 --version | string match -qr "(?<v>[\d.]+)"
else
python --version | string match -qr "(?<v>[\d.]+)"
end
string match -qr "^.*/(?<dir>.*)/(?<base>.*)" $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.
Expand All @@ -14,7 +17,11 @@ function _tide_item_python
_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
python --version | string match -qr "(?<v>[\d.]+)"
if command -q python3
python3 --version | string match -qr "(?<v>[\d.]+)"
else
python --version | string match -qr "(?<v>[\d.]+)"
end
_tide_print_item python $tide_python_icon' ' $v
end
end
17 changes: 17 additions & 0 deletions functions/fish_prompt.fish
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,23 @@ end"

if test "$tide_prompt_transient_enabled" = true
function _tide_enter_transient
set -l line (commandline --line)

commandline --search-mode
set -l search_mode_status $status

commandline --paging-mode
set -l paging_mode_status $status

commandline --paging-full-mode
set -l paging_full_mode_status $status

commandline --is-valid
set -l is_valid_status $status

echo "line: $line, search: $search_mode_status, paging: $paging_mode_status, paging_full: $paging_full_mode_status, is_valid: $is_valid_status" >>~/commandline_status


# If the commandline will be executed, or is empty
if commandline --is-valid || test -z "$(commandline)"
set -g _tide_transient
Expand Down

0 comments on commit 1ec5448

Please sign in to comment.