forked from xxh/xxh-plugin-prerun-dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
100-prerun.sh
36 lines (33 loc) · 1.17 KB
/
100-prerun.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
if [[ $XDG_CACHE_HOME ]]; then
done_file=$XDG_CACHE_HOME/xxh-plugin-prerun-dotfiles-conf-done
else
done_file=$XXH_HOME/.xxh-plugin-prerun-dotfiles-conf-done
fi
if [[ ! -f $done_file ]]; then
CURR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd $CURR_DIR/home
for item in $(shopt -s dotglob && cd $CURR_DIR/home && find *); do
item_basedir=`echo $item | cut -d "/" -f1`
target_item=$XXH_HOME/$item
target_dir=`dirname $target_item`
if [[ $item_basedir == '.config' && $XDG_CONFIG_HOME ]]; then
target_dir=`dirname $XDG_CONFIG_HOME`
target_item=$target_dir/$item
fi
if [[ -f $item && ! -f $target_item ]]; then
if [[ $XXH_VERBOSE == '1' || $XXH_VERBOSE == '2' ]]; then
echo "xxh-plugin-prerun-dotfiles-conf: Create file $target_item"
fi
mkdir -p $target_dir
cp -R $item $target_item
elif [[ -d $item && ! -d $target_item ]]; then
if [[ $XXH_VERBOSE == '1' || $XXH_VERBOSE == '2' ]]; then
echo "xxh-plugin-prerun-dotfiles-conf: Create dir $target_item"
fi
mkdir -p $target_item
fi
done
mkdir -p `dirname $done_file`
echo 'done' > $done_file
fi
cd $XXH_HOME