-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.sh
executable file
·114 lines (84 loc) · 3.2 KB
/
install.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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env bash
readonly SCRIPT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
function main() {
set -euo pipefail
shopt -s nullglob
[[ "${SCRIPT_DIR}" == "$PWD" ]] || {
echo "Changing wroking directory to ${SCRIPT_DIR}"
cd "${SCRIPT_DIR}"
}
# which jq &>/dev/null || {
# apt_install jq "jq - command-line JSON processor"
# }
# which basher &>/dev/null || {
# echo "Installing: basher - package manager for shell scripts and functions"
# curl -s https://raw.githubusercontent.com/basherpm/basher/master/install.sh | bash
# }
which git &>/dev/null || apt_install git "git - distributed version control"
which stow &>/dev/null || apt_install stow "stow - package manager for shell scripts and functions"
which make &>/dev/null || apt_install build-essential "build-essential - make"
source "${SCRIPT_DIR}/path_manager/.bashrc.d/path_manager.sh" || {
echo 2>&1 "ERROR: Failed to source path_manager.sh"
exit 1
}
add_directory_to_path "${HOME}/.local/bin"
which bpkg &>/dev/null || {
echo "Installing: bpkg - bash package manager"
curl -Lo- "https://raw.githubusercontent.com/bpkg/bpkg/master/setup.sh" | bash
}
which term &>/dev/null || {
echo "Installing: term - Terminal fun"
bpkg install term -g
}
[[ ! -f "${SCRIPT_DIR}/bashrc_manager/install.sh" ]] || {
echo "Installing: bashrc manager - modular bashrc files"
"${SCRIPT_DIR}/bashrc_manager/install.sh"
}
[[ ! -f "${SCRIPT_DIR}/gitconfig/install.sh" ]] || {
echo "Installing: gitconfig files"
"${SCRIPT_DIR}/gitconfig/install.sh"
}
echo "Linking: path-manager"
stow --no-folding -t "${HOME}" --dotfiles path_manager
echo "Linking: my_bashrc"
stow --no-folding -t "${HOME}" --dotfiles my_bashrc
echo "Linking: git_ps1"
stow --no-folding -t "${HOME}" --dotfiles git_ps1
echo "Linking: wait_pid"
stow --no-folding -t "${HOME}" --dotfiles wait_pid
echo "Linking: pwd_short"
stow --no-folding -t "${HOME}" --dotfiles pwd_short
echo "Linking: inputrc"
stow --no-folding -t "${HOME}" --dotfiles inputrc
echo "Linking: tmux_conf"
stow --no-folding -t "${HOME}" --dotfiles tmux_conf
echo "Linking: vimrc"
stow --no-folding -t "${HOME}" --dotfiles vimrc
echo "Linking: ps1_manager"
stow --no-folding -t "${HOME}" --dotfiles ps1_manager
echo "Linking: preexec"
stow --no-folding -t "${HOME}" --dotfiles preexec
echo "Linking: profile"
local backup_path
backup_path="${HOME}/.profile.$(date --iso-8601=seconds | tr -dc '0-9').bkp"
if [[ -e "${HOME}/.profile" ]]; then
echo "Moving existing ${HOME}/.profile -> ${backup_path}"
mv "${HOME}/.profile" "${backup_path}"
fi
stow --no-folding -t "${HOME}" --dotfiles profile
echo "Done - please restart your shell for changes to take effect"
}
__apt_updated=false
function _update_apt() {
if ! __apt_updated; then
echo "Updating apt"
sudo apt update
__apt_updated=true
fi
}
function apt_install() {
echo "Installing: ${2}"
_update_apt
sudo apt install -y "${1}"
}
main "$@"