-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo
executable file
·54 lines (44 loc) · 1.14 KB
/
demo
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
#!/bin/sh
set -e
export DOTFILES_HOME="$(realpath "$(dirname "$0")")"
export DOTFILES_ENV='demo'
TMP_HOME="$DOTFILES_HOME/custom/tmp/demo_home"
DEMO_DOTFILES_ENV_FILE="$DOTFILES_HOME/custom/env/demo/dotfiles.env"
clean () {
rm -vrf "$TMP_HOME"
}
install () {
mkdir -pv "$TMP_HOME"
cd "$TMP_HOME"
[ -f "$DEMO_DOTFILES_ENV_FILE" ] && rm -f "$DEMO_DOTFILES_ENV_FILE"
"$DOTFILES_HOME/install" -f -e "$DOTFILES_ENV" --user-home "$TMP_HOME" --dotfiles-path "$DOTFILES_HOME"
}
start () {
(
export DOTFILES_ENV="$DOTFILES_ENV"
export DOTFILES_ENV_HOME="$TMP_HOME"
export DOTFILES_ENV_USER="$USER"
export DOTFILES_HOME="$DOTFILES_HOME"
export HOME="$TMP_HOME"
exec "$SHELL"
)
}
if [ -e "$TMP_HOME" ]; then
printf "Another temp home exitsts. Clean (y/[n])? "
read -r response
if [ "$response" = 'y' ]; then
clean
install
else
printf "Reinstall to $TMP_HOME (y/[n])? "
read -r response
if [ "$response" = 'y' ]; then
install
fi
fi
else
install
fi
set +e
echo "You can try my dotfiles in this shell."
start