-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstow.sh
executable file
·37 lines (32 loc) · 938 Bytes
/
stow.sh
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
#!/usr/bin/env bash
source sh/xdg.sh
if [[ "$#" -ge "1" ]]; then
case $1 in
-R|-D|-S)
STOW_ACTION=$1
;;
*)
TARGETS="$TARGETS $1"
;;
esac
shift
fi
STOW_ACTION=${STOW_ACTION:-"-R"}
TARGETS=${TARGETS:-"bash git sh tmux vim zsh"}
for TARGET in $TARGETS; do
if [[ -e $TARGET/link.sh ]]; then
# allow dotfile bundles to override the linker
$TARGET/link.sh
else
# default install: symlink into XDG_CONFIG_HOME
DEST=${XDG_CONFIG_HOME:-$HOME/.config}/$TARGET
[[ -d $DEST ]] || mkdir -p $DEST
# stow our application
stow $STOW_ACTION $TARGET -t $DEST \
--ignore="configure.sh" --ignore="link.sh" --ignore "README.md"
fi
# run a prepare script, if any, on stows/restows
if [[ -e $TARGET/configure.sh ]] && ! [[ $STOW_ACTION = -D ]]; then
$TARGET/configure.sh
fi
done