|
1 | 1 | #!/bin/bash |
2 | 2 |
|
| 3 | + |
3 | 4 | # ------------------------------ |
4 | 5 | # Global and command-line args |
5 | 6 |
|
6 | 7 | config_root="${1:?"Please provide the top-level config directory"}" |
7 | 8 |
|
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" |
12 | 20 |
|
13 | | -config_dirpath="${HOME}/.config" |
14 | | -symlink_fishconfig="${config_dirpath}/fish" |
15 | | -symlink_alacrittyconfig="${config_dirpath}/alacritty" |
| 21 | +path_to_home_vim="${HOME}/.vimrc" |
16 | 22 |
|
17 | 23 |
|
18 | 24 | # ------------------------------ |
19 | | -# Configuration |
| 25 | +# Validation |
20 | 26 |
|
21 | | -# Create the base ".config" directory |
22 | | -mkdir -p ${config_dirpath} |
| 27 | +# >> At some point, add validation that we're on a mac |
23 | 28 |
|
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}" |
28 | 29 |
|
29 | | - if [[ ! -f "${HOME}/.${config_file}" ]]; then |
30 | | - ln -s "${config_filepath}" "${symlink_filepath}" |
| 30 | +# ------------------------------ |
| 31 | +# Main logic |
31 | 32 |
|
32 | | - else |
33 | | - echo "Skipping existing file: '${symlink_filepath}'" |
| 33 | +# .............................. |
| 34 | +# All of the configurations that go directly into $HOME |
34 | 35 |
|
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}" |
36 | 49 | done |
37 | 50 |
|
38 | | -# Fish setup |
39 | | -if [[ ! -d "${symlink_fishconfig}" ]]; then |
40 | | - ln -s "${fish_configdir}" "${symlink_fishconfig}" |
41 | 51 |
|
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} |
44 | 55 |
|
| 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}" |
45 | 59 | fi |
46 | 60 |
|
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}" |
53 | 64 | fi |
54 | 65 |
|
55 | 66 | # 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" |
58 | 69 | path_to_nordtheme="${config_root}/external/nord-tmux" |
59 | 70 |
|
60 | 71 | 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" |
62 | 73 |
|
63 | 74 | else |
64 | 75 | echo "tmux theme not found. make sure the submodule is setup." |
|
0 commit comments