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  )
25  $maysudo "$apt" install -y "${deps[@]}"
26  exit 0
27fi
28
29# Fedora, CentOS, RHEL, etc.
30# https://packages.fedoraproject.org/
31dnf=$(command -v dnf || true)
32if [[ -n $dnf ]]; then
33  deps=(
34    alsa-lib-devel
35    fontconfig-devel
36  )
37  $maysudo "$dnf" install -y "${deps[@]}"
38  exit 0
39fi
40
41# Arch, Manjaro, etc.
42# https://archlinux.org/packages
43pacman=$(command -v pacman || true)
44if [[ -n $pacman ]]; then
45  deps=(
46    alsa-lib
47    fontconfig
48  )
49  $maysudo "$pacman" -S --noconfirm "${deps[@]}"
50  exit 0
51fi
52
53echo "Unsupported Linux distribution in script/linux"