Skip to content

Instantly share code, notes, and snippets.

@speto
Last active January 26, 2022 19:36
Show Gist options
  • Save speto/89c741391b5283e3071938f4d4d61553 to your computer and use it in GitHub Desktop.
Save speto/89c741391b5283e3071938f4d4d61553 to your computer and use it in GitHub Desktop.
Execute shell script directly from a URL or create shell command line installation script (macOS)

Execute shell script directly from a URL or create shell command line installation script (macOS)

non-sudo

zsh -c "$(curl -sL https://gist.githubusercontent.com/speto/89c741391b5283e3071938f4d4d61553/raw/whoami.sh)"

or

zsh <(curl -sL https://gist.githubusercontent.com/speto/89c741391b5283e3071938f4d4d61553/raw/whoami.sh)

sudo

sudo zsh -c "$(curl -sL https://gist.githubusercontent.com/speto/89c741391b5283e3071938f4d4d61553/raw/whoami.sh)"

or (doesn't work with read)

sudo zsh < <(curl -sL https://gist.githubusercontent.com/speto/89c741391b5283e3071938f4d4d61553/raw/whoami.sh)

run sudo only for specific command in script

zsh -c "$(curl -sL https://gist.githubusercontent.com/speto/89c741391b5283e3071938f4d4d61553/raw/whoami_with_sudo.sh)"
zsh <(curl -sL https://gist.githubusercontent.com/speto/89c741391b5283e3071938f4d4d61553/raw/whoami_with_sudo.sh)

Resources

#!/usr/bin/env zsh
whoami
#!/usr/bin/env zsh
whoami
sudo whoami
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment