Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: allow customization of CONFIG_FILE during install.sh #2241

Open
mvk opened this issue Feb 26, 2024 · 0 comments
Open

[Feature]: allow customization of CONFIG_FILE during install.sh #2241

mvk opened this issue Feb 26, 2024 · 0 comments

Comments

@mvk
Copy link
Contributor

mvk commented Feb 26, 2024

Expected behavior

as a "deployer" I'd like to be able to override CONFIG_FILE so that instead of directly updating ~/.bashrc, another file would be created, and then loaded into ~/.bashrc (or whatever).

for example, I'd like to have bash-it config file at ~/.bash.d/scripts/bash-it.bash, and load it from ~/.bashrc.

This "feature" has a side-effect of easily allowing to compare resulting .bashrc file with an expected value, thus allowing testing.

Current behavior

currently install.sh determines CONFIG_FILE value based on OSTYPE at line 188.

Possible solution

Introduce an env variable BASH_IT_CONFIG_FILE, if defined, set CONFIG_FILE to its value.

Context

currently (the lack of thereof requires me to):

dest="${HOME}/.bash.d/scripts"
BASHRC="${HOME}/.bashrc"
BASH_IT_CONFIG_FILE="${dest}/bash-it-config.bash"
ts="$(date +%s)"
mkdir -p "${dest}"
# backup current config
cp -p "${BASHRC}"{,.backup.$ts}
# create a "temporarily" ~/.bashrc file
./install.sh
mv "${BASHRC}" "${BASH_IT_CONFIG_FILE}"
cp -p "${BASHRC}"{.backup.$ts,}
{
  echo "## source bash-it config file";
  echo "source \"${BASH_IT_CONFIG_FILE}\"";
} >> "${BASHRC}"

hopefully I'd be able to:

dest="${HOME}/.bash.d/scripts"
BASHRC="${HOME}/.bashrc"
BASH_IT_CONFIG_FILE="${dest}/bash-it-config.bash"
ts="$(date +%s)"
mkdir -p "${dest}"
cp -p "${BASHRC}"{,.backup.$ts}
# create bash-it config file
BASH_IT_CONFIG_FILE="${BASH_IT_CONFIG_FILE}" ./install.sh
{
  echo "## source bash-it config file";
  echo "source \"${BASH_IT_CONFIG_FILE}\"";
} >> "${BASHRC}"

Notes

I can implement the above.

mvk added a commit to mvk/bash-it that referenced this issue Feb 26, 2024
draft to resolve Bash-it#2241
if the code is ok, documentation can be updated in additional commit.
mvk added a commit to mvk/bash-it that referenced this issue Feb 26, 2024
- update `install.sh`
- update `README.md`

Signed-off-by: Max Kovgan <kovganm@gmail.com>
mvk added a commit to mvk/bash-it that referenced this issue Feb 26, 2024
- update `install.sh`
- update `README.md`

Signed-off-by: Max Kovgan <kovganm@gmail.com>
mvk added a commit to mvk/bash-it that referenced this issue Feb 26, 2024
- update `install.sh`
- update `README.md`

Signed-off-by: Max Kovgan <kovganm@gmail.com>
mvk added a commit to mvk/bash-it that referenced this issue Feb 26, 2024
- update `install.sh` & `uninstall.sh`
- update `README.md`

Signed-off-by: Max Kovgan <kovganm@gmail.com>
mvk added a commit to mvk/bash-it that referenced this issue Feb 26, 2024
- update `install.sh` & `uninstall.sh`
- update `README.md`

Signed-off-by: Max Kovgan <kovganm@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant