diff --git a/scripts/.update_dotfiles.sh b/scripts/.update_dotfiles.sh new file mode 100755 index 0000000..4999f8b --- /dev/null +++ b/scripts/.update_dotfiles.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env sh +echo 'Updating dotfiles' +cd /home/sothr/dotfiles +git checkout master +git pull +git submodule update diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 2e4bd8e..0de425c 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -36,11 +36,37 @@ link_dir() { set -x set -e -# Step out of the script directory and into the main dotfiles directory -cd .. +# Need to get the source for the script +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + TARGET="$(readlink "$SOURCE")" + if [[ $TARGET == /* ]]; then + echo "SOURCE '$SOURCE' is an absolute symlink to '$TARGET'" + SOURCE="$TARGET" + else + DIR="$( dirname "$SOURCE" )" + echo "SOURCE '$SOURCE' is a relative symlink to '$TARGET' (relative to '$DIR')" + SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located + fi +done +echo "SOURCE is '$SOURCE'" +RDIR="$( dirname "$SOURCE" )" +DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +if [ "$DIR" != "$RDIR" ]; then + echo "DIR '$RDIR' resolves to '$DIR'" +fi +echo "DIR is '$DIR'" + +# Step into the directory where thes script is +cd $DIR # Store the path to the root directory and the reference home directory -DOTFILES_DIR="$PWD" +GIT_DIR="$(echo `git rev-parse --show-toplevel`)" + +cd $GIT_DIR + +# Home directory in the git directory +DOTFILES_DIR="$GIT_DIR" DOTFILES_HOME="$DOTFILES_DIR/home" # Configure .vimrc