-
Notifications
You must be signed in to change notification settings - Fork 4
/
link-dotfiles
executable file
·85 lines (73 loc) · 1.68 KB
/
link-dotfiles
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env bash
#
# Link all user dotfiles into their standard locations.
#
set -o errexit
set -o nounset
set -o pipefail
log_info() {
printf "[INFO]: %s\n" "$*"
}
log_warn() {
printf "[WARN]: %s\n" "$*" >&2
}
log_error() {
printf "[ERROR]: %s\n" "$*" >&2
}
CURRENT_SCRIPT_PATH="$(
cd "$(dirname "$0")"
pwd -P
)"
packages=(
"ag"
"alacritty"
"asdf"
"bin"
"emacs"
"git"
"gpg"
"haskell"
"javascript"
"nvim"
"ssh"
"tmux"
"yubikey"
"zsh"
)
# Create standard XDG base directories; if these don't exist, stow will create them as symlinks into
# the first package that asks for them (e.g. `packages/asdf/.config/asdf` will be linked as
# `${HOME}/.config` rather than "${HOME}/.config/asdf" as we want)
mkdir -p "${XDG_CACHE_HOME}"
mkdir -p "${XDG_CONFIG_HOME}"
mkdir -p "${XDG_DATA_HOME}"
mkdir -p "${HOME}/.gnupg"
mkdir -p "${HOME}/.ssh"
mkdir -p "${HOME}/.var/app"
mkdir -p "${XDG_CONFIG_HOME}/containers"
mkdir -p "${XDG_DATA_HOME}/applications"
case "${OSTYPE}" in
linux*)
:
packages+=(
"gammastep"
"podman"
"sway"
"zeal"
)
;;
esac
if command -v stow > /dev/null 2>&1; then
log_info "Symlinking dotfiles into $HOME..."
for pkg in "${packages[@]}"; do
pushd "${CURRENT_SCRIPT_PATH}/packages" > /dev/null
stow --target="$HOME" --verbose=1 "${pkg}"
popd > /dev/null
done
log_info "Symlinked dotfiles into $HOME."
else
log_warn "stow not installed. Skipping dotfiles symlinking..."
fi
# Update the desktop database to pick up any installed .desktop files
if [[ "${OSTYPE}" == linux* ]] && command -v update-desktop-database > /dev/null 2>&1; then
update-desktop-database "${XDG_DATA_HOME}/applications/"
fi