ofek / userpath

Cross-platform tool for adding locations to the user PATH, no elevated privileges required!
MIT License
151 stars 20 forks source link

Avoid adding modified PATH to multiple shell config files #46

Open chrysle opened 1 year ago

chrysle commented 1 year ago

userpath.append() seems to write the modified PATH to all available shell configuration files currently. Example:

$ mkdir temp/ && userpath append -s bash temp/
$ tail -n 2 .bashrc && tail -n 2 .profile 
# Created by `userpath` on 2023-06-18 13:18:55
export PATH="$PATH:/home/user/temp"
# Created by `userpath` on 2023-06-18 13:18:55
export PATH="$PATH:/home/user/temp"

I'd think there should be an option to turn that off. Or is there?

This code seems to be responsible for the behaviour:

https://github.com/ofek/userpath/blob/9b475a5311d077d36495f6afbeeee6201892ddbc/userpath/interface.py#L133-L134

chrysle commented 1 year ago

@ofek Would you be interested in such a feature (maybe through a command line option)? If so, I'd be happy to contribute.

ofek commented 1 year ago

I would very much appreciate that! I think maybe what you're talking about should be the default behavior, see this issue https://github.com/ofek/userpath/issues/3#issuecomment-512973913

chrysle commented 12 months ago

Could you state your preference, then? Only adding to shell login file, or a CLI option like --file and environment variable, or both?

ofek commented 12 months ago

Preferably both but the former for sure, just modify one file by default