-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsetup_dotfiles
executable file
·78 lines (62 loc) · 2.53 KB
/
setup_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
#! /usr/bin/env bash
main() {
local teal_highlight clear_highlight
teal_highlight='\x1b[38;5;006m'
clear_highlight='\x1b[0m\n\n'
parse_input "$@"
# check that DOTFILES variable is defined
# relative path handling is tricky and never foolproof
# refs
# - http://mywiki.wooledge.org/BashFAQ/028
# - https://stackoverflow.com/questions/6659689/referring-to-a-file-relative-to-executing-script
# shellcheck disable=SC1090
source "${BASH_SOURCE%/*}/check_dotfiles_variable.sh"
printf "%bstarting dotfiles setup%b" "$teal_highlight" "$clear_highlight"
# symlink config files to their correct locations
# done early so that other installation steps can make use of these files (for
# example, setting up home-manager for the first time in `setup_nix` requires
# `$DOTFILES/nix/home.nix` to be symlinked appropriately)
"$DOTFILES/infra/setup/bin/symlink"
# TODO: test if available for future setup steps
"$DOTFILES/infra/setup/bin/setup_nix" || {
# shellcheck disable=SC2016
echo '`nix` installation failed.'
# shellcheck disable=SC2016
echo 'Try opening a new shell and rerunning `$DOTFILES/infra/setup/bin/setup_nix`'
exit 1
}
# generate user-specific gitconfig (name & email) @ `$HOME/.gitconfig.local`
"$DOTFILES/infra/setup/bin/setup_git_config" "$HOME/.gitconfig.local" --skip-existing
# set up our shell (`zsh`)
# this adds `zsh` to our allowed shells and sets it as the default. Then it
# loads `zsh` for the first time to install plugins & complete setup.
"$DOTFILES/infra/setup/bin/setup_zsh"
# load neovim for the first time to install plugins
"$DOTFILES/infra/setup/bin/setup_neovim"
# set up various pieces too small for their own files
# see the file in question for each piece
"$DOTFILES/infra/setup/bin/setup_bits_and_pieces"
# run after `$DOTFILES/infra/setup/bin/symlink` so that $DOTFILES/utilities/asdf/tool-versions is
# symlinked to `$HOME/.tool-versions`
"$DOTFILES/infra/setup/bin/setup_asdf"
# optionally set up work-specific config (confirms via user prompt)
"$DOTFILES/infra/setup/bin/setup_work"
printf "%bstarting new shell, happy coding!%b" "$teal_highlight" "$clear_highlight"
printf "%bsetup finished! 🎉%b" "$teal_highlight" "$clear_highlight"
zsh --interactive
}
parse_input() {
for opt in "$@"; do
case $opt in
--headless)
export DOTFILES_SETUP_HEADLESS=true
;;
--*)
# shellcheck disable=SC2016
printf 'invalid flag passed to `setup_dotfiles`'
exit 1
;;
esac
done
}
main "$@"