Skip to content

Instantly share code, notes, and snippets.

@jozic
Last active March 14, 2017 03:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jozic/d123eaa4e87eda102deb0bf7161bff03 to your computer and use it in GitHub Desktop.
Save jozic/d123eaa4e87eda102deb0bf7161bff03 to your computer and use it in GitHub Desktop.
curl_install
# downloads a file specified by first parameter, puts it to /usr/local/bin (or second parameter) and gives it +x permissions
curl_install() {
if [[ $# == 0 ]]; then
echo "At least one parameter (url) is required"
return
elif [[ $# == 1 ]]; then
local url=$1
local file="/usr/local/bin/"${url##*/}
elif [[ $# == 2 ]] ; then
local url=$1
local file=$2
fi
echo "Installing $url to $file ..."
sudo curl -L -o $file $url && sudo chmod +x $file
echo "Done!"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment