Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/autocompletion #29

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions bin/install
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,42 @@ install_poetry() {
echo Consider upgrading to a later version.
echo https://github.com/asdf-community/asdf-poetry/issues/10
fi

if [ $config_vercomp == "ge" ]; then
if echo "$SHELL" | grep -q "bash"; then
if [ ! -f "$HOME/.bash_completion" ]; then
echo "Detected default shell Bash"
echo "Setting up autocompletion for Bash..."
"$install_path"/bin/poetry completions bash >~/.bash_completion
elif grep -q '_poetry_' ~/.bash_completion; then
echo "Detected default shell Bash"
echo "Setting up autocompletion for Bash..."
"$install_path"/bin/poetry completions bash >~/.bash_completion
fi
elif echo "$SHELL" | grep -q "zsh"; then
if [ ! -d "$HOME/.zfunc/" ]; then
mkdir -p ~/.zfunc
fi
if [ ! -f "$HOME/.zfunc/_poetry" ]; then
echo "Detected default shell Zsh"
echo "Setting up autocompletion for Zsh..."
"$install_path"/bin/poetry completions zsh >~/.zfunc/_poetry
fi
grep -qxF 'fpath+=~/.zfunc' ~/.zshrc || echo "fpath+=~/.zfunc" >>~/.zshrc
grep -qxF 'autoload -Uz compinit && compinit' ~/.zshrc || echo "autoload -Uz compinit && compinit" >>~/.zshrc
elif echo "$SHELL" | grep -q "fish"; then
if [ ! -f "$HOME/.config/fish/completions/poetry.fish" ]; then
echo "Detected default shell fish"
echo "Setting up autocompletion for fish..."
"$install_path"/bin/poetry completions fish >~/.config/fish/completions/poetry.fish
fi
else
echo "Warning: Could not detect shells Bash, Zsh or fish."
echo "Could not complete autocompletion setup"
fi
else
echo "Warning: Poetry versions prior to 1.2.0 do not have autocompletion"
fi
}

install_poetry "$ASDF_INSTALL_TYPE" "$ASDF_INSTALL_VERSION" "$ASDF_INSTALL_PATH"