linux

 1#!/usr/bin/bash -e
 2
 3# if not on Linux, do nothing
 4[[ $(uname) == "Linux" ]] || exit 0
 5
 6# Copy settings and keymap to the user's home directory if they don't exist
 7mkdir -p "$HOME/.config/zed"
 8test -f "$HOME/.config/zed/settings.json" ||
 9  cp -uL ./assets/settings/initial_user_settings.json "$HOME/.config/zed/settings.json"
10test -f "$HOME/.config/zed/keymap.json" ||
11  cp -uL ./assets/keymaps/default.json "$HOME/.config/zed/keymap.json"
12
13# if sudo is not installed, define an empty alias
14maysudo=$(command -v sudo || true)
15export maysudo
16
17# Ubuntu, Debian, etc.
18# https://packages.ubuntu.com/
19apt=$(command -v apt-get || true)
20if [[ -n $apt ]]; then
21  deps=(
22    libasound2-dev
23    libfontconfig-dev
24    libxcb-dev
25    alsa-base
26    cmake
27    fontconfig
28    libssl-dev
29    build-essential
30
31  )
32  $maysudo "$apt" install -y "${deps[@]}"
33  exit 0
34fi
35
36# Fedora, CentOS, RHEL, etc.
37# https://packages.fedoraproject.org/
38dnf=$(command -v dnf || true)
39if [[ -n $dnf ]]; then
40  deps=(
41    alsa-lib-devel
42    fontconfig-devel
43  )
44  $maysudo "$dnf" install -y "${deps[@]}"
45  exit 0
46fi
47
48# Arch, Manjaro, etc.
49# https://archlinux.org/packages
50pacman=$(command -v pacman || true)
51if [[ -n $pacman ]]; then
52  deps=(
53    alsa-lib
54    fontconfig
55  )
56  $maysudo "$pacman" -S --noconfirm "${deps[@]}"
57  exit 0
58fi
59
60echo "Unsupported Linux distribution in script/linux"