Как удалить исходные элементы в .bashrc без комментариев?

Как удалить исходные элементы из .bashrc без комментариев? Я хочу, чтобы исходный элемент не работал в файле .bashrc. Конкретный пункт 'source ~ / miniconda3 / bin / activ' в .bashrc. Я не хочу комментировать это, потому что это неудобство. Так что я думаю, есть ли способ сделать это?

-1
задан 21 June 2020 в 11:57

1 ответ

No, typically one can't "undo" something that is "sourced", since it directly changes the current environment. The only way to have the changes "undone" is if, somehow, the old environment was stored, so it could be set back to its original values.

For example, if a file foo.env is sourced (source foo.env) and it changes PATH to include $HOME/mystuff/bin/, then the only way to undo those changes would be for foo.env to remember what PATH was originally, e.g., by setting something like OLD_PATH=$PATH, then you run something that will set everything back to its original values. (Note that this isn't always reliable, and any changes made after sourcing foo.env would be lost.)

In the case of anaconda (miniconda), which is the command you reference in your .bashrc, there does happen to be such a program, though. It's invoked by running something like deactivate or conda deactivate, which should "undo" the changes to the environment caused by ~/miniconda3/bin/activate.

See https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#deactivating-an-environment

1
ответ дан 30 July 2020 в 22:23

Другие вопросы по тегам:

Похожие вопросы: