mac-dotfiles/install-mac-apps.sh

41 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
[ -n "${DEBUG-}" ] && set -x
cd "$(dirname "$0")" || exit 1
shellcheck "$0" || exit 1
shfmt -i 2 -d -s "$0"
newest_wezterm_release() {
curl -s -H "Accept: application/vnd.github+json" -L https://api.github.com/repos/wez/wezterm/releases/latest | jq -r '.assets | map(select(.name | startswith("WezTerm-macos"))) | first.browser_download_url'
}
LATEST_WEZTERM=$(newest_wezterm_release)
install_latest_wezterm() {
curl -Lo wezterm.zip "$LATEST_WEZTERM"
ouch d wezterm.zip
mv WezTerm-macos-*/WezTerm.app /Applications/ && rm -rf wezterm.zip WezTerm-macos-*
}
if [ ! -e /Applications/WezTerm.app ]; then
install_latest_wezterm
else
current_wezterm=$(/Applications/WezTerm.app/Contents/MacOS/wezterm -V | awk '{print $2}')
if ! echo "$LATEST_WEZTERM" | grep "$current_wezterm" >/dev/null; then
install_latest_wezterm
fi
fi
[ -d /usr/local/bin ] || sudo mkdir /usr/local/bin
install_typst() {
echo "manually installing typst"
curl -sLO https://github.com/typst/typst/releases/download/22-03-21-2/typst-x86_64-apple-darwin.tar.gz
ouch d typst*.tar.gz
sudo install -m 755 typst*/typst /usr/local/bin/
rm -rf ./typst*
}
[ -e "/usr/local/bin/typst" ] || install_typst