-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstaller.sh
executable file
·27 lines (22 loc) · 1015 Bytes
/
installer.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
#!/bin/sh -e
#
# First time installation for new systems
# Default settings
export DOTFILES="${DOTFILES:-$HOME/.dotfiles}"
export ZSH="${ZSH:-$DOTFILES/zsh}"
# $USER is defined by login(1) which is not always executed (e.g. containers)
# POSIX: https://pubs.opengroup.org/onlinepubs/009695299/utilities/id.html
USER=${USER:-$(id -u -n)}
# $HOME is defined at the time of login, but it could be unset. If it is unset,
# a tilde by itself (~) will not be expanded to the current user's home directory.
# POSIX: https://pubs.opengroup.org/onlinepubs/009696899/basedefs/xbd_chap08.html#tag_08_03
HOME="${HOME:-$(getent passwd "$USER" 2>/dev/null | cut -d: -f6)}"
# macOS does not have getent, but this works even if $HOME is unset
HOME="${HOME:-$(eval echo ~"$USER")}"
REMOTE=${REMOTE:-"[email protected]:kylejb/dotfiles.git"}
if [ ! -d "$DOTFILES" ]; then
echo "Installing kylejb/dotfiles"
git clone "${REMOTE}" "${DOTFILES}" || true
# shellcheck source=/dev/null
. "${DOTFILES}/script/bootstrap"
fi