Add a --prepend
option to the pipx ensurepath
command
#1451
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
changelog.d/
(if the patch affects the end users)Summary of changes
Closes #1424.
This PR adds an option to
pipx ensurepath
, i.e.,pipx ensurepath --prepend
to allow users to prependpipx
-installed applications to thePATH
environment variable rather than appending to it. This is disabled and set toFalse
by default; it is only enabled if the user doespipx ensurepath --prepend
(or its--force
counterparts such aspipx ensurepath --force --prepend
orpipx ensurepath --prepend --force
). The implementation is throughuserpath.prepend
, which is similar touserpath.append
(see https://github.com/ofek/userpath#api).Test plan
Tested by running
This modifies my
~/.zshrc
file on macOS accordingly:Therefore, the latter entry from these changes has prepended
pipx
's installation location toPATH
. The earlier entry is from an olderpipx
installation I had that had appended the location. I'm happy to add additional tests in an appropriate place intests/
as necessary (though I notice thatensurepath
doesn't have tests yet), and update the documentation (not sure where a mention of this would be best appropriate to add, though).