-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·104 lines (87 loc) · 2.28 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·104 lines (87 loc) · 2.28 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
#!/usr/bin/env bash
# Dotfiles installer
# Usage: ./install.sh [--dry-run] [--force] [--quiet] [install|update]
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
source "$SCRIPT_DIR/scripts/lib.sh"
source "$SCRIPT_DIR/scripts/post-update.sh"
usage() {
cat <<EOF
Usage: ./install.sh [options] [command]
Commands:
install Install dotfiles (default)
update Update submodules and run post-update tasks
Options:
--dry-run Show what would be done without making changes
--force Overwrite existing files (backs up originals)
--quiet Suppress informational output
-h, --help Show this help message
EOF
}
init_submodules() {
header "Initializing submodules"
run git -C "$DOTFILES_ROOT" submodule update --init
log "Submodules initialized"
}
update_submodules() {
header "Updating submodules"
run git -C "$DOTFILES_ROOT" submodule update --remote --merge
log "Submodules updated"
}
install_links() {
header "Linking dotfiles"
link_tree "$DOTFILES_HOME"
log "Dotfiles linked"
}
install_copies() {
header "Installing copied files"
copy_if_missing "$DOTFILES_COPY/vimrc.local" "$HOME/.vimrc.local"
copy_if_missing "$DOTFILES_COPY/vimplug.local" "$HOME/.vimplug.local"
log "Copied files installed"
}
create_vim_dirs() {
header "Creating Vim directories"
local vim_tmp="$HOME/.vim/tmp"
for dir in backup swap undo; do
local target="$vim_tmp/$dir"
if [[ ! -d "$target" ]]; then
info "Creating $target"
run mkdir -p "$target"
fi
done
log "Vim directories ready"
}
cmd_install() {
header "Dotfiles install"
init_submodules
install_links
prune_dead_links
install_copies
create_vim_dirs
run_post_update
if [[ "$SKIP_COUNT" -gt 0 ]]; then
warn "$SKIP_COUNT file(s) skipped (rerun with --force to override)"
header "Install incomplete"
exit 1
fi
header "Install complete!"
}
cmd_update() {
header "Dotfiles update"
update_submodules
run_post_update
header "Update complete!"
}
main() {
parse_global_flags "$@"
set -- "${PARSED_ARGS[@]+"${PARSED_ARGS[@]}"}"
local command="${1:-install}"
case "$command" in
install) cmd_install ;;
update) cmd_update ;;
-h|--help|help) usage ;;
*)
die "Unknown command: $command (try: install, update)"
;;
esac
}
main "$@"