-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
Β·165 lines (133 loc) Β· 4.96 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
Β·165 lines (133 loc) Β· 4.96 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/bash
# ==============================================================================
# π Dotfiles Installation Script (Homebrew Edition)
# Installs configuration for Nushell, Starship, WezTerm, etc. using Homebrew
# ==============================================================================
set -e
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
RED='\033[0;31m'
NC='\033[0m'
echo -e "${CYAN}π§ Starting Dotfiles Installation (Homebrew)...${NC}\n"
# Paths
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
CONFIG_DIR="$HOME/.config"
DOTFILES_LINK="$HOME/dotfiles"
# ------------------------------------------------------------------------------
# Helper Functions
# ------------------------------------------------------------------------------
backup_if_exists() {
local target="$1"
if [ -e "$target" ] || [ -L "$target" ]; then
local backup_name="${target}.bak.$(date +%Y%m%d%H%M%S)"
echo -e "${YELLOW}β οΈ Backing up existing $target -> $backup_name${NC}"
mv "$target" "$backup_name"
fi
}
create_symlink() {
local source="$1"
local target="$2"
mkdir -p "$(dirname "$target")"
backup_if_exists "$target"
echo -e "${CYAN}π Linking $target -> $source${NC}"
ln -s "$source" "$target"
}
check_cmd() {
command -v "$1" &> /dev/null
}
# ------------------------------------------------------------------------------
# 1. Install Homebrew
# ------------------------------------------------------------------------------
if ! check_cmd brew; then
echo -e "${YELLOW}πΊ Homebrew not found. Installing...${NC}"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Eval brew shellenv for Linux
if [ -d "/home/linuxbrew/.linuxbrew" ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
elif [ -d "/opt/homebrew" ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
else
echo -e "${GREEN}β
Homebrew is already installed${NC}"
fi
# ------------------------------------------------------------------------------
# 2. Install Packages via Homebrew
# ------------------------------------------------------------------------------
TOOLS=(
"nushell"
"starship"
"zoxide"
"atuin"
"bat"
"lsd"
"git-delta"
"bottom"
"fzf"
"yazi"
"neovim"
"font-caskaydia-cove-nerd-font"
)
echo -e "\n${CYAN}π¦ Installing dependencies with Homebrew...${NC}"
# Update brew first
echo -e "Running brew update..."
brew update
for tool in "${TOOLS[@]}"; do
if brew list "$tool" &>/dev/null; then
echo -e "${GREEN}β
$tool already installed${NC}"
else
echo -e "${YELLOW}π₯ Installing $tool...${NC}"
# Nerd font might need cask on macOS, generic install usually works or taps
if [[ "$tool" == "font-caskaydia-cove-nerd-font" ]]; then
brew list --cask "$tool" &>/dev/null || brew install --cask "$tool" || echo -e "${RED}β οΈ Font install skipped (Linux/No Cask support potentially)${NC}"
else
brew install "$tool"
fi
fi
done
# ------------------------------------------------------------------------------
# 3. Link Dotfiles
# ------------------------------------------------------------------------------
# Ensure ~/dotfiles link
if [ ! -d "$DOTFILES_LINK" ] && [ ! -L "$DOTFILES_LINK" ]; then
echo -e "\n${CYAN}π Creating ~/dotfiles symlink...${NC}"
ln -s "$SCRIPT_DIR" "$DOTFILES_LINK"
else
echo -e "\n${GREEN}β
~/dotfiles correct${NC}"
fi
echo -e "\n${CYAN}π Linking config files...${NC}"
# Nushell
create_symlink "$SCRIPT_DIR/config/nushell" "$CONFIG_DIR/nushell"
# WezTerm
create_symlink "$SCRIPT_DIR/config/wezterm" "$CONFIG_DIR/wezterm"
# Starship
create_symlink "$SCRIPT_DIR/config/starship.toml" "$CONFIG_DIR/starship.toml"
# Neovim
create_symlink "$SCRIPT_DIR/config/nvim" "$CONFIG_DIR/nvim"
# Yazi
create_symlink "$SCRIPT_DIR/config/yazi" "$CONFIG_DIR/yazi"
# Zsh
create_symlink "$SCRIPT_DIR/config/zsh/.zshrc" "$HOME/.zshrc"
# ------------------------------------------------------------------------------
# 4. Final Setup (Nushell Caches)
# ------------------------------------------------------------------------------
echo -e "\n${CYAN}βοΈ Generating Nu cache files...${NC}"
mkdir -p "$HOME/.cache"
# Generate init files using the newly installed binaries
echo -e "Generating .zoxide.nu..."
if command -v zoxide &> /dev/null; then
zoxide init nushell > "$HOME/.cache/.zoxide.nu"
else
echo -e "${YELLOW}β οΈ Zoxide not found (checking path?). Creating empty config.${NC}"
touch "$HOME/.cache/.zoxide.nu"
fi
echo -e "Generating .atuin.nu..."
if command -v atuin &> /dev/null; then
atuin init nu > "$HOME/.cache/.atuin.nu"
else
echo -e "${YELLOW}β οΈ Atuin not found. Creating empty config.${NC}"
touch "$HOME/.cache/.atuin.nu"
fi
echo -e "\n${GREEN}π Installation Complete!${NC}"
echo -e "You are ready to rock with Nushell + Starship + Homebrew tools."