Commit Graph

296 Commits (d86a182b6eb9d0f34c4a8f54196c38431f45eb4b)

Author SHA1 Message Date
Noah Gorny 34bc37c178
Merge pull request #2061 from gaelicWizard/lib/helpers
lib/helpers: fixes, improvements, consolations, constellations, and a partridge in a pear tree
2022-03-01 23:21:27 +02:00
John D Pell 47bbc73744 lib/helpers: `_bash-it-find-in-ancestor()`
Use new `composure.sh` feature to avoid `cite()`.
2022-02-24 12:47:22 -08:00
John D Pell 5957d189ea lib/utilities: `_bash-it-component-item-is-enabled()`
- Use normal `if`/`then`
2022-02-20 12:01:05 -08:00
John D Pell fe48deda2d lib: rename `_bash-it-clean-component-cache()`
…to `_bash-it-component-cache-clean()`
2022-02-20 12:01:05 -08:00
John D Pell 6257853759 lib/utilities: use `$XDG_CACHE_HOME` properly
We should fall back to the default location, not use an entirely different one.
2022-02-20 12:01:05 -08:00
John D Pell 72829ca21d lib/utilities: `_bash-it-component-item-is-enabled()`
- required arguments
2022-02-20 12:01:05 -08:00
John D Pell ffcf8f1c94 lib/utilities: >| 2022-02-20 12:01:05 -08:00
John D Pell fbd842b2ea lib/helpers: fix extraneous quotes from `_bash-it-grep()` 2022-02-20 12:01:05 -08:00
John D Pell 150f73ee50 bash-it update: show change log once 2022-02-18 03:06:17 -08:00
John D Pell 95353f1a98 lib/helpers: the last remnants of the `$OSTYPE` have been swept away
- Figure out which `sed` we have by checking, not guessing.
2022-02-17 20:46:28 -08:00
John D Pell ddf75f17ac lib/search: fix variable scope 2022-02-17 20:46:28 -08:00
John D Pell 35ecc260c2 lib/helpers: handle unbound parameters 2022-02-17 20:46:28 -08:00
John D Pell 31751624c0 lib/helpers: cleanup `_bash-it-profile-load-parse-profile()` a bit 2022-02-17 20:45:37 -08:00
John D Pell e7818dbaca lib/helpers: handle unbound positional parameters
Alsö, don't `pushd`/`popd` when restarting shell.
2022-02-17 20:45:37 -08:00
John D Pell 60c10004d1 lib/helpers: fix `_bash-it-component-pluralize()` 2022-02-17 20:45:27 -08:00
John D Pell 8246794a28 lib/preexec: the last remnants of the `$OSTYPE` have been swept away
- Use a POSIX-compliant/portable extended regular expression to match on word-boundaries, rather than guessing which regex library `bash` was linked against. See https://stackoverflow.com/a/12696899/555333 for explanation and code suggestion.
2022-02-16 16:10:41 -08:00
John D Pell c1943192ce lib/preexec: clarify subshell guard and comment
Rewrite comment on disabling the `DEBUG` trap in subshells, which is now handled upstream as of rcaloras/bash-preexec#26.

Alsö, fix the guard variable assignment to allow it to be overridden elsewhere (e.g., for testing).
2022-02-16 16:10:41 -08:00
John D Pell a93919625d lib/preexec: adobt `_bash_it_library_finalize_hook`
Schedule modification of `$PROMPT_COMMAND` for after everything has loaded.
2022-02-16 16:10:41 -08:00
John D Pell 6b08284928 Update "preexec" from "https://github.com/rcaloras/bash-preexec@master"
git-vendor-name: preexec
git-vendor-dir: vendor/github.com/rcaloras/bash-preexec
git-vendor-repository: https://github.com/rcaloras/bash-preexec
git-vendor-ref: fd2ffa8876d3940c97ffdc3cc807e43277cf72da
2022-02-16 16:10:41 -08:00
Noah Gorny 9d6fe72267
Merge pull request #2088 from gaelicWizard/lib/log
lib/log: //echo/printf
2022-02-16 22:18:22 +02:00
Puneeth Chaganti b3ef9ea209 lib/helpers: Don't rm "$profile_path" before writing to it
When the file is being re-created, we write to it, instead of appending to
it. So, the rm here is unnecessary and prevents users from linking the profile
file to another location that is potentially under version control. For
instance, once could link to a profile file located at
"$BASH_IT_CUSTOM/profiles/*.bash_it".
2022-02-16 20:55:08 +05:30
John D Pell e7b91e7be5 lib/log: use newly supported `composure.sh` feature
- these functions can now run even if `composure.sh` has *not* been loaded at all!
2022-02-15 22:20:19 -08:00
John D Pell 61b6393a4a lib/log: //echo/printf
- Replace `echo -e` with `printf` in `_bash-it-log-message()`.
- Local positional parameters to allow for defaults.
- Use `if`/`then` properly.
- Clean up use of `$BASH_IT_LOG_PREFIX` slightly (eliminate duplicate colons).
2022-02-15 22:18:24 -08:00
Noah Gorny 89c9504a5e
Merge pull request #2017 from gaelicWizard/lib/preview
lib/preview: functionalize
2022-02-13 23:59:06 +02:00
John D Pell 5d5858058e lib/history: new functions `_bash-it-history-auto-*()`
Two new functions `_bash-it-history-auto-save()` and `_bash-it-history-auto-load()`, which append new history to disk and load new history from disk, respectively.

See bash-it/bash-it#1595 for discussion.
2022-02-08 16:59:29 -08:00
John D Pell 00e3955dd3 lib/preview: add full completion 2022-02-07 15:27:03 -08:00
John D Pell a9a40a3cad lib/helpers: add `preview` to `bash-it` spaghetti 2022-02-07 15:27:03 -08:00
John D Pell d6555f369a lib/preview: refactor into a function
This allows future use like `bash-it preview`. Alsö, allows to use `$BASH_PREVIEW` to specify a particular theme to preview instead of just doing all of them.
2022-02-07 15:27:03 -08:00
Nariyasu Heseri 1e77c26c00 helpers: fix `awk: unterminated regexp` 2022-01-31 23:54:14 +09:00
Noah Gorny 2a9ee7e344
Merge pull request #2019 from gaelicWizard/lib/colors
lib/colors: split out metaprogramming
2022-01-30 00:10:14 +02:00
Noah Gorny 39e5652ee5
Merge pull request #1932 from gaelicWizard/search
Lib/search: lint, cleanup, and small fixes
2022-01-30 00:09:49 +02:00
John D Pell 4cf2aae36e lib/search: code cleanup
Improve `_bash-it-erase-term()`, `_bash-it-flash-term()`, `_bash-it-rewind()`, `_bash-it-search-result()`, and `_bash-it-search-component()`. Minor tweaks to `_bash-it-is-partial-match()`, and `_bash-it-search()`.
2022-01-28 13:35:17 -08:00
John D Pell b8694ee140 lib/search: `shfmt`
My apologies to future `git blame` hunters ♥
2022-01-28 13:35:17 -08:00
John D Pell 8939e943c5 lib/search: fix usage statement `_bash-it-search()`
SC2154
2022-01-28 13:35:17 -08:00
John D Pell 64efe52394 lib/search: fix `_bash-it-flash-term()`
1. `$text_black` isn't a parameter provided by _Bash It_. Typo?
2. `$bold_yellow` is meant for prompt strings and putputs `\[`; ditto `$bold_red`.
3. The color was never returned to normal after.
2022-01-28 13:35:17 -08:00
John D Pell afeb4d6e11 lib/search: `shellcheck`
SC2076
SC2091
SC2004
SC2086
SC2207
2022-01-28 13:35:17 -08:00
John D Pell 5478617a89 lib/search: code style cleanup
Couldn't even `shellcheck` until I did a first pass...too much noise! ♥
2022-01-28 13:35:17 -08:00
John D Pell 16cee1956d lib/colors: revert #99
This reverts bash-it/bash-it#99, a metaprogramming adventure in terminal color code escape computation. It was functionally reverted in bash-it/bash-it#699; I'm just finishing the job.
2022-01-28 13:08:50 -08:00
John D Pell 2a8d8ba540 lib/colors: rename `theme/colors` 2022-01-28 13:08:50 -08:00
John D Pell c08267e25d lib/helpers: eliminate assumptions about login shells
Bash loads initialization files on Mac just the same as it does on Linux or WSL. Our previous assumptions were wrong, and my fix was alsö wrong because I made more assumptions!

This patch eliminates the assumptions. Literally just load either the startup file the shell started with, or fall back to `~/.bashrc`. Don't check `shopt -q login_shell` and don't check `$OSTYPE` or anything else.
2022-01-28 03:59:02 -08:00
Noah Gorny 056c392a54 lib: preexec: Properly return if there was a conflict in check_*_conflict
It goes the other way around!
2022-01-26 18:25:37 +02:00
John D Pell ae8c9c08a3 lib/preexec: trim whitespace
Alsö, use `_bash-it-array-contains-element()`
2022-01-25 13:00:04 -08:00
John D Pell 7770e8cbb9 lib/preexec: log an error if `bash-preexec` not loaded 2022-01-25 13:00:04 -08:00
John D Pell 9f146f937a lib/preexec: consolidate helper functions
Define the helper functions for `bash-preexec.sh` immediately after importing it, rather than in `lib/theme`.
- `__check_precmd_conflict()` and `save_append_prompt_command()` are generally useful and not theme-specific.
- Add matching `__check_preexec_conflict()` and `safe_append_preexec()`.
2022-01-25 13:00:04 -08:00
John D Pell 7a0b353cea lib/preexec: rename `vendor/init.d/preexec.bash` 2022-01-25 13:00:04 -08:00
souhaiebtar a312e5a9b9
fix wrong function name in `helpers.bash`
when i tried to install, i got a message `_bash-it-pluralize-component` command not found; after checking `utilities.bash` the correct function name was `_bash-it-component-pluralize`
2022-01-22 12:33:33 +00:00
John D Pell 0f0093dd4b lib/helpers: quotes for consistency
Quote some parameter uses that don't strictly require it, but since Bash needs so many quotes everywhere else my brain worms feel better when these are quoted too.

lib/helpers: simplify some quote escapes
2022-01-18 11:06:21 -08:00
John D Pell dfc3fa4339 lib/helpers: delete `_bash-it-determine-component-status-from-path()`
Duplicate function of existing `_bash-it-component-item-is-enabled()`.
2022-01-18 11:06:21 -08:00
John D Pell 62b5297dc2 lib/utilities: autonomize `_bash-it-component-item-is-enabled()` 2022-01-18 11:06:21 -08:00
John D Pell 22b290b94f lib/helpers: simplify some functions
- add some `local` variables,
- don't subshell `_typeset_functions`,
2022-01-18 11:02:37 -08:00