-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·88 lines (73 loc) · 1.3 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·88 lines (73 loc) · 1.3 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
#!/bin/sh
# This script creates symlinks from `$HOME` to this repository
# It is idempotent; existing real files are kept with a warning.
set -eu
dotfiles=$(cd "$(dirname "$0")" && pwd)
# creating symlinks
items='
.bash_aliases
.bash_profile
.bashrc
.zshenv
.editorconfig
bin
.config/zsh
.config/tmux
.config/vim
.config/dircolors
.config/npm
.config/git
.config/karabiner
.config/nvim
.config/mise
.config/gh/config.yml
.claude/CLAUDE.md
'
# symlinks that pointed into this repository before files were moved
stale='
.zprofile
.zshrc
.dir_colors
.tmux.conf
.vim
.vimrc
.gvimrc
.npmrc
'
link() {
rel=$1
src="$dotfiles/$rel"
dst="$HOME/$rel"
mkdir -p "$(dirname "$dst")"
if [ -L "$dst" ]; then
if [ "$(readlink "$dst")" = "$src" ]; then
return
fi
rm -f "$dst"
elif [ -e "$dst" ]; then
echo "warn: $dst already exists, skipped" >&2
return
fi
ln -s "$src" "$dst"
echo "link: $dst -> $src"
}
unlink_stale() {
rel=$1
dst="$HOME/$rel"
if [ ! -L "$dst" ]; then
return
fi
case "$(readlink "$dst")" in
"$dotfiles"/*)
rm -f "$dst"
echo "unlink: $dst"
;;
esac
}
for rel in $stale; do
unlink_stale "$rel"
done
for rel in $items; do
link "$rel"
done
echo "done"