Files
shell/install/sublimemerge
T
2026-07-10 15:11:51 +08:00

79 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
##makedesc: Install Sublime Merge
set -eo pipefail
installed() { command -v "$1" >/dev/null 2>&1; }
download() {
if installed wget; then
wget -q --show-progress "$1" -O "$2"
else
curl -fsSL "$1" -o "$2"
fi
}
install() {
if [ "$(uname -s)" = "Darwin" ]; then
if installed brew; then
brew install --cask sublime-merge
else
echo "ERROR: Install Homebrew first." >&2
exit 1
fi
return
fi
echo
echo "==============================================="
echo "Installing Sublime Merge"
echo "==============================================="
echo
# https://www.sublimemerge.com/download
SMVER='2102'
mkdir -p "$HOME/install"
DEB_PATH="$HOME/install/sublime-merge_build-${SMVER}_amd64.deb"
BIN_PATH="/opt/sublime_merge/sublime_merge"
if [[ ! -f "$DEB_PATH" ]]; then
download "https://download.sublimetext.com/sublime-merge_build-${SMVER}_amd64.deb" "$DEB_PATH"
fi
sudo dpkg -i "$DEB_PATH"
echo
echo "Finish!"
$BIN_PATH --version
echo
}
remove() {
if [ "$(uname -s)" = "Darwin" ]; then
if installed brew; then
brew uninstall --cask sublime-merge
fi
return
fi
echo
echo "==============================================="
echo "Removing Sublime Merge"
echo "==============================================="
echo
sudo dpkg -r sublime-merge 2>/dev/null || true
sudo rm -rf /opt/sublime_merge
echo
echo "Finish!"
echo
}
case "$1" in
r|remove|d|delete|p|purge) remove ;;
*) install ;;
esac