diff --git a/home/dotfiles/zshrc b/home/dotfiles/zshrc index 49f0d09..3625533 100644 --- a/home/dotfiles/zshrc +++ b/home/dotfiles/zshrc @@ -1,5 +1,18 @@ #!/bin/zsh +when_binary_available() { + if has_binary "$@"; then + printf '1' + return + fi + printf '0' + return +} + +has_binary() { + command -v "$@" >/dev/null 2>&1 +} + ZSH_DEBUG="${ZSH_DEBUG:-0}" ZSH_ALIAS=${ZSH_ALIAS:-1} @@ -7,6 +20,7 @@ ZSH_COMPAT_BASH_COMPLETION=${ZSH_COMPAT_BASH_COMPLETION:-1} ZSH_CUSTOM=${ZSH_CUSTOM:-1} ZSH_DEFAULT_TERM=${ZSH_DEFAULT_TERM:-1} ZSH_GPG_PINENTRY_FIX=${ZSH_GPG_PINENTRY_FIX:-1} +ZSH_PIPX=${ZSH_PIPX:-$(when_binary_available pipx)} ZSH_POWERLINE="${ZSH_POWERLINE:-1}" ZSH_PRINT_REBOOT_REQUIRED=${ZSH_PRINT_REBOOT_REQUIRED:-0} # hacky, see below ZSH_SYNTAX_HIGHLIGHTING="${ZSH_SYNTAX_HIGHLIGHTING:-1}" @@ -48,9 +62,9 @@ log() { # Compatibility mode for completions section "compat: bash completion" -if [ $ZSH_COMPAT_BASH_COMPLETION -gt 0 ]; then +if [ $ZSH_COMPAT_BASH_COMPLETION -gt 0 ] || [ $ZSH_PIPX -gt 0 ]; then log "Enabling compatibility for bash completion scripts..." - autoload bashcompinit + autoload -U bashcompinit bashcompinit fi section_end @@ -80,6 +94,13 @@ if [ -d "$HOME/Library/Python/2.7" ]; then export PATH fi section_end +section "pipx bin" +if [ $ZSH_PIPX -gt 0 ]; then + autoload -U bashcompinit + bashcompinit + eval "$(register-python-argcomplete pipx)" +fi +section_end # Locale fix section "locale fix" diff --git a/packages/os.sh b/packages/os.sh index 6ed60be..a6f0d0c 100644 --- a/packages/os.sh +++ b/packages/os.sh @@ -85,6 +85,7 @@ for pm in \ pacaur \ pacman \ pip3 \ + pipx \ npm \ yaourt \ yarn \ diff --git a/packages/packages.sh b/packages/packages.sh index b501b9a..c0bac78 100755 --- a/packages/packages.sh +++ b/packages/packages.sh @@ -40,6 +40,13 @@ pip3_install() { pip3 install --ignore-installed --user -U "$@" } +pipx_install() { + for pkg in "$@" + do + pipx install --force "$pkg" + done +} + download() { curl -L "$@" } @@ -151,6 +158,12 @@ fi if has_tags pm:pip3; then pip3_install \ + pipx + add_tag pm:pipx +fi + +if has_tags pm:pipx; then + pipx_install \ powerline-status \ thefuck fi