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
|
#!/bin/bash
CURRENT=
if [ -d ~/.stdhome.orig -a ! -d ~/.stdhome.dev ]; then
CURRENT=on
elif [ ! -d ~/.stdhome.orig -a -d ~/.stdhome.dev ]; then
CURRENT=off
fi
if [ -z "$CURRENT" ]; then
echo "Can't determine current state" >&2
exit 1
fi
TARGET=
if [ "$1" == "on" ]; then
TARGET=on
elif [ "$1" == "off" ]; then
TARGET=off
fi
if [ "$TARGET" == "on" ]; then
if [ "$CURRENT" == "on" ]; then
echo already on >& 2
exit 0
fi
echo turning on
mv ~/.stdhome{,.orig}
mv ~/.stdhome{.dev,}
sed -ie 's/^#\(home-dir\)/\1/' ~/.stdhomerc
elif [ "$TARGET" == "off" ]; then
if [ "$CURRENT" == "off" ]; then
echo already off >& 2
exit 0
fi
echo turning off
mv ~/.stdhome{,.dev}
mv ~/.stdhome{.orig,}
sed -ie 's/^home-dir/#\0/' ~/.stdhomerc
else
echo currently $CURRENT
fi
|