-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·79 lines (70 loc) · 2.11 KB
/
install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
set -eu
set -o pipefail
# Detect the OS
if [ $(uname -s) == "Linux" ]; then
DISTRO="$(cat /etc/os-release | grep -E '^ID=' | cut -d '=' -f 2)"
case "$DISTRO" in
"arch" | "manjaro")
OS="arch"
PACKAGE_MANAGER="pacman"
;;
"ubuntu" | "debian")
OS="debian"
PACKAGE_MANAGER="apt"
;;
*)
echo "Unsupported linux distro: $distro. Packages won't be installed automatically."
;;
esac
else
echo "Unsupported OS: $(uname -s). Packages won't be installed automatically."
fi
if [ -n "${OS+x}" ]; then
echo "Detected OS: $OS"
echo "Package manager: $PACKAGE_MANAGER"
fi
# Ensure ~/.config exists
CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}"
if [ ! -d "$CONFIG" ]; then
echo "Creating $CONFIG..."
mkdir -p "$CONFIG"
fi
# Install required packages if a package manager was detected
if [ -n "${PACKAGE_MANAGER+x}" ]; then
echo "Installing required packages. If prompted by sudo, please enter your password."
case "$PACKAGE_MANAGER" in
"pacman")
sudo pacman -Sy --noconfirm --needed fish git git-crypt stow tmux direnv zoxide
;;
"apt")
sudo apt-get update
sudo apt-get install -y fish git git-crypt stow tmux direnv zoxide
;;
*)
echo "Unsupported package manager: $PACKAGE_MANAGER. Packages won't be installed automatically."
;;
esac
fi
# Install dotfiles
echo "Installing dotfiles..."
stow -v 2 .
# Set fish as the default shell
echo "Setting fish as the default shell..."
sudo chsh -s "$(which fish)" "$USER"
# Install mise
# https://mise.jdx.dev/installing-mise.html#https-mise-run
curl https://mise.run | sh
fish_add_path "$HOME/.local/bin"
# Install TPM and tmux plugins
TMUX_DIR="$CONFIG/tmux"
TPM_DIR="$TMUX_DIR/plugins/tpm"
if [ ! -d "$TPM_DIR" ]; then
echo "Installing TPM..."
mkdir -p "$TMUX_DIR/plugins"
git clone https://github.com/tmux-plugins/tpm "$TPM_DIR"
else
echo "TPM already installed."
fi
echo "Installing TPM plugins..."
"$TPM_DIR/bin/install_plugins"