Apple - How to install tar.gz file directly from URL efficiently from terminal?

If you don't want to keep the tar file, do

curl https://cran.r-project.org/src/base/R-3/R-3.5.0.tar.gz | tar zxf -

This uncompresses and extracts the tar file while downloading it.

The commands to install vary with the package, but you can do this after the download has finished:

cd R-3.5.0 ; ./configure && make

This will work better as a script that accepts a parameter.

tar_from_url() {
    URL="$1"
    curl -O "$URL"
    tar -xvf "${URL##*/}"
    rm "${URL##*/}"
}

So basically use curl to download, then use tar to extract, finally get rid of downloaded file.

The installation part needs still to be done manually though. The name of the directory it extracts to is unknown and different depending on the actual tar file, as is the method required for installation itself.