From 98890b34d2f00977dac620969132f28982afb15f Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Mon, 26 Feb 2024 00:48:03 -0500 Subject: [PATCH] feat: add profile awareness --- README.md | 15 +++++----- bootstrap.sh | 28 +++++++++++++++---- ...ash_config.yml => gh-dash_config.home.yml} | 0 3 files changed, 29 insertions(+), 14 deletions(-) rename files/{gh-dash_config.yml => gh-dash_config.home.yml} (100%) diff --git a/README.md b/README.md index dbc5f2d..358416a 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Environment tweaks for everyday happiness. ## Setup ```bash -git clone git@github.com:mcataford/env.git | . ./bootstrap.sh +git clone git@github.com:mcataford/env.git | ./bootstrap.sh ``` The setup script will look for pre-existing managed blocks and will not update the file if one is found. @@ -16,6 +16,11 @@ Since the managed blocks only `source` the files in this repository, pulling in new tweaks you want to apply. If changes are made to the managed blocks, you will need to first remove them from where they live and rerun the setup script. +## Profiles + +A profile must be provided via `$ENV_PROFILE`. This can be used by steps to determine variants of a file to copy over. +Files with profile specificity should be named `file..`. + ## Structure The package is structured as such: @@ -27,17 +32,11 @@ env/ shell_extras # Functions, aliases and exports for the shell. extras.vim # Common config for neovim. git_config # Configuration commands for git - starship.toml # Starship prompt configuration + ... Other configuration templates ``` Adding code to `shell_extras` will add code that gets executed on shell-start. -### Adding steps - -Each step is defined as a function in `steps.sh` and should start with a call to `pre_step` to ensure that a header gets -echo'ed out. Additionally, the function should be called from `bootstrap` in `bootstrap.sh` and the `TOTAL_STEPS` should -be updated to reflect the number of steps. - ## Contributing I'm not currently looking for contributions since this is mainly about standardizing my own setup across machines. diff --git a/bootstrap.sh b/bootstrap.sh index 564e650..1e082e6 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -183,7 +183,7 @@ install_gh_plugins() { gh extension install nektos/gh-act gh extension install dlvhdr/gh-dash - copy_file ./files/gh-dash_config.yml ~/.config/gh-dash/config.yml + copy_file ./files/gh-dash_config.$ENV_PROFILE.yml ~/.config/gh-dash/config.yml gh extension upgrade --all } @@ -249,10 +249,9 @@ inject_vim_configuration() { # ########################################################### -TOTAL_STEPS=10 +bootstrap_home() { + TOTAL_STEPS=10 -# Refer to steps.sh for step definition. -bootstrap() { # System updates ensure_apt_up_to_date ensure_apt_dependencies @@ -271,5 +270,22 @@ bootstrap() { inject_vim_configuration } -bootstrap -return +bootstrap_work() { + TOTAL_STEPS=4 + + install_gh_plugins + + install_omz + install_and_configure_starship + + inject_shell_configuration + inject_vim_configuration +} + +if [[ $ENV_PROFILE == "home" ]]; then + bootstrap_home +elif [[ $ENV_PROFILE == "work" ]]; then + bootstrap_work +else + echo "Unknown \$ENV_PROFILE. :shrug:" +fi diff --git a/files/gh-dash_config.yml b/files/gh-dash_config.home.yml similarity index 100% rename from files/gh-dash_config.yml rename to files/gh-dash_config.home.yml