2024-06-12 04:12:14 +03:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
set -eu
|
2024-04-30 23:25:12 +03:00
|
|
|
|
|
|
|
main() {
|
|
|
|
platform="$(uname -s)"
|
|
|
|
arch="$(uname -m)"
|
2024-05-02 06:51:38 +03:00
|
|
|
channel="${ZED_CHANNEL:-stable}"
|
2024-04-30 23:25:12 +03:00
|
|
|
temp="$(mktemp -d "/tmp/zed-XXXXX")"
|
|
|
|
|
2024-06-12 04:12:14 +03:00
|
|
|
if [ "$platform" = "Darwin" ]; then
|
2024-04-30 23:25:12 +03:00
|
|
|
platform="macos"
|
2024-06-12 04:12:14 +03:00
|
|
|
elif [ "$platform" = "Linux" ]; then
|
2024-04-30 23:25:12 +03:00
|
|
|
platform="linux"
|
|
|
|
else
|
|
|
|
echo "Unsupported platform $platform"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-06-12 04:12:14 +03:00
|
|
|
case "$platform-$arch" in
|
2024-06-21 10:46:25 +03:00
|
|
|
macos-arm64* | linux-arm64* | linux-armhf | linux-aarch64)
|
2024-06-12 04:12:14 +03:00
|
|
|
arch="aarch64"
|
|
|
|
;;
|
|
|
|
macos-x86* | linux-x86* | linux-i686*)
|
|
|
|
arch="x86_64"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unsupported platform or architecture"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2024-04-30 23:25:12 +03: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 04:12:14 +03:00
|
|
|
}
|
2024-04-30 23:25:12 +03:00
|
|
|
else
|
|
|
|
echo "Could not find 'curl' or 'wget' in your path"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
"$platform" "$@"
|
2024-07-09 22:34:32 +03:00
|
|
|
|
|
|
|
if [ "$(which "zed")" = "$HOME/.local/bin/zed" ]; 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:"
|
|
|
|
|
|
|
|
case "$SHELL" in
|
|
|
|
*zsh)
|
|
|
|
echo " echo 'export PATH=\$HOME/.local/bin:\$PATH' >> ~/.zshrc"
|
|
|
|
echo " source ~/.zshrc"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo " echo 'export PATH=\$HOME/.local/bin:\$PATH' >> ~/.bashrc"
|
|
|
|
echo " source ~/.bashrc"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
echo "To run Zed now, '~/.local/bin/zed'"
|
|
|
|
fi
|
2024-04-30 23:25:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
linux() {
|
2024-06-13 16:59:28 +03:00
|
|
|
if [ -n "${ZED_BUNDLE_PATH:-}" ]; then
|
2024-06-11 05:43:13 +03: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 23:25:12 +03:00
|
|
|
|
2024-05-01 01:01:07 +03:00
|
|
|
suffix=""
|
2024-06-12 04:12:14 +03:00
|
|
|
if [ "$channel" != "stable" ]; then
|
2024-05-01 01:01:07 +03:00
|
|
|
suffix="-$channel"
|
|
|
|
fi
|
|
|
|
|
2024-05-03 12:03:55 +03: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 06:51:38 +03:00
|
|
|
rm -rf "$HOME/.local/zed$suffix.app"
|
2024-05-01 01:01:07 +03:00
|
|
|
mkdir -p "$HOME/.local/zed$suffix.app"
|
2024-04-30 23:25:12 +03:00
|
|
|
tar -xzf "$temp/zed-linux-$arch.tar.gz" -C "$HOME/.local/"
|
|
|
|
|
2024-05-03 12:03:55 +03:00
|
|
|
# Setup ~/.local directories
|
2024-04-30 23:25:12 +03:00
|
|
|
mkdir -p "$HOME/.local/bin" "$HOME/.local/share/applications"
|
2024-05-03 12:03:55 +03:00
|
|
|
|
|
|
|
# Link the binary
|
2024-06-12 04:12:14 +03: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-05 01:31:01 +03:00
|
|
|
else
|
|
|
|
# support for versions before 0.139.x.
|
2024-06-12 04:12:14 +03:00
|
|
|
ln -sf "$HOME/.local/zed$suffix.app/bin/cli" "$HOME/.local/bin/zed"
|
2024-06-05 01:31:01 +03:00
|
|
|
fi
|
2024-05-03 12:03:55 +03:00
|
|
|
|
|
|
|
# Copy .desktop file
|
|
|
|
desktop_file_path="$HOME/.local/share/applications/${appid}.desktop"
|
2024-06-12 04:12:14 +03:00
|
|
|
cp "$HOME/.local/zed$suffix.app/share/applications/zed$suffix.desktop" "${desktop_file_path}"
|
2024-05-03 12:03:55 +03: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 05:43:13 +03:00
|
|
|
sed -i "s|Exec=zed|Exec=$HOME/.local/zed$suffix.app/libexec/zed-editor|g" "${desktop_file_path}"
|
2024-04-30 23:25:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
macos() {
|
2024-05-01 01:01:07 +03:00
|
|
|
echo "Downloading Zed"
|
2024-04-30 23:25:12 +03: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 04:12:14 +03:00
|
|
|
if [ -d "/Applications/$app" ]; then
|
2024-04-30 23:25:12 +03:00
|
|
|
echo "Removing existing $app"
|
|
|
|
rm -rf "/Applications/$app"
|
|
|
|
fi
|
2024-05-02 06:51:38 +03:00
|
|
|
ditto "$temp/mount/$app" "/Applications/$app"
|
2024-04-30 23:25:12 +03:00
|
|
|
hdiutil detach -quiet "$temp/mount"
|
2024-05-02 06:51:38 +03:00
|
|
|
|
2024-05-22 07:39:16 +03:00
|
|
|
mkdir -p "$HOME/.local/bin"
|
|
|
|
# Link the binary
|
2024-06-12 04:12:14 +03:00
|
|
|
ln -sf "/Applications/$app/Contents/MacOS/cli" "$HOME/.local/bin/zed"
|
2024-04-30 23:25:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|