userpath icon indicating copy to clipboard operation
userpath copied to clipboard

Avoid adding modified PATH to multiple shell config files

Open chrysle opened this issue 2 years ago • 5 comments

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 avatar Jun 18 '23 13:06 chrysle

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

chrysle avatar Jun 29 '23 08:06 chrysle

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

ofek avatar Jun 29 '23 12:06 ofek

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

chrysle avatar Jul 07 '23 10:07 chrysle

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

ofek avatar Jul 07 '23 13:07 ofek

Hrm, and then #48 was reverted?!?

lingfish avatar Aug 31 '25 06:08 lingfish