2016-10-22 05:10:25 +00:00
|
|
|
#!/bin/sh
|
2015-06-03 21:39:41 +00:00
|
|
|
|
2020-02-19 17:14:43 +00:00
|
|
|
#SCRIPT=$(readlink -f "$0")
|
|
|
|
#RC_PATH=$(dirname "$SCRIPT")
|
|
|
|
RC_PATH=$(cd "$(dirname "$0")"; pwd)
|
2016-10-22 05:10:25 +00:00
|
|
|
HOST=$(hostname)
|
2019-02-21 05:30:04 +00:00
|
|
|
XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
|
2019-06-01 18:34:05 +00:00
|
|
|
XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share}
|
2015-06-03 21:39:41 +00:00
|
|
|
|
2015-06-06 22:47:56 +00:00
|
|
|
# List of the config files to install
|
2019-11-19 13:22:31 +00:00
|
|
|
FILES="vimrc zshrc gitconfig vim gitignore_global git_user ctags.d mailcap"
|
2019-02-21 05:30:04 +00:00
|
|
|
CONF_DIR="config"
|
2019-06-01 18:34:05 +00:00
|
|
|
DATA_DIR="data"
|
2016-06-28 02:22:35 +00:00
|
|
|
|
2016-10-22 05:10:25 +00:00
|
|
|
if [ ! -e "$HOME/.git_user" ]; then
|
2019-02-21 05:30:04 +00:00
|
|
|
cp "$RC_PATH/git_user.def" "$RC_PATH/git_user"
|
|
|
|
sed -i -e "s/{username}/$USER/" "$RC_PATH/git_user"
|
|
|
|
sed -i -e "s/{email}/$USER@$HOST/" "$RC_PATH/git_user"
|
2016-06-28 02:22:35 +00:00
|
|
|
fi
|
2015-06-03 21:39:41 +00:00
|
|
|
|
2018-07-19 19:07:18 +00:00
|
|
|
# Init or update submodules
|
2019-06-01 18:34:05 +00:00
|
|
|
cd "$RC_PATH" || exit
|
2018-07-19 19:07:18 +00:00
|
|
|
git submodule update --init --recursive
|
2019-06-01 18:34:05 +00:00
|
|
|
cd - > /dev/null || exit
|
2018-07-19 19:07:18 +00:00
|
|
|
|
2015-06-06 22:47:56 +00:00
|
|
|
# Create symbolic links in the user's home dir
|
2015-06-03 21:45:41 +00:00
|
|
|
for file in $FILES
|
|
|
|
do
|
2016-10-22 05:10:25 +00:00
|
|
|
if [ ! -e "$HOME/.${file}" ]; then
|
2019-02-21 05:30:04 +00:00
|
|
|
ln -s "${RC_PATH}/${file}" "$HOME/.${file}"
|
|
|
|
# Only warn if an actual file exist, else we suppose it is from a previous install
|
|
|
|
elif [ ! -L "$HOME/.$file" ]; then
|
|
|
|
>&2 echo "File $HOME/.$file exists. Keeping old version."
|
2015-12-12 21:46:20 +00:00
|
|
|
fi
|
2015-06-03 21:39:41 +00:00
|
|
|
done
|
2019-02-21 05:30:04 +00:00
|
|
|
|
2019-06-01 18:34:05 +00:00
|
|
|
mkdir -p "$XDG_CONFIG_HOME"
|
|
|
|
mkdir -p "$XDG_DATA_HOME"
|
|
|
|
# https://github.com/koalaman/shellcheck/wiki/SC2156
|
|
|
|
find "$RC_PATH/$CONF_DIR" -mindepth 1 -maxdepth 1 -type d \
|
2020-07-27 16:46:29 +00:00
|
|
|
-exec sh -c 'ln -s "$2" "$1" 2> /dev/null || ( link="$1/$(basename "$2")"; test -L "$link" || >&2 echo "Folder $link exists. Keeping old version.")' _ "$XDG_CONFIG_HOME" '{}' \;
|
2019-06-01 18:34:05 +00:00
|
|
|
find "$RC_PATH/$DATA_DIR" -mindepth 1 -maxdepth 1 -type d \
|
2020-07-27 16:46:29 +00:00
|
|
|
-exec sh -c 'ln -s "$2" "$1" 2> /dev/null || ( link="$1/$(basename "$2")"; test -L "$link" || >&2 echo "Folder $link exists. Keeping old version.")' _ "$XDG_DATA_HOME" '{}' \;
|