Skip to content

Instantly share code, notes, and snippets.

@bates64
Last active February 6, 2020 21:23
Show Gist options
  • Save bates64/cf9ca4e645d8b7b1951c42d2b9c6f2f6 to your computer and use it in GitHub Desktop.
Save bates64/cf9ca4e645d8b7b1951c42d2b9c6f2f6 to your computer and use it in GitHub Desktop.
New-Item -ItemType Directory -Force -Path "$HOME\.starpkg"
Invoke-WebRequest -Uri "https://github.com/nanaian/starpkg/releases/latest/download/starpkg-x86_64-pc-windows-msvc.zip" -OutFile "~\Downloads\starpkg.zip"
Expand-Archive -Force -Path "~\Downloads\starpkg.zip" -DestinationPath "$HOME\.starpkg"
Remove-Item "~\Downloads\starpkg.zip"
$path = [Environment]::GetEnvironmentVariable("Path", "User")
if ($path -notlike "*$HOME\.starpkg*") {
[Environment]::SetEnvironmentVariable("Path", "$HOME\.starpkg;" + $path, "User")
Write-Output " "
Write-Output "starpkg installed! :)"
} else {
Write-Output " "
Write-Output "starpkg updated! :)"
}
mkdir -p ~/.starpkg
platform="$(uname -s | tr '[:upper:]' '[:lower:]')"
if [ "${platform}" = "darwin" ]; then
# macOS
curl -o starpkg.tar.gz -L https://github.com/nanaian/starpkg/releases/latest/download/starpkg-x86_64-apple-darwin.tar.gz
else
# Linux
if ldd /bin/sh | grep -i musl >/dev/null; then
# Linux (MUSL)
curl -o starpkg.tar.gz -L https://github.com/nanaian/starpkg/releases/latest/download/starpkg-x86_64-unknown-linux-musl.tar.gz
else
# Linux (GNU)
curl -o starpkg.tar.gz -L https://github.com/nanaian/starpkg/releases/latest/download/starpkg-x86_64-unknown-linux-gnu.tar.gz
fi
fi
tar -xf starpkg.tar.gz -C ~/.starpkg
rm starpkg.tar.gz
chmod +x ~/.starpkg/starpkg
echo "starpkg installed/updated! :)"
if [ -d "$HOME/.local/bin" ]; then
ln -s ~/.starpkg/starpkg ~/.local/bin
else
if [ -d "$HOME/bin" ]; then
ln -s ~/.starpkg/starpkg ~/bin
else
echo "please add ~/.starpkg to your PATH"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment