Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install script overwrites .bashrc file #115

Closed
Antoine-marchais opened this issue Nov 21, 2019 · 12 comments · Fixed by #284
Closed

Install script overwrites .bashrc file #115

Antoine-marchais opened this issue Nov 21, 2019 · 12 comments · Fixed by #284
Labels

Comments

@Antoine-marchais
Copy link

Steps to reproduce

  • start with a non empty .bashrc file (paths, aliases, etc...)
  • run the install script

Expected result

The oh my bash contents are append to the end of the file.

Actual result

The .bashrc is overwritten

Note : Maybe it is good practise to have the aliases and paths in ~/.profile in which case I apologize for my ignorance, but a little warning would go a long way

@nntoan
Copy link
Member

nntoan commented Nov 28, 2019

Hey @Antoine-marchais ,

At this moment, it's the expectation to overwrite the content of .bashrc. I'm thinking about to move it to .profile or .bash_profile but for now it will stick with .bashrc

@dreais
Copy link

dreais commented Dec 8, 2019

hey there, why not running an extra line to create a backup if .bashrc is an existing file, and renaming it .bashrc_back or something similar for instance?

@nntoan
Copy link
Member

nntoan commented Dec 9, 2019

@dreais Yes, we do support that functionality. If you take a look into https://github.com/ohmybash/oh-my-bash/blob/master/tools/uninstall.sh

You will see that whenever you execute uninstall_oh_my_bash it will revert your current .bashrc with .bashrc.pre-oh-my-bash :)

@dreais
Copy link

dreais commented Dec 9, 2019

hey @nntoan!

sorry, my bad, i quickly looked at the installation script and i didn't find it! thanks for confirming tho :)

@tralston
Copy link

I feel it's a little presumptuous to "intend" to overwrite a user's .bashrc file. Maybe not everyone uses it, but those of us that do, it's where we keep our personal configuration. My .bashrc was indeed backed up to .bashrc.pre-oh-my-bash, but I didn't find any reference to my old file in the replaced one.

Why not try to make oh-my-bash a modular addon, where it supplements what a user has, instead of replacing everything? With the current method, if I then make changes to .bashrc (oh-my-bash's version), and then decide to uninstall OMB later, I'll lose those changes, because my original .bashrc will be restored. What about sourcing a .bashrc-oh-my-bash file with OMB specific settings? This way, config isn't tied to one or the other, in case OMB is installed/uninstalled.

@alexpfx
Copy link
Contributor

alexpfx commented Aug 6, 2020

@dreais Yes, we do support that functionality. If you take a look into https://github.com/ohmybash/oh-my-bash/blob/master/tools/uninstall.sh

You will see that whenever you execute uninstall_oh_my_bash it will revert your current .bashrc with .bashrc.pre-oh-my-bash :)

If you run the instalation twice, like I did for some reason... the .bashrc.pre-oh-my-bash will be overwrited I the old one will be lost.

Maybe you should create the .bashrc backup using a date in the name, like you did with the file create after uninstall: .bashrc.omb-uninstalled-20200806201204

@akinomyoga
Copy link
Contributor

I have fixed this issue in #284. I have adopted the idea by @alexpfx. Thanks

@Steve973
Copy link

I just created another ticket that is similar to this one. There's no need to overwrite anything in .bashrc, and I think that most people who are using oh-my-bash are somewhat in the category of "power users". So, changes should be isolated. Maybe the default behavior is to add one line to .bashrc to source the script, but the changes are way too destructive for my taste. Also, to overwrite .bashrc at each update is far too aggressive. I really like oh-my-bash, but being so aggressive with a system file (even if it's a personal one) might end up being too much for me.

@akinomyoga
Copy link
Contributor

akinomyoga commented Feb 23, 2024

somewhat in the category of "power users".

I think it's the opposite. Oh My Bash targets newcomers who don't know where to start customizing Bash and have never (largely) modified their ~/.bashrc or don't want to waste time for the configuration.

This behavior of replacing the rcfile is coming from the original Oh My Zsh. Bash-it also behaves in the same way by default. It's common to replace the rcfile for this kind of configuration framework. To be honest, I also don't like the behavior of replacing the rcfile for my taste, but there is significant demand for that.

But now those upstream projects seem to start supporting the options to suppress replacing the rcfiles, so we may also have such options.

being so aggressive with a system file (even if it's a personal one) might end up being too much for me.

Sure. That's also too much for me, but it depends on the user. I'm not a user of Oh My Bash. I just took over maintenance of this project because there didn't seem to be any users who could properly maintain those Bash scripts and started to cause problems to my own project unlimitedly.

@Bozzified
Copy link

somewhat in the category of "power users".

I think it's the opposite. Oh My Bash targets newcomers who don't know where to start customizing Bash and have never (largely) modified their ~/.bashrc or don't want to waste time for the configuration.

This behavior of replacing the rcfile is coming from the original Oh My Zsh. Bash-it also behaves in the same way by default. It's common to replace the rcfile for this kind of configuration framework. To be honest, I also don't like the behavior of replacing the rcfile for my taste, but there is significant demand for that.

But now those upstream projects seem to start supporting the options to suppress replacing the rcfiles, so we may also have such options.

being so aggressive with a system file (even if it's a personal one) might end up being too much for me.

Sure. That's also too much for me, but it depends on the user. I'm not a user of Oh My Bash. I just took over maintenance of this project because there didn't seem to be any users who could properly maintain those Bash scripts and started to cause problems to my own project unlimitedly.

I'm not sure how there is any justification of overwriting bashrc vs like most other configuration scripts do and append to it. I am on Ubuntu and there's a ton of configuration of the system that is far more important than a pretty prompt and it took me by surprise after installing oh-my-bash and realizing it just nonchalantly backs up my bashrc and just wipes everything with configuration for itself. It's pretty sillly.

@akinomyoga
Copy link
Contributor

I'm not sure how there is any justification of overwriting bashrc

Have you read the part you quoted? I explained the background of the current way in the part you quoted. Your reply doesn't include any arguments related to the background explained there. Both approaches have pros and cons, and the user needs to choose the framework depending on their needs.

vs like most other configuration scripts do and append to it.

What types of configuration scripts do you assume when you say most? Oh My Bash provides the theme, which can conflict with the existing theming if it just appends its setting to ~/.bashrc. It's different from configurations that add a unique feature.

For the theming configurations, I don't think it is possible to automatically detect if there is an existing theme in ~/.bashrc and to automatically integrate a theme with another theme in a robust way. Some of the theme frameworks intend to be appended to ~/.bashrc (such as starship, liquidprompt, sbp), but some are not (such as Bash-it and Oh My Zsh). If the framework chooses the former approach of appending its configuration, the user needs to take care of possible conflicts. This implies that it requires a certain level of knowledge from its users. OMB takes the latter approach of entirely replacing ~/.bashrc (as OMB is just derived from those OMZ and Bash-it). They have been in this way for a long time.

I am on Ubuntu and there's a ton of configuration of the system that is far more important than a pretty prompt

As far as I remember, in Ubuntu, the important system configurations are supposed to be loaded from /etc/bash.bashrc, which is loaded by Bash before loading ~/.bashrc. So even if ~/.bashrc is replaced, those system configurations should still be loaded.

and it took me by surprise after installing oh-my-bash and realizing it just nonchalantly backs up my bashrc and just wipes everything with configuration for itself. It's pretty silly.

What is silly? Sure, it's not ideal, but there is a background.

@essamgouda97
Copy link

Note on newer versions the .bashrc file is backed up automatically in the home directory ~/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants