Skip to content

Commit b0578ce

Browse files
committed
Restart dotfiles script if necessary.
1 parent 2850e9b commit b0578ce

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

bin/dotfiles

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
[[ "$1" ]] || \
2+
[[ "$1" == "source" ]] || \
33

44
echo 'Dotfiles - "Cowboy" Ben Alman - http://benalman.com/'
55

@@ -133,7 +133,7 @@ function to_install() {
133133
}
134134

135135
# If this file was being sourced, exit now.
136-
[[ "$1" ]] && return
136+
[[ "$1" == "source" ]] && return
137137

138138

139139
###########################################
@@ -267,12 +267,14 @@ if [[ ! -d $DOTFILES ]]; then
267267
e_header "Downloading dotfiles"
268268
git clone --recursive git://github.com/${github_user:-cowboy}/dotfiles.git $DOTFILES
269269
cd $DOTFILES
270-
else
270+
elif [[ "$1" != "restart" ]]; then
271271
# Make sure we have the latest files.
272272
e_header "Updating dotfiles"
273+
prev_head="$(git rev-parse HEAD)"
273274
cd $DOTFILES
274275
git pull
275276
git submodule update --init --recursive --quiet
277+
[[ "$(git rev-parse HEAD)" != "$prev_head" ]] && exec "$0" "restart"
276278
fi
277279

278280
# Add binaries into the path

source/00_dotfiles.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# Passing an arg into dotfiles tells it to only define functions, then quit.
2-
source ~/.dotfiles/bin/dotfiles 1
1+
# Passing the "source" arg tells it to only define functions, then quit.
2+
source ~/.dotfiles/bin/dotfiles "source"

0 commit comments

Comments
 (0)