Skip to content

Commit 9b23394

Browse files
committed
feat: install, logging improvements
1 parent c942a8b commit 9b23394

File tree

11 files changed

+35
-44
lines changed

11 files changed

+35
-44
lines changed

files/home/.aliases

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
alias bench='ZSH_BENCH=1 exec zsh'
2-
alias dots='$DOTFILES/install'
2+
alias dots='cd $DOTFILES'
33
alias j='z'
44
alias reload='source ~/.zshrc'
55
alias zen='curl -s https://api.github.com/zen && echo'

files/home/.profile

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,6 @@ _dots_load_nvm() {
3434
}
3535
_dots_load_nvm
3636

37-
_dots_install_node() {
38-
node_alias="$NVM_DIR/alias/lts/jod"
39-
if [ -f "$node_alias" ]; then
40-
VERSION=`cat $node_alias`
41-
if [ -x `command -v nvm` ]; then
42-
nvm install "$VERSION" > /dev/null 2>&1 & disown
43-
fi
44-
node_bin_path="$NVM_DIR/versions/node/$VERSION/bin"
45-
if [[ ":$PATH:" != *":$node_bin_path:"* ]]; then
46-
export PATH="$node_bin_path:$PATH"
47-
fi
48-
fi
49-
}
50-
_dots_install_node
51-
5237
# Initialise and load pyenv
5338
# -----------------------------------------------------------------
5439
export PYENV_ROOT=${PYENV_ROOT:-"$HOME/.pyenv"}

script/install

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ set -eo pipefail
66
#
77

88
if [[ -t 1 && -n "$TERM" && "$TERM" != "dumb" ]]; then
9+
CYAN="\033[0;36m"
10+
CYAN_BOLD="\033[1;36m"
911
RED="\033[1;31m"
1012
GREEN="\033[1;32m"
1113
YELLOW="\033[1;33m"
@@ -19,7 +21,7 @@ else
1921
NC=""
2022
fi
2123

22-
printf "\n\t${GREEN} <<< dots >>> ${NC}\n"
24+
printf "\n\t${CYAN} <<< ${CYAN_BOLD}dots${CYAN} >>> ${NC}\n"
2325
printf "\t${GREY}==============${NC}\n\n"
2426

2527
# Prevent running as root
@@ -30,7 +32,7 @@ fi
3032

3133
# Ensure sudo credentials are cached
3234
if [[ -z "$SKIP_SUDO_CHECK" ]]; then
33-
echo -e "${GREY}Checking sudo credentials...${NC}"
35+
echo -e "${YELLOW}Checking sudo credentials...${NC}"
3436
sudo -v
3537
fi
3638

@@ -69,12 +71,12 @@ targets=($@)
6971

7072
# Run install scripts
7173
run() {
72-
echo -e "${GREY}Running \"$(basename "$0")\" at \"$(date)\"${NC}"
73-
echo -e "${GREY}Running as \"$(whoami)\" on \"$(hostname)\"${NC}"
74+
echo -e "Running \"$(basename "$0")\" at \"$(date)\""
75+
echo -e "Running as \"$(whoami)\" on \"$(hostname)\""
7476
if [[ -n "$targets" ]]; then
75-
echo -e "${GREY}Running ${#targets[@]} install target(s): ${targets[@]}${NC}"
77+
echo -e "Running ${YELLOW}${#targets[@]}${NC} install target(s): ${YELLOW}${targets[@]}${NC}"
7678
else
77-
echo -e "${GREY}Running all install targets${NC}"
79+
echo -e "Running all install targets"
7880
fi
7981

8082
for script in $install_dir/*.sh; do
@@ -88,27 +90,31 @@ run() {
8890

8991
local script_name=$(basename $script)
9092

91-
printf "\n\n${GREY}<<< $script_name:${NC}\n"
93+
printf "\n\n${CYAN}<<< ${CYAN_BOLD}$script_name:${NC}\n"
9294
local start_time=$(date +%s.%N)
9395
source $script
9496
local end_time=$(date +%s.%N)
9597
local execution_time=$(echo "$end_time - $start_time" | bc)
9698
local execution_ms=$(echo "$execution_time * 1000" | bc | awk '{printf "%.0f", $0}')
9799
local execution_ms_formatted=$(printf "%'.0f" "$execution_ms")
98100
local time_color="$GREY"
99-
if (( execution_ms > 1000 )); then
101+
if (( execution_ms < 2000 )); then
102+
time_color="$GREEN"
103+
elif (( execution_ms < 5000 )); then
104+
time_color="$YELLOW"
105+
else
100106
time_color="$RED"
101107
fi
102-
printf "\n${GREY}>>> $script_name, "
108+
printf "\n${CYAN}>>> ${CYAN_BOLD}${script_name}, ${NC}"
103109
printf "completed in ${time_color}${execution_ms_formatted}ms${NC}\n"
104110
done
105111
}
106-
echo -e "\n${GREY}install: Logging to \"$log_abs_target\"${NC}"
112+
echo -e "\ninstall: Logging to \"$log_abs_target\""
107113
start_time=$(date +%s.%N)
108114
run 2>&1 | tee "$log_abs_target"
109115
end_time=$(date +%s.%N)
110116

111117
total_time_raw=$(echo "$end_time - $start_time" | bc)
112118
total_time=$(echo "$total_time_raw" | awk '{printf "%.3g", $1}')
113-
echo -e "\n${GREY}Thank you!${NC}"
114-
echo -e "${GREY}Total time: ${GREEN}${total_time}s${NC}\n"
119+
echo -e "\nThank you!"
120+
echo -e "Total time: ${GREEN}${total_time}s${NC}\n"

script/install.d/01-ssh.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# skip if CODESPACES is set
99
if [ -n "$CODESPACES" ]; then
10-
echo -e "${GREY}Running in a GitHub Codespace${NC}"
10+
echo -e "${YELLOW}Running in a GitHub Codespace${NC}"
1111
export SKIP_SSH_CONFIG=1
1212
fi
1313

script/install.d/10-pyenv.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export PYENV_ROOT="$HOME/.pyenv"
99
if ! echo $PATH | grep -q "$PYENV_ROOT"; then
1010
export PATH="$PYENV_ROOT/bin:$PATH"
1111
fi
12-
if ! command -v "pyenv" &>/dev/null; then
12+
if ! command -v pyenv &>/dev/null; then
1313
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
1414
# https://github.com/pyenv/pyenv/wiki#suggested-build-environment
1515
sudo apt-get install -qq build-essential libssl-dev zlib1g-dev \

script/install.d/11-python.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
99

10-
if ! command -v "python" &>/dev/null; then
10+
if ! command -v python &>/dev/null; then
1111
pyenv install 3.12.1
1212
pyenv global 3.12.1
1313
fi
@@ -38,7 +38,7 @@ fi
3838
mkdir -p ~/.local/bin
3939
unset local_bin_path
4040

41-
if ! command -v "pipx" &>/dev/null; then
41+
if ! command -v pipx &>/dev/null; then
4242
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
4343
sudo apt-get install -qq pipx
4444
elif [[ "$OSTYPE" == "darwin"* ]]; then
@@ -48,7 +48,7 @@ fi
4848

4949
echo "pipx $(pipx --version)"
5050

51-
if ! command -v "poetry" &>/dev/null; then
51+
if ! command -v poetry &>/dev/null; then
5252
pipx install poetry
5353
fi
5454

script/install.d/12-node.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
99
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh"
1010

11-
nvm_version="0.39.7"
12-
if ! command -v "nvm" &>/dev/null; then
11+
nvm_version="0.40.3"
12+
if ! command -v nvm &>/dev/null; then
1313
bash -c "$(curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v${nvm_version}/install.sh)"
1414
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh"
1515
fi
@@ -25,9 +25,9 @@ echo "npm $(npm --version)"
2525

2626
npm_dependencies=(
2727
"firebase-tools"
28-
"neovim"
29-
"typescript-language-server"
30-
"typescript"
28+
# "neovim"
29+
# "typescript-language-server"
30+
# "typescript"
3131
)
3232

3333
npm_dependencies=($(comm -13 <(printf "%s\n" "${npm_dependencies[@]}" | sort) <(npm list -g --depth=0 --parseable | awk -F'/' '{print $NF}' | sort)))

script/install.d/20-docker.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88

99
# skip if in WSL
1010
if [[ -n "$WSL_DISTRO_NAME" ]]; then
11-
echo -e "${GREY}Running in WSL${NC}"
11+
echo -e "${YELLOW}Running in WSL${NC}"
1212
export SKIP_DOCKER_CONFIG=1
1313
fi
1414

1515
# skip if in CODESPACES
1616
if [[ -n "$CODESPACES" ]]; then
17-
echo -e "${GREY}Running in GitHub Codespaces${NC}"
17+
echo -e "${YELLOW}Running in GitHub Codespaces${NC}"
1818
export SKIP_DOCKER_CONFIG=1
1919
fi
2020

2121
# skip on mac
2222
if [[ "$OSTYPE" == "darwin"* ]]; then
23-
echo -e "${GREY}Running on macOS${NC}"
23+
echo -e "${YELLOW}Running on macOS${NC}"
2424
export SKIP_DOCKER_CONFIG=1
2525
fi
2626

script/install.d/25-terraform.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Install terraform.
66
#
77

8-
if ! command -v "terraform" &>/dev/null; then
8+
if ! command -v terraform &>/dev/null; then
99
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
1010
terraform_keyring_path="/usr/share/keyrings/hashicorp-archive-keyring.gpg"
1111
if [[ ! -f "$terraform_keyring_path" ]]; then

script/install.d/80-neofetch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Install neofetch.
66
#
77

8-
if ! command -v "neofetch" &>/dev/null; then
8+
if ! command -v neofetch &>/dev/null; then
99
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
1010
sudo apt-get install -qq neofetch &>/dev/null
1111
elif [[ "$OSTYPE" == "darwin"* ]]; then

0 commit comments

Comments
 (0)