forked from rse/claude-code-setup
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup
More file actions
executable file
·78 lines (70 loc) · 2.01 KB
/
Copy pathsetup
File metadata and controls
executable file
·78 lines (70 loc) · 2.01 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
#!/usr/bin/env bash
##
## claude-code-setup - Claude Code Setup Toolkit
## Copyright (c) 2025 Dr. Ralf S. Engelschall <[email protected]>
## Licensed under MIT <https://spdx.org/licenses/MIT>
##
# sanity check usage
if [[ $1 != "import" && $1 != "install" && $1 != "uninstall" ]]; then
echo "USAGE: setup import|install|uninstall [<prefix>]" 1>&2
exit 1
fi
# determine installation prefix
prefix="${2-$HOME}"
# determine base directory
basedir=""
case "$0" in
/* )
# absolute path
basedir=$(dirname "$0")
;;
*/* )
# relative path
basedir=$(dirname "$0")
basedir=$(cd "$basedir" && pwd)
;;
* )
# no path
OIFS="$IFS"; IFS=":"
for p in $PATH; do
IFS="$OIFS"
echo "$p"
done
IFS="$OIFS"
;;
esac
# helper functionf for running a shell command
run () {
echo "\$ $@"
eval "$@"
}
# dispatch according to command
case $1 in
# import all files (development only)
import )
for dir in $(grep -E "^DIR" $basedir/MANIFEST.txt | sed -e 's;^DIR *;;'); do
run "mkdir -p $basedir/$dir"
done
for file in $(grep -E "^FILE" $basedir/MANIFEST.txt | sed -e 's;^FILE *;;'); do
run "cp -p $prefix/$file $basedir/$file"
done
;;
# install all files (production)
install )
for dir in $(grep -E "^DIR" $basedir/MANIFEST.txt | sed -e 's;^DIR *;;'); do
run "mkdir -p $prefix/$dir"
done
for file in $(grep -E "^FILE" $basedir/MANIFEST.txt | sed -e 's;^FILE *;;'); do
run "cp -p $basedir/$file $prefix/$file"
done
;;
# uninstall all files (production)
uninstall )
for file in $(grep -E "^FILE" $basedir/MANIFEST.txt | sed -e 's;^FILE *;;'); do
run "rm -f $prefix/$file"
done
for dir in $(grep -E "^DIR" $basedir/MANIFEST.txt | sed -e 's;^DIR *;;'); do
run "rmdir $prefix/$dir"
done
;;
esac