cantino / mcfly

Fly through your shell history. Great Scott!
MIT License
6.85k stars 178 forks source link

update script #142

Closed Konfekt closed 3 years ago

Konfekt commented 3 years ago

Dear @cantino,

I wanted to add the following script to update the mcfly binary (say in ~/bin to be run by a cron job) to the wiki but I cannot access this page. Below it is:

#!/usr/bin/env sh

# debug output and exit on error or use of undeclared variable or pipe error:
set -o xtrace -o errtrace -o errexit -o nounset -o pipefail

latest_tag="$(curl --location --head https://github.com/cantino/mcfly/releases/latest | grep -i location: | sed 's/^.*\/tag\/\([^\/]*\)\r$/\1/')"
filename="mcfly-${latest_tag}-x86_64-unknown-linux-gnu.tar.gz"
uri_to_download="https://github.com/cantino/mcfly/releases/download/${latest_tag}/${filename}"

{
cd "$(mktemp --directory "${TMPDIR:-/tmp}/mcfly-update.XXXXXXXXXX")"
    curl --fail --show-error --remote-name --location "$uri_to_download"
    tar xf "$filename"
    chmod a+x mcfly
    cp mcfly "$HOME/bin"
}

if [ ! -x "$HOME/bin/mcfly" ]; then
    echo '"mcfly" was not successfully installed!' >&2
    # DISPLAY=:0 notify-send --urgency=critical "Failed updating mcfly!
      # Run $0 to check."
    exit 2
fi
cantino commented 3 years ago

Thanks @Konfekt!

cantino commented 3 years ago

https://github.com/cantino/mcfly/wiki/Linux-update-script