-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·67 lines (54 loc) · 2.28 KB
/
install.sh
File metadata and controls
executable file
·67 lines (54 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
#!/usr/bin/env bash
set -euo pipefail
###############################################################################
# Sync local nvim/ tree -> ~/.config/nvim/, preserving structure and #
# replacing/creating symlinks for every file. #
###############################################################################
# Directory that contains this script (your local nvim/ root)
src_root="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/nvim"
dst_root="$HOME/.config/nvim"
# This script
installer="$(basename "$0")"
echo "Installing Neovim config:"
echo " Source : $src_root"
echo " Target : $dst_root"
echo
# Make sure the destination root exists
mkdir -p "$dst_root"
# Extensions to skip (NO leading dot). Example: "DS_Store", "swp", "tmp"
IGNORE_EXT=( "DS_Store" )
###############################################################################
# Helper: return 0 (true) if the file should be ignored #
###############################################################################
should_ignore () {
local path="$1"
local base="${path##*/}"
local ext="${base##*.}"
# No dot in the name -> ext == whole filename, that’s fine
for ign in "${IGNORE_EXT[@]}"; do
[[ "$ext" == "$ign" ]] && return 0
done
return 1
}
###############################################################################
# 1. Re-create the directory tree #
###############################################################################
find "$src_root" -mindepth 1 -type d -print0 |
while IFS= read -r -d '' dir; do
rel="${dir#$src_root/}" # path relative to src_root
mkdir -p "$dst_root/$rel"
done
###############################################################################
# 2. Symlink every file (skip this installer) #
###############################################################################
find "$src_root" -type f -print0 |
while IFS= read -r -d '' file; do
# Skip this installer and any ignored extension
[[ "$(basename "$file")" == "$installer" ]] && continue
should_ignore "$file" && continue
rel="${file#$src_root/}"
echo "Installing $dst_root/$rel"
ln -sf "$file" "$dst_root/$rel"
done
echo
echo "Done."