curl -L https://gist.github.com/emersion/c95d210fc9123f2c30f99112b0c913c0/raw/install-micro.sh | bash
-
-
Save emersion/c95d210fc9123f2c30f99112b0c913c0 to your computer and use it in GitHub Desktop.
Install micro text editor
This file contains 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
#!/bin/bash | |
unamem="$(uname -m)" | |
if [[ $unamem == *64* ]]; then | |
micro_arch="64" | |
elif [[ $unamem == *86* ]]; then | |
micro_arch="32" | |
elif [[ $unamem == *armv5* ]]; then | |
micro_arch="-arm" | |
micro_arm="5" | |
elif [[ $unamem == *armv6l* ]]; then | |
micro_arch="-arm" | |
micro_arm="6" | |
elif [[ $unamem == *armv7l* ]]; then | |
micro_arch="-arm" | |
micro_arm="7" | |
else | |
echo "Aborted, unsupported or unknown architecture: $unamem" | |
return 1 | |
fi | |
unameu="$(tr '[:lower:]' '[:upper:]' <<<$(uname))" | |
if [[ ${unameu} == *DARWIN* ]]; then | |
micro_os="osx" | |
micro_arch="" | |
elif [[ ${unameu} == *LINUX* ]]; then | |
micro_os="linux" | |
elif [[ ${unameu} == *WIN* ]]; then | |
micro_os="win" | |
else | |
echo "Aborted, unsupported or unknown os: $uname" | |
return 2 | |
fi | |
echo -n "Checking latest version... " | |
micro_version=`curl -sI https://github.com/zyedidia/micro/releases/latest | grep Location | sed "s~^.*tag\/v~~" | tr -d '\n' | tr -d '\r'` | |
if [ ! "$micro_version" ] ; then | |
echo "Failed to find version" | |
exit 3 | |
fi | |
echo "Found ${micro_version}" | |
#building url | |
micro_file="micro-${micro_version}-${micro_os}${micro_arch}.tar.gz" | |
micro_url="https://github.com/zyedidia/micro/releases/download/v${micro_version}/${micro_file}" | |
#download | |
PWD=`pwd` | |
DL=/tmp/microdl | |
echo "Downloading: $URL" && \ | |
mkdir -p $DL && curl -L -"#" $micro_url | tar zxf - -C $DL && \ | |
cd $DL/micro-${micro_version}/ && \ | |
chmod +x micro && \ | |
((mv micro /usr/local/bin/micro > /dev/null 2>&1 && echo "Installed micro to /usr/local/bin") || \ | |
(mv micro $PWD/micro && echo "Downloaded micro to $PWD")) && \ | |
rm -rf $DL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment