-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfresh-brew.local
88 lines (72 loc) · 3.13 KB
/
fresh-brew.local
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
#!/usr/bin/env bash
python_version="3.11.3"
##### START OF HELPER FUNCTIONS #####
# If this breaks, you can look at the config instructions on their README
# https://github.com/pyenv/pyenv#homebrew-in-macos
configure_shell_file_for_pyenv() {
# This env var isn't really well documented, but essentially there's a prompt that comes
# up if you don't have this set letting you know that the pyenv venv prompt will change
# in the future.
append_to_file "$shell_file" "export PYENV_VIRTUALENV_DISABLE_PROMPT=1"
if [[ $SHELL == *fish ]]; then
# shellcheck disable=SC2016
append_to_file "$shell_file" 'set -Ux PYENV_ROOT $HOME/.pyenv'
# shellcheck disable=SC2016
append_to_file "$shell_file" 'set -U fish_user_paths $PYENV_ROOT/bin $fish_user_paths'
append_to_file "$shell_file" 'status is-login; and pyenv init --path | source'
append_to_file "$shell_file" 'status --is-interactive; and source (pyenv init - | psub)'
elif [[ $SHELL == *zsh ]]; then
# shellcheck disable=SC2016
append_to_file "$shell_file" 'eval "$(pyenv init -)"'
elif [[ $SHELL == *bash ]]; then
# shellcheck disable=SC2016
append_to_file "$shell_file" 'export PYENV_ROOT="$HOME/.pyenv"'
# shellcheck disable=SC2016
append_to_file "$shell_file" 'export PATH="$PYENV_ROOT/bin:$PATH"'
# shellcheck disable=SC2016
append_to_file "$shell_file" 'eval "$(pyenv init --path)"'
# shellcheck disable=SC2016
append_to_file "$shell_file" 'eval "$(pyenv init -)"'
fi
}
install_python_with_pyenv() {
fancy_echo "Installing python $python_version ..."
if pyenv versions | grep -q "$python_version"; then
fancy_echo "python $python_version already installed."
else
pyenv install "$python_version"
fi
}
# If direnv stops working, it might be because the setup commands changed.
# Check the documentation:
# https://github.com/direnv/direnv/blob/master/docs/hook.md
configure_shell_file_for_direnv() {
if [[ $SHELL == *fish ]]; then
append_to_file "$shell_file" "direnv hook fish | source"
elif [[ $SHELL == *zsh ]]; then
# shellcheck disable=SC2016
append_to_file "$shell_file" 'eval "$(direnv hook zsh)"'
elif [[ $SHELL == *bash ]]; then
# shellcheck disable=SC2016
append_to_file "$shell_file" 'eval "$(direnv hook bash)"'
fi
}
##### END OF HELPER FUNCTIONS #####
fancy_echo "Running your customizations from fresh-brew.local ..."
if [ -f "Brewfile.local" ]; then
if brew bundle --file="Brewfile.local"; then
fancy_echo "All items in Brewfile.local were installed successfully."
else
fancy_echo "Some items in Brewfile.local were not installed successfully."
fi
fi
configure_shell_file_for_pyenv
# make sure that any functions that write to the shell file appear before this
# direnv function below because the direnv line has to be at the very end of the
# shell file.
configure_shell_file_for_direnv
install_python_with_pyenv
fancy_echo "******* IMPORTANT **************************************"
fancy_echo "If you get errors below, quit and restart your terminal,"
fancy_echo "or open a new tab, and run 'make setup' again."
fancy_echo "********************************************************"