Skip to content

Commit 54910e6

Browse files
committed
mac/installers/setup-env: added vim
also updated style to match what's in the corresponding ubuntu installer (install-configfiles)
1 parent 3bf12c8 commit 54910e6

File tree

1 file changed

+44
-33
lines changed

1 file changed

+44
-33
lines changed

mac/installers/setup-env

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,75 @@
11
#!/bin/bash
22

3+
34
# ------------------------------
45
# Global and command-line args
56

67
config_root="${1:?"Please provide the top-level config directory"}"
78

8-
bash_configs="${config_root}/mac/bash"
9-
fish_configdir="${config_root}/mac/fish"
10-
alacritty_configdir="${config_root}/mac/alacritty"
11-
tmux_configdir="${config_root}/mac/tmux"
9+
# source paths of configuration files
10+
path_to_configs_vim="${config_root}/common/vim/vimrc"
11+
path_to_configs_bash="${config_root}/mac/bash"
12+
path_to_configs_fish="${config_root}/mac/fish"
13+
path_to_configs_alacritty="${config_root}/mac/alacritty"
14+
path_to_configs_tmux="${config_root}/mac/tmux"
15+
16+
# destination paths of configuration files
17+
path_to_home_config="${HOME}/.config"
18+
path_to_home_fish="${path_to_home_config}/fish"
19+
path_to_home_alacritty="${path_to_home_config}/alacritty"
1220

13-
config_dirpath="${HOME}/.config"
14-
symlink_fishconfig="${config_dirpath}/fish"
15-
symlink_alacrittyconfig="${config_dirpath}/alacritty"
21+
path_to_home_vim="${HOME}/.vimrc"
1622

1723

1824
# ------------------------------
19-
# Configuration
25+
# Validation
2026

21-
# Create the base ".config" directory
22-
mkdir -p ${config_dirpath}
27+
# >> At some point, add validation that we're on a mac
2328

24-
# Bash setup
25-
for config_file in $(ls "${bash_configs}"); do
26-
symlink_filepath="${HOME}/.${config_file}"
27-
config_filepath="${bash_configs}/${config_file}"
2829

29-
if [[ ! -f "${HOME}/.${config_file}" ]]; then
30-
ln -s "${config_filepath}" "${symlink_filepath}"
30+
# ------------------------------
31+
# Main logic
3132

32-
else
33-
echo "Skipping existing file: '${symlink_filepath}'"
33+
# ..............................
34+
# All of the configurations that go directly into $HOME
3435

35-
fi
36+
# [vim] symlink the file
37+
echo "[vim] Linking configuration files..."
38+
ln -s "${path_to_configs_vim}" "${path_to_home_vim}"
39+
40+
# [bash] symlink each file
41+
for bash_config_file in $(ls "${path_to_configs_bash}"); do
42+
[[ -f "${HOME}/.${bash_config_file}" ]] && continue
43+
44+
config_filepath="${path_to_configs_bash}/${bash_config_file}"
45+
symlink_filepath="${HOME}/.${bash_config_file}"
46+
47+
echo -e "\t>> '${symlink_filepath}'"
48+
ln -s "${config_filepath}" "${symlink_filepath}"
3649
done
3750

38-
# Fish setup
39-
if [[ ! -d "${symlink_fishconfig}" ]]; then
40-
ln -s "${fish_configdir}" "${symlink_fishconfig}"
4151

42-
else
43-
echo "fish config exists. Skipping..."
52+
# ..............................
53+
# All of the configurations that go into $HOME/.config
54+
mkdir -p ${path_to_home_config}
4455

56+
# [fish] symlink the directory
57+
if [[ -d "${path_to_home_config}" && ! -d "${path_to_home_fish}" ]]; then
58+
ln -s "${path_to_configs_fish}" "${path_to_home_fish}"
4559
fi
4660

47-
# Alacritty setup
48-
if [[ ! -d "${symlink_alacrittyconfig}" ]]; then
49-
ln -s "${alacritty_configdir}" "${symlink_alacrittyconfig}"
50-
51-
else
52-
echo "alacritty config exists. Skipping..."
61+
# [alacritty] symlink the directory
62+
if [[ ! -d "${path_to_home_alacritty}" ]]; then
63+
ln -s "${path_to_configs_alacritty}" "${path_to_home_alacritty}"
5364
fi
5465

5566
# tmux theme setup
56-
if [[ ! -d "${tmux_configdir}/themes" ]]; then
57-
mkdir -p "${tmux_configdir}/themes"
67+
if [[ ! -d "${path_to_configs_tmux}/themes" ]]; then
68+
mkdir -p "${path_to_configs_tmux}/themes"
5869
path_to_nordtheme="${config_root}/external/nord-tmux"
5970

6071
if [[ -e "${path_to_nordtheme}/nord.tmux" ]]; then
61-
ln -s "${path_to_nordtheme}" "${tmux_configdir}/themes/nord-tmux"
72+
ln -s "${path_to_nordtheme}" "${path_to_configs_tmux}/themes/nord-tmux"
6273

6374
else
6475
echo "tmux theme not found. make sure the submodule is setup."

0 commit comments

Comments
 (0)