2024-06-12 01:12:14 +00:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
set -eu
|
2024-04-30 20:25:12 +00:00
|
|
|
|
2024-07-10 18:08:54 +00:00
|
|
|
# Downloads the latest tarball from https://zed.dev/releases and unpacks it
|
|
|
|
# into ~/.local/. If you'd prefer to do this manually, instructions are at
|
|
|
|
# https://zed.dev/docs/linux.
|
|
|
|
|
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-07-10 21:41:43 +00:00
|
|
|
temp="$(mktemp -d "/tmp/zed-XXXXXX")"
|
2024-04-30 20:25:12 +00:00
|
|
|
|
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"
|
|
|
|
else
|
|
|
|
echo "Unsupported platform $platform"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-06-12 01:12:14 +00:00
|
|
|
case "$platform-$arch" in
|
2024-06-21 07:46:25 +00:00
|
|
|
macos-arm64* | linux-arm64* | linux-armhf | linux-aarch64)
|
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
|
|
|
|
2024-11-07 07:34:56 +00:00
|
|
|
if command -v curl >/dev/null 2>&1; then
|
2024-04-30 20:25:12 +00:00
|
|
|
curl () {
|
|
|
|
command curl -fL "$@"
|
|
|
|
}
|
2024-11-07 07:34:56 +00:00
|
|
|
elif command -v wget >/dev/null 2>&1; then
|
2024-04-30 20:25:12 +00:00
|
|
|
curl () {
|
2024-08-28 23:25:19 +00:00
|
|
|
wget -O- "$@"
|
2024-06-12 01:12:14 +00:00
|
|
|
}
|
2024-04-30 20:25:12 +00:00
|
|
|
else
|
2024-08-28 23:25:19 +00:00
|
|
|
echo "Could not find 'curl' or 'wget' in your path"
|
|
|
|
exit 1
|
2024-04-30 20:25:12 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
"$platform" "$@"
|
2024-07-09 19:34:32 +00:00
|
|
|
|
2024-11-07 07:34:56 +00:00
|
|
|
if [ "$(command -v zed)" = "$HOME/.local/bin/zed" ]; then
|
2024-07-09 19:34:32 +00:00
|
|
|
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"
|
|
|
|
;;
|
2024-07-15 17:11:09 +00:00
|
|
|
*fish)
|
|
|
|
echo " fish_add_path -U $HOME/.local/bin"
|
|
|
|
;;
|
2024-07-09 19:34:32 +00:00
|
|
|
*)
|
|
|
|
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 20:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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-04-30 20:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|