2

I'm trying to install Oh my zsh through script:

ssh username@host "
   sh -c \"\$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)\"
"

However, when the install finishes, it hangs, the command doesn't exit. It waits for my input and I have to pres CTRL+C so it ends. How can I make it run and exit itself?

I found some answers here with similar issues so I tried executing these but the result was pretty much the same.

sh -c \"\$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)\" &
sh -c \"\$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)\" 1>&2
4
+50

After reviewing the script itself, I guess it is not really possible without a small modification at the end of it.

The line env zsh -l actually runs zsh, and it is this zsh which waits for your input. I would suggest forking this script and removing this line.

The cause why & didn't work is because the ssh session wasn't closed because of a background task not finishing (the actual env zsh -l line).

You can also try to run the script with nohup, which will disconnect the script from the actual ssh session.

nohup sh -c \"\$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)\" &

But this way it would be still spawning zsh at the end, leaving it with an unused process disconnected from anything.

UPDATE:

Another way to cope with the problem may be using sed to strip out the unneeded command. The resulting command would be like this:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.