feat: add profile awareness

This commit is contained in:
Marc 2024-02-26 00:48:03 -05:00
parent 63d1aba020
commit 98890b34d2
Signed by: marc
GPG key ID: 048E042F22B5DC79
3 changed files with 29 additions and 14 deletions

View file

@ -5,7 +5,7 @@ Environment tweaks for everyday happiness.
## Setup ## Setup
```bash ```bash
git clone git@github.com:mcataford/env.git <path-of-your-choosing> | . ./bootstrap.sh git clone git@github.com:mcataford/env.git <path-of-your-choosing> | ./bootstrap.sh
``` ```
The setup script will look for pre-existing managed blocks and will not update the file if one is found. 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 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. 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.<profile>.<extension>`.
## Structure ## Structure
The package is structured as such: The package is structured as such:
@ -27,17 +32,11 @@ env/
shell_extras # Functions, aliases and exports for the shell. shell_extras # Functions, aliases and exports for the shell.
extras.vim # Common config for neovim. extras.vim # Common config for neovim.
git_config # Configuration commands for git 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 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 ## Contributing
I'm not currently looking for contributions since this is mainly about standardizing my own setup across machines. I'm not currently looking for contributions since this is mainly about standardizing my own setup across machines.

View file

@ -183,7 +183,7 @@ install_gh_plugins() {
gh extension install nektos/gh-act gh extension install nektos/gh-act
gh extension install dlvhdr/gh-dash 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 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 # System updates
ensure_apt_up_to_date ensure_apt_up_to_date
ensure_apt_dependencies ensure_apt_dependencies
@ -271,5 +270,22 @@ bootstrap() {
inject_vim_configuration inject_vim_configuration
} }
bootstrap bootstrap_work() {
return 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