djui / alias-tips

An oh-my-zsh plugin to help remembering those aliases you defined once
781 stars 51 forks source link

_alias_tips__preexec:34: command not found: python #60

Open andig opened 2 years ago

andig commented 2 years ago

Recently getting this message on OSX:

~/htdocs
❯ which python
_alias_tips__preexec:34: command not found: python
python not found

~/htdocs
❯ which python3
_alias_tips__preexec:34: command not found: python
/opt/homebrew/bin/python3
djui commented 2 years ago

Thanks @andig for reporting. The python version is currently hardcoded to python3.

Do you have an idea how to best route to Python 3 via python or python3? I know that some distributions have defaulted to have python actually be Python 3, yet I am not aware of a good heuristic to figure that out.

andig commented 2 years ago

I wouldn‘t know- not a regular python user. One option might be checking for python3 and then fall back to python?

braggy commented 2 years ago

I've just started getting this issue and I believe it started right after I typo'd with 'd ' instead of 'cd '. It's done it ever since (new iTerm2 sessions and a reboot)

braggy commented 2 years ago

OK, so I've found the d function in ~/.oh-my-zsh/lib/directories.zsh:

function d () {
  if [[ -n $1 ]]; then
    dirs "$@"
  else
    dirs -v | head -n 10
  fi
}
compdef _dirs d

After giving the command dirs ~, this problem is now fixed for me!

Strangely, I can't seem to replicate the issue again with d <dir_name> though.

braggy commented 2 years ago

It turns out the fix was also to have a symlink for python to python3, going by @djui's previous comment. It's now reproducable:

$ ll /usr/local/bin/python
/usr/local/bin/python -> /usr/local/bin/python3

$ rm /usr/local/bin/python
remove /usr/local/bin/python? y

$ d test
_alias_tips__preexec:34: command not found: python

$ ln -s /usr/local/bin/python3 /usr/local/bin/python
_alias_tips__preexec:34: command not found: python

$ d test
$ d test