-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy
More file actions
executable file
·75 lines (60 loc) · 1.53 KB
/
deploy
File metadata and controls
executable file
·75 lines (60 loc) · 1.53 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
#!/bin/sh
TMPFILE=$(mktemp /tmp/dotfiles.XXXXXX)
IGNORE=$PWD/deploy.ignore
ME=$0
R=`tput setaf 1`
G=`tput setaf 2`
B=`tput setaf 6`
N=`tput sgr0`
b=`tput bold`
OK="[${G} OK ${N}]"
NOPE="[${R}FAIL${N}]"
ignore() {
while read line; do
sed -i "/$line/d" $TMPFILE
done < $IGNORE
}
listfiles() {
cat <<EOF > $TMPFILE
# This is an auto-generated file for linking config files to your
# $HOME directory
#
# This script will read filenames from this file in order to create
# ONLY the links you want. Lines starting with '#' will be ignored.
#
# The following list lists every. single. file or directory. Just
# remove the line that you don't want to be linked. Then, save that
# file, and watch the magic happen...
EOF
echo "listing the whole directory"
ls $PWD >> $TMPFILE
# Remove this script from the file list
sed -i "/`basename $0`/d" $TMPFILE
# Remove ignore list from the file list
sed -i "/`basename $IGNORE`/d" $TMPFILE
# Remove files in the ignore list from the file list
ignore
}
config() {
# Edit the temporary file
test -z "$EDITOR" && vi $TMPFILE || $EDITOR $TMPFILE
}
simulate() {
# Print what's going to happen
echo "the following files will be linked:"
for f in `grep -v '^#' $TMPFILE`; do
echo "~/.$f -> ${B}${PWD}/$f${N}"
done
}
link() {
read -p "hit ^C to abort..."
for f in `grep -v '^#' $TMPFILE`; do
echo -n "${f} ... "
ln -sfn $PWD/$f ~/.$f 2>/dev/null && echo $OK || echo $NOPE
done
}
listfiles
config
simulate
link
exit $?