-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·83 lines (69 loc) · 2.68 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·83 lines (69 loc) · 2.68 KB
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
80
81
82
83
#!/bin/sh
# m8a Default Dotfiles Installer
set -e
echo ">> Starting m8a default dotfiles setup..."
# Ensure ~/.config exists
mkdir -p "$HOME/.config"
# --- 1. Dependencies ---
# Check for apt-get (Debian/Ubuntu)
if [ -x "$(command -v apt-get)" ]; then
PACKAGES=""
if ! [ -x "$(command -v zsh)" ]; then
PACKAGES="$PACKAGES zsh"
fi
if ! [ -x "$(command -v curl)" ]; then
PACKAGES="$PACKAGES curl"
fi
if ! [ -x "$(command -v git)" ]; then
PACKAGES="$PACKAGES git"
fi
if [ -n "$PACKAGES" ]; then
echo ">> Installing missing packages: $PACKAGES"
sudo apt-get update && sudo apt-get install -y $PACKAGES
fi
else
echo ">> Warning: apt-get not found. Assuming dependencies (zsh, curl, git) are available."
fi
# --- 2. Oh My Zsh ---
if [ ! -d "$HOME/.oh-my-zsh" ]; then
echo ">> Installing Oh My Zsh..."
# Unattended install
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
else
echo ">> Oh My Zsh is already installed."
fi
# --- 3. Spaceship Theme ---
ZSH_CUSTOM="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}"
if [ ! -d "$ZSH_CUSTOM/themes/spaceship-prompt" ]; then
echo ">> Installing Spaceship theme..."
git clone https://github.com/spaceship-prompt/spaceship-prompt.git "$ZSH_CUSTOM/themes/spaceship-prompt" --depth=1
ln -sf "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme"
else
echo ">> Spaceship theme is already installed."
fi
# --- 4. Configuration Linking ---
echo ">> Linking configurations..."
# Get the directory where this script is located
REPO_ROOT="$(cd "$(dirname "$0")" && pwd)"
# Backup existing config if it's a file and not a symlink to our target
backup_if_exists() {
target=$1
if [ -e "$target" ] && [ ! -L "$target" ]; then
echo ">> Backing up existing $target to $target.bak"
mv "$target" "$target.bak"
fi
}
backup_if_exists "$HOME/.zshrc"
ln -sf "$REPO_ROOT/.zshrc" "$HOME/.zshrc"
# --- 5. Set Default Shell ---
CURRENT_SHELL=$(basename "$SHELL")
if [ "$CURRENT_SHELL" != "zsh" ]; then
echo ">> Changing default shell to zsh..."
# Attempt chsh if we have sudo or passwordless capability, might fail in some containers without sudo
if [ -x "$(command -v sudo)" ]; then
sudo chsh -s "$(which zsh)" "$USER" || echo ">> Warning: Failed to change shell. You may need to run 'chsh -s $(which zsh)' manually."
else
chsh -s "$(which zsh)" || echo ">> Warning: Failed to change shell. You may need to run 'chsh -s $(which zsh)' manually."
fi
fi
echo ">> m8a dotfiles setup complete! Restart your terminal or run 'zsh' to see changes."