Created
August 24, 2017 10:59
-
-
Save vifo/0730780025e420943a707dd64e503531 to your computer and use it in GitHub Desktop.
Boot dotfiles.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
NAME="$(readlink -f "$0")" | |
echo $NAME | |
cleanup() { | |
true | |
} | |
dotfile() { | |
[ "$#" -lt 2 ] && { | |
echo "$NAME: Usage: dotfile NAME URL" >&2 | |
exit 1 | |
} | |
local dotfile="$1" | |
local dotfile_path="$HOME/.${dotfile}" | |
local url="$2" | |
shift 2 | |
# fetch dotfile from given url | |
local tmp_dotfile_path="$(mktemp)" | |
echo "Dotfile: name=\"$dotfile\", dotfile_path=\"$dotfile_path\"" | |
wget -O "$tmp_dotfilepath" "$url" | |
if [ "$?" -eq 0 ]; then | |
diff -Naur "$dotfile_path" "$tmp_dotfile_path" | |
if [ "$?" -eq 0 ]; then | |
echo "diff returned 0" | |
fi | |
else | |
echo "wget failed" | |
fi | |
} | |
# Add dotfiles to be booted below | |
dotfile "zshrc" "https://git.grml.org/f/grml-etc-core/etc/zsh/zshrc" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment