Last active
March 14, 2017 03:12
-
-
Save jozic/d123eaa4e87eda102deb0bf7161bff03 to your computer and use it in GitHub Desktop.
curl_install
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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