Created
August 16, 2024 22:47
-
-
Save jborbely/1b2841cc5aa6c03dd56803d65f3019a1 to your computer and use it in GitHub Desktop.
Install pipx to ~/.local/bin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e | |
| pipx_dir="${HOME}/.local/bin" | |
| mkdir -p $pipx_dir | |
| echo "#!/bin/bash | |
| if [[ \"\$1\" == \"-U\" ]]; then | |
| echo \"Fetching latest pipx tag from GitHub\" | |
| tag_name=\$(curl -sL --get https://api.github.com/repos/pypa/pipx/releases/latest | grep tag_name) | |
| if [[ -z "\${tag_name}" ]]; then | |
| echo \"Cannot get latest tag from GitHub, try again soon\" | |
| exit 1 | |
| fi | |
| latest=\$(grep -oP \"\\d+\.\\d+\.\\d+\" <<< \"\${tag_name}\") | |
| curl -s -L https://github.com/pypa/pipx/releases/download/\${latest}/pipx.pyz > \"\$(dirname \"\$0\")/pipx.pyz\" | |
| echo \"Installed pipx \${latest}\" | |
| else | |
| python3 \"\$(dirname \"\$0\")/pipx.pyz\" \"\$@\" | |
| fi | |
| " > ${pipx_dir}/pipx | |
| chmod +x ${pipx_dir}/pipx | |
| ${pipx_dir}/pipx -U |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment