-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·61 lines (51 loc) · 1.8 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·61 lines (51 loc) · 1.8 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
#!/usr/bin/env bash
set -euo pipefail
repo_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
nvim_target="${HOME}/.config/nvim"
tmux_target="${HOME}/.tmux.conf"
tpm_target="${HOME}/.tmux/plugins/tpm"
link_path() {
local source_path="$1"
local target_path="$2"
if [ -L "$target_path" ]; then
local current_target
current_target="$(readlink "$target_path")"
if [ "$current_target" = "$source_path" ]; then
printf '%s\n' "Already linked: $target_path"
return
fi
printf '%s\n' "Refusing to replace existing symlink: $target_path -> $current_target" >&2
return 1
fi
if [ -e "$target_path" ]; then
printf '%s\n' "Refusing to overwrite existing path: $target_path" >&2
printf '%s\n' "Move it away or back it up, then rerun setup.sh." >&2
return 1
fi
mkdir -p "$(dirname "$target_path")"
ln -s "$source_path" "$target_path"
printf '%s\n' "Linked: $target_path -> $source_path"
}
link_path "$repo_dir" "$nvim_target"
link_path "$repo_dir/.tmux.conf" "$tmux_target"
if [ ! -d "$tpm_target" ]; then
if command -v git >/dev/null 2>&1; then
mkdir -p "$(dirname "$tpm_target")"
git clone https://github.com/tmux-plugins/tpm "$tpm_target"
printf '%s\n' "Installed TPM: $tpm_target"
else
printf '%s\n' "git not found; skipping TPM install." >&2
fi
else
printf '%s\n' "Already installed: $tpm_target"
fi
if command -v nvim >/dev/null 2>&1; then
nvim --headless "+Lazy! sync" +qa
else
printf '%s\n' "nvim not found; install Neovim, then run: nvim" >&2
fi
if command -v tmux >/dev/null 2>&1; then
printf '%s\n' "tmux found. Start tmux and press prefix + I to install plugins."
else
printf '%s\n' "tmux not found; install tmux before using .tmux.conf." >&2
fi