#!/bin/sh set -eu usage() { cat <=~/.local] Installs latest code-server on any macOS or Linux system preferring to use the OS package manager. curl -fsSL https://code-server.dev/install.sh | sh -s -- - For Debian, Ubuntu, Raspbian it will install the latest deb package. - For Fedora, CentOS, RHEL, openSUSE it will install the latest rpm package. - For Arch Linux it will install the AUR package. - For any unrecognized Linux operating system it will install the latest static release into ~/.local - Add ~/.local/bin to your \$PATH to run code-server. - For macOS it will install the Homebrew package. - If Homebrew is not installed it will install the latest static release into ~/.local - Add ~/.local/bin to your \$PATH to run code-server. - If ran on an architecture with no binary releases or outdated libc/libcxx, it will install the npm package with yarn or npm. - We only have binary releases for amd64 and arm64 presently. --dry-run Enables a dry run where where the steps that would have taken place are printed but do not actually execute. --version Pass to install a specific version instead of the latest release. --static Forces the installation of a static release into ~/.local This flag takes an optional argument for the installation prefix which defaults to "~/.local". code-server will be unarchived into ~/.local/lib/code-server.X.X.X and the binary will be symlinked into "~/.local/bin/code-server". You will need to add ~/.local/bin to your \$PATH to use it without the full path. To install system wide set the prefix to /usr/local. EOF } echo_latest_version() { version="$(curl -fsSL https://api.github.com/repos/cdr/code-server/releases/latest | jq -r .tag_name)" # Strip leading v. version="${version:1}" echo "$version" } echo_static_postinstall() { echo cat </dev/null 2>&1 } sh_c() { if [ ! "${SKIP_LOG-}" ]; then echo echo "+ $*" fi if [ ! "${DRY_RUN-}" ]; then sh -c "$*" fi } sudo_sh_c() { if [ "$(id -u)" = 0 ]; then sh_c "$@" elif command_exists sudo; then sh_c "sudo $*" elif command_exists su; then sh_c "su -c '$*'" else echo echoerr "This script needs to run the following command as root." echoerr " $*" echoerr "Please run this script as root or install sudo or su." exit 1 fi } echo_cache_dir() { if [ "${XDG_CACHE_HOME-}" ]; then echo "$XDG_CACHE_HOME/code-server" elif [ "${HOME-}" ]; then echo "$HOME/.cache/code-server" else echo "/tmp/code-server-cache" fi } echoerr() { echo "$@" >&2 } main "$@"