2024-06-12 01:12:14 +00:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
set -eu
|
2024-04-30 20:25:12 +00:00
|
|
|
|
|
|
|
main() {
|
|
|
|
platform="$(uname -s)"
|
|
|
|
arch="$(uname -m)"
|
2024-05-02 03:51:38 +00:00
|
|
|
channel="${ZED_CHANNEL:-stable}"
|
2024-04-30 20:25:12 +00:00
|
|
|
temp="$(mktemp -d "/tmp/zed-XXXXX")"
|
|
|
|
|
2024-06-12 01:12:14 +00:00
|
|
|
if [ "$platform" = "Darwin" ]; then
|
2024-04-30 20:25:12 +00:00
|
|
|
platform="macos"
|
2024-06-12 01:12:14 +00:00
|
|
|
elif [ "$platform" = "Linux" ]; then
|
2024-04-30 20:25:12 +00:00
|
|
|
platform="linux"
|
2024-05-02 03:51:38 +00:00
|
|
|
channel="${ZED_CHANNEL:-preview}"
|
2024-04-30 20:25:12 +00:00
|
|
|
else
|
|
|
|
echo "Unsupported platform $platform"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-06-12 01:12:14 +00:00
|
|
|
case "$platform-$arch" in
|
2024-06-18 20:29:19 +00:00
|
|
|
macos-arm64* | linux-arm64* | linux-armhf)
|
2024-06-12 01:12:14 +00:00
|
|
|
arch="aarch64"
|
|
|
|
;;
|
|
|
|
macos-x86* | linux-x86* | linux-i686*)
|
|
|
|
arch="x86_64"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unsupported platform or architecture"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2024-04-30 20:25:12 +00:00
|
|
|
|
|
|
|
if which curl >/dev/null 2>&1; then
|
|
|
|
curl () {
|
|
|
|
command curl -fL "$@"
|
|
|
|
}
|
|
|
|
elif which wget >/dev/null 2>&1; then
|
|
|
|
curl () {
|
|
|
|
wget -O- "$@"
|
2024-06-12 01:12:14 +00:00
|
|
|
}
|
2024-04-30 20:25:12 +00:00
|
|
|
else
|
|
|
|
echo "Could not find 'curl' or 'wget' in your path"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
"$platform" "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
linux() {
|
2024-06-13 13:59:28 +00:00
|
|
|
if [ -n "${ZED_BUNDLE_PATH:-}" ]; then
|
2024-06-11 02:43:13 +00:00
|
|
|
cp "$ZED_BUNDLE_PATH" "$temp/zed-linux-$arch.tar.gz"
|
|
|
|
else
|
|
|
|
echo "Downloading Zed"
|
|
|
|
curl "https://zed.dev/api/releases/$channel/latest/zed-linux-$arch.tar.gz" > "$temp/zed-linux-$arch.tar.gz"
|
|
|
|
fi
|
2024-04-30 20:25:12 +00:00
|
|
|
|
2024-04-30 22:01:07 +00:00
|
|
|
suffix=""
|
2024-06-12 01:12:14 +00:00
|
|
|
if [ "$channel" != "stable" ]; then
|
2024-04-30 22:01:07 +00:00
|
|
|
suffix="-$channel"
|
|
|
|
fi
|
|
|
|
|
2024-05-03 09:03:55 +00:00
|
|
|
appid=""
|
|
|
|
case "$channel" in
|
|
|
|
stable)
|
|
|
|
appid="dev.zed.Zed"
|
|
|
|
;;
|
|
|
|
nightly)
|
|
|
|
appid="dev.zed.Zed-Nightly"
|
|
|
|
;;
|
|
|
|
preview)
|
|
|
|
appid="dev.zed.Zed-Preview"
|
|
|
|
;;
|
|
|
|
dev)
|
|
|
|
appid="dev.zed.Zed-Dev"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unknown release channel: ${channel}. Using stable app ID."
|
|
|
|
appid="dev.zed.Zed"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Unpack
|
2024-05-02 03:51:38 +00:00
|
|
|
rm -rf "$HOME/.local/zed$suffix.app"
|
2024-04-30 22:01:07 +00:00
|
|
|
mkdir -p "$HOME/.local/zed$suffix.app"
|
2024-04-30 20:25:12 +00:00
|
|
|
tar -xzf "$temp/zed-linux-$arch.tar.gz" -C "$HOME/.local/"
|
|
|
|
|
2024-05-03 09:03:55 +00:00
|
|
|
# Setup ~/.local directories
|
2024-04-30 20:25:12 +00:00
|
|
|
mkdir -p "$HOME/.local/bin" "$HOME/.local/share/applications"
|
2024-05-03 09:03:55 +00:00
|
|
|
|
|
|
|
# Link the binary
|
2024-06-12 01:12:14 +00:00
|
|
|
if [ -f "$HOME/.local/zed$suffix.app/bin/zed" ]; then
|
|
|
|
ln -sf "$HOME/.local/zed$suffix.app/bin/zed" "$HOME/.local/bin/zed"
|
2024-06-04 22:31:01 +00:00
|
|
|
else
|
|
|
|
# support for versions before 0.139.x.
|
2024-06-12 01:12:14 +00:00
|
|
|
ln -sf "$HOME/.local/zed$suffix.app/bin/cli" "$HOME/.local/bin/zed"
|
2024-06-04 22:31:01 +00:00
|
|
|
fi
|
2024-05-03 09:03:55 +00:00
|
|
|
|
|
|
|
# Copy .desktop file
|
|
|
|
desktop_file_path="$HOME/.local/share/applications/${appid}.desktop"
|
2024-06-12 01:12:14 +00:00
|
|
|
cp "$HOME/.local/zed$suffix.app/share/applications/zed$suffix.desktop" "${desktop_file_path}"
|
2024-05-03 09:03:55 +00:00
|
|
|
sed -i "s|Icon=zed|Icon=$HOME/.local/zed$suffix.app/share/icons/hicolor/512x512/apps/zed.png|g" "${desktop_file_path}"
|
2024-06-11 02:43:13 +00:00
|
|
|
sed -i "s|Exec=zed|Exec=$HOME/.local/zed$suffix.app/libexec/zed-editor|g" "${desktop_file_path}"
|
2024-04-30 20:25:12 +00:00
|
|
|
|
2024-05-06 02:17:55 +00:00
|
|
|
if which "zed" >/dev/null 2>&1; then
|
|
|
|
echo "Zed has been installed. Run with 'zed'"
|
2024-05-02 03:51:38 +00:00
|
|
|
else
|
2024-05-03 09:19:11 +00:00
|
|
|
echo "To run Zed from your terminal, you must add ~/.local/bin to your PATH"
|
2024-04-30 22:01:07 +00:00
|
|
|
echo "Run:"
|
|
|
|
echo " echo 'export PATH=\$HOME/.local/bin:\$PATH' >> ~/.bashrc"
|
|
|
|
echo " source ~/.bashrc"
|
2024-05-06 02:17:55 +00:00
|
|
|
echo "To run Zed now, '~/.local/bin/zed'"
|
2024-04-30 20:25:12 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
macos() {
|
2024-04-30 22:01:07 +00:00
|
|
|
echo "Downloading Zed"
|
2024-04-30 20:25:12 +00:00
|
|
|
curl "https://zed.dev/api/releases/$channel/latest/Zed-$arch.dmg" > "$temp/Zed-$arch.dmg"
|
|
|
|
hdiutil attach -quiet "$temp/Zed-$arch.dmg" -mountpoint "$temp/mount"
|
|
|
|
app="$(cd "$temp/mount/"; echo *.app)"
|
|
|
|
echo "Installing $app"
|
2024-06-12 01:12:14 +00:00
|
|
|
if [ -d "/Applications/$app" ]; then
|
2024-04-30 20:25:12 +00:00
|
|
|
echo "Removing existing $app"
|
|
|
|
rm -rf "/Applications/$app"
|
|
|
|
fi
|
2024-05-02 03:51:38 +00:00
|
|
|
ditto "$temp/mount/$app" "/Applications/$app"
|
2024-04-30 20:25:12 +00:00
|
|
|
hdiutil detach -quiet "$temp/mount"
|
2024-05-02 03:51:38 +00:00
|
|
|
|
2024-05-22 04:39:16 +00:00
|
|
|
mkdir -p "$HOME/.local/bin"
|
|
|
|
# Link the binary
|
2024-06-12 01:12:14 +00:00
|
|
|
ln -sf "/Applications/$app/Contents/MacOS/cli" "$HOME/.local/bin/zed"
|
2024-05-22 04:39:16 +00:00
|
|
|
|
|
|
|
if which "zed" >/dev/null 2>&1; then
|
|
|
|
echo "Zed has been installed. Run with 'zed'"
|
|
|
|
else
|
|
|
|
echo "To run Zed from your terminal, you must add ~/.local/bin to your PATH"
|
|
|
|
echo "Run:"
|
|
|
|
echo " echo 'export PATH=\$HOME/.local/bin:\$PATH' >> ~/.bashrc"
|
|
|
|
echo " source ~/.bashrc"
|
|
|
|
echo "To run Zed now, '~/.local/bin/zed'"
|
|
|
|
fi
|
2024-04-30 20:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|