-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·56 lines (48 loc) · 1.91 KB
/
install.sh
File metadata and controls
executable file
·56 lines (48 loc) · 1.91 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
#!/usr/bin/env bash
#
# install.sh -- set up dotfiles
#
# Wires dotfiles into your shell and git config. No symlinks -- just
# appends/includes into existing system files. Idempotent.
set -euo pipefail
DOTFILES_DIR="$(cd "$(dirname "$0")" && pwd)"
info() { printf "\033[0;34m[info]\033[0m %s\n" "$1"; }
success() { printf "\033[0;32m[ok]\033[0m %s\n" "$1"; }
# --- Git config (include, not symlink) ---
# We add an [include] to ~/.gitconfig rather than replacing it.
# This lets gh and other tools write to ~/.gitconfig without polluting the repo.
if git config --global --get-all include.path | grep -qF "$DOTFILES_DIR/gitconfig"; then
success "~/.gitconfig already includes dotfiles"
else
git config --global --add include.path "$DOTFILES_DIR/gitconfig"
success "added include to ~/.gitconfig -> $DOTFILES_DIR/gitconfig"
fi
# --- Global gitignore ---
if [[ "$(git config --global core.excludesfile)" == "$DOTFILES_DIR/gitignore" ]]; then
success "core.excludesfile already set"
else
git config --global core.excludesfile "$DOTFILES_DIR/gitignore"
success "set core.excludesfile -> $DOTFILES_DIR/gitignore"
fi
# --- Tmux config ---
SOURCE_CMD="source-file $DOTFILES_DIR/tmux.conf"
if grep -qF "$DOTFILES_DIR/tmux.conf" "$HOME/.tmux.conf" 2>/dev/null; then
success "~/.tmux.conf already sources dotfiles"
else
printf '# dotfiles\n%s\n' "$SOURCE_CMD" >> "$HOME/.tmux.conf"
success "added source-file to ~/.tmux.conf"
fi
# --- Bashrc source line ---
SOURCE_LINE="[[ -f $DOTFILES_DIR/bashrc ]] && source $DOTFILES_DIR/bashrc"
if grep -qF "$DOTFILES_DIR/bashrc" "$HOME/.bashrc" 2>/dev/null; then
success "~/.bashrc already sources dotfiles"
else
printf '\n# dotfiles\n%s\n' "$SOURCE_LINE" >> "$HOME/.bashrc"
success "appended source line to ~/.bashrc"
fi
# --- Agent config ---
"$DOTFILES_DIR/agents/install.sh"
if [[ -z "${DOTFILES_QUIET:-}" ]]; then
echo ""
info "Done! Restart your shell or run: source ~/.bashrc"
fi