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

Prevent change shell during setup #4261

Closed
flip111 opened this issue Aug 18, 2015 · 14 comments
Closed

Prevent change shell during setup #4261

flip111 opened this issue Aug 18, 2015 · 14 comments
Labels
Area: installer Issue or PR related to the installer

Comments

@flip111
Copy link

flip111 commented Aug 18, 2015

Is there a flag to the setup script that prevents changing to zsh after installation? I would like zsh to become the default shell but not on the shell session during installation. This is because i have an installation script which halts when installing oh my zsh. I have to manually type exit before the script resumes in the old shell.

@apjanke
Copy link
Contributor

apjanke commented Aug 18, 2015

There isn't. But this might be nice to have. (And if you want to go fully-scriptable, you'd probably want is a full "non-interactive" flag for the installer, because there are other points it might block and wait on user input as well, like the password for chsh.) The line at the end where it sources ~/.zshrc after returning from the subshell (or inside the subshell, depending on how the installer was run) may be an issue too.

Since the installer is a core part of OMZ, changes to it take a while to go through. However, the installer doesn't care where it's run from, so you can easily make your own variant of it. Just create a new repo, copy the installer over, remove those last couple lines, and use the URL to your installer instead of the default one when doing your scripted installations.

@mcornella
Copy link
Member

Just create a new repo, copy the installer over, remove those last couple lines, and use the URL to your installer instead of the default one when doing your scripted installations.

That's how babun does it anyway, I think. A simple git clone and the zshrc file modification is all that's needed, in fact.

@flip111
Copy link
Author

flip111 commented Sep 10, 2015

I don't find the trigger line for starting the actual z-shell. There are a lot of things being sourced though

@apjanke
Copy link
Contributor

apjanke commented Sep 10, 2015

I'm not sure I understand what you're saying here.

Aside from its installer, nothing in Oh My Zsh starts zsh. It works the other way around: you start zsh somehow (for example, by starting a new terminal session), and zsh automatically loads ~/.zshrc as part of its startup sequence, and then ~/.zshrc loads Oh My Zsh by sourcing ~/.oh-my-zsh/oh-my-zsh.sh.

@flip111
Copy link
Author

flip111 commented Sep 10, 2015

@apjanke i observed that after running sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" the prompt changes, then when i type exit it returns to the previous prompt and my setup script continues. This made me believe that zsh was started as sub-shell by oh-my-zsh.

@apjanke
Copy link
Contributor

apjanke commented Sep 10, 2015

Ah: yes, during the installer, it is. But that's just a one-time quirk of the installer (sort of giving you a preview of what your zsh will look like from now on), and doesn't reflect normal usage of OMZ. (There's a longish discussion of this in #3664.)

Once it's installed, the normal sequence is: you start up a shell session, and OMZ is loaded automatically from ~/.zshrc.

@flip111
Copy link
Author

flip111 commented Sep 14, 2015

Is it possible to disable this functionality? (the one-time quirk of the installer). Looking at what you wrote in the other issue there is no official option yet. So that would leaving hacking it a bit, i wonder if this is a one-liner or drastically change things around.

@apjanke
Copy link
Contributor

apjanke commented Sep 14, 2015

Easy change. Just comment out these last two lines

env zsh
. ~/.zshrc

@flip111
Copy link
Author

flip111 commented Sep 14, 2015

thanks @apjanke shall i leave the issue open for the official option?

@mcornella
Copy link
Member

We can open a tracking issue related to the install script and point here. There are a number of issues with it and we should collect them. It doesn't matter if this one is closed, we got the feature request and we'll put it there.
TL;DR you can close this one thanks 😁

@leoj3n
Copy link
Contributor

leoj3n commented Aug 18, 2016

Could wrap the code in a file descriptor check:

# Do not prompt user unless STDIN file descriptor is bound to TTY,
if [ -t 0 ]; then
  # chsh
  # env zsh
fi

Then run the install like:

0>/dev/null sh -c "$(curl -fsSL ...)"

@lezsakdomi
Copy link

lezsakdomi commented Apr 16, 2018

I've done some hacking, for automating OMZ installation process:

sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sed '/\s*env\s\s*zsh\s*/d')" \

For other modifications, it's better to revert them after running the install script. See http://lezsakdomi-home.herokuapp.com/.bashrc and grep for oh-my-zsh (solution should be up-to-date here)

@Tomotoes
Copy link

Tomotoes commented May 8, 2019

NO_INTERACTIVE=true sh -c "$(curl -fsSL https://raw.githubusercontent.com/subtlepseudonym/oh-my-zsh/feature/install-noninteractive/tools/install.sh)"

@mcornella mcornella added the Area: installer Issue or PR related to the installer label May 24, 2019
@mcornella
Copy link
Member

Hi there, I pulled the changes from #7266 in #5169, which mean you can now add --skip-chsh to the install script call, as well as set the environment variable CHSH to no so that the script doesn't attempt to change the default shell. You can also run it with --unattended so that zsh is not run at the end of the install.

If you want to help speed up the testing and merge (which should happen early next week), you can wget or curl it from the URL https://raw.githubusercontent.com/mcornella/oh-my-zsh/refactor-installer/tools/install.sh. Read the comments at the top of the script to know how to call it.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: installer Issue or PR related to the installer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants