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

Create lib finalize hook #2004

Merged
merged 2 commits into from
Jan 18, 2022
Merged

Create lib finalize hook #2004

merged 2 commits into from
Jan 18, 2022

Conversation

gaelicWizard
Copy link
Contributor

@gaelicWizard gaelicWizard commented Dec 29, 2021

Description

Create an array _bash_it_library_finalize_hook and loop at the end of the main bash_it.sh to run each element in the array.

Motivation and Context

The purpose here is to run some command after everything else has been loaded. For example, lib/theme checks for executables for SCM commands, but $PATH may be altered after lib/theme has loaded and therefore some available commands may never be discovered. To accommodate this problem, create _bash_it_appearance_scm_init() and add it to the hook. It will re-check at end of bash_it.sh just before prompt is first displayed.

How Has This Been Tested?

This has been part of my main branch for months and all tests pass.

Types of changes

  • Enhancement (non-breaking change which adds functionality)

Checklist:

  • My code follows the code style of this project.
  • If my change requires a change to the documentation, I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • If I have added a new file, I also added it to clean_files.txt and formatted it using lint_clean_files.sh.
  • I have added tests to cover my changes, and all the new and existing tests pass.

Copy link
Member

@NoahGorny NoahGorny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Create an array `_bash_it_library_finalize_hook` and loop at the end of the main `bash_it.sh` to run each element in the array.

The purpose here is to run some command after everything else has been loaded. For example, the appearance lib checks for executables for SCM commands, but `$PATH` may be altered after appearance has loaded and therefore some available commands may never be discovered. Therefore, create `_bash_it_appearance_scm_init()` and add it to the hook. It will re-check at end of `bash_it.sh` just before prompt is first displayed.
@NoahGorny NoahGorny merged commit fd35094 into Bash-it:master Jan 18, 2022
@gaelicWizard gaelicWizard deleted the finalize branch January 18, 2022 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants