I'm trying to install starship by a single command but when I run the following one it asks key input. Then how can I pass it "y" automatically without typing? I believe yes
command may help but don't know how can I use in this case.
$ curl -sS https://starship.rs/install.sh | sh
Configuration
> Bin directory: /usr/local/bin
> Platform: unknown-linux-musl
> Arch: aarch64
> Tarball URL: https://github.com/starship/starship/releases/latest/download/starship-aarch64-unknown-linux-musl.tar.gz
? Install Starship latest to /usr/local/bin? [y/N]
CodePudding user response:
You can't, because you are already redirecting curl
to sh
.
Inspecting the script reveals that you can run it with -y
to avoid interactive prompts, so probably just do that.
curl -sS https://starship.rs/install.sh | sh -s -- -y
The -s
option allows you to pass options to the script from the sh
command line and the --
is then required to separate the sh
options from the options you pass to the script.
In the general case, if the script was written so that it unconditionally requires interactive I/O, you really need to download it to a file and then run that file with redirection.
#!/bin/bash
dest=$(mktemp -t) || exit
trap 'rm -f "$dest"' ERR EXIT HUP INT TERM
curl -sS https://starship.rs/install.sh >"$dest"
yes | sh "$dest"
The use of ERR
and EXIT
with trap
is a Bash extension. If you informally run this by hand, the scripted generation of a temporary file and the associated trap can probably be replaced with something more ad-hoc.