Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Quote things, SC2268, SC2143, SC2181, SC2162, SC2016, SC2013, &c. Rewrite globbing per `shellcheck`’s SC2013, and alsö s/typeset/local/g. Eliminate `compgen` where possible. Alsö: use the existing utility functions `_bash-it-get-component-type-from-path` and `_bash-it-get-component-name-from-path`, which just use parameter substitution anyway. Why was `sed` here? Alsö, don't add not-existing directories to `$PATH` in `pathmunge()` lib/helpers: fix `_command_exists()` The weird subshell is weird AF. Just do a normal `if`. Ditto `_binary_exists()`, `_completion_exists()`, and `_is_function()`! lib/helpers: second `shellcheck` pass lib/helpers: lint `_bash-it-migrate()` lib/helpers: lint `_disable-thing()` lib/helpers: lint `_enable-thing()` lib/helpers: lint `_help-list-aliases()` lib/helpers: lint `_help-plugins()` lib/helpers: some SC2034 fixes And SC2154 in `_make_reload_alias()` lib/helpers: lint `all_groups()` lib/helpers: `shfmt` My apologies to future `git blame` hunters ♥ lib/helpers: fix `all_groups()` - Don't write to disk, just pipe. - Don't loop, just do all functions. Performance of old implementation on my system: ``` real 0m9.996s user 0m5.318s sys 0m9.126s ``` Performance of new implementation on my system: ``` real 0m0.052s user 0m0.069s sys 0m0.025s ``` lib/helpers: cleanup - Improve `pushd`/`popd` somewhat - local some parameters - Lose weird Mac-specific alternate shell startup file (Bash loads startup files on Mac the same as it does on any other *nix system.) plugins/ruby: tests on Mac OS X Test was failing only on Mac OS X for some reason, so refactor a little. lib/utilities: autonomize `_bash-it-component-item-is-enabled()` lib/helpers: fix `_bash-it-describe()` Use `_bash-it-component-item-is-enabled()` Fix SC2295 lib/utilities: fix tests This subshell is...wut lib/helpers: be extra careful with word splitting Use curly braces when `$1` is unseparated from words in a string. lib/helpers: use `awk` to count lines instead of piping to `wc -l` Co-authored-by: Kostas Giapis <[email protected]> lib/helpers: remove weird non-globs Replace weird non-globs with array and loop, as suggested by `shellcheck`. Alsö, simplify several constructs to eliminate external binaries. Alsö, see mvdan/sh#558 lib/helpers: unbound positional parameters lib/helpers: juse use `awk`, insteado of `grep | awk` lib/helpers: local lib/search: code style cleanup Couldn't even `shellcheck` until I did a first pass...too much noise! ♥ lib/search: `shellcheck` SC2076 SC2091 SC2004 SC2086 SC2207 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. lib/search: fix usage statement `_bash-it-search()` SC2154 lib/search: `shfmt` My apologies to future `git blame` hunters ♥ lib/utilities: fix `_bash-it-component-help()` for long component names Alsö, minor tweak to `_bash-it-array-contains-element()` for clarity. This fixes Bash-it#1978. 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()`. lib/log: `shellcheck` && `shfmt` Alsö, fix tests to load `lib/colors` instead of `lib/appearance`...wut Alsö, `short-circuit _has_colors()`: If we already looked up colors, and we already have them, then don't run `tput` again. My apologies to future `git blame` hunters ♥ lib/log: rename `_log_general()` ...to `_bash-it-log-message()`. alsö, add common log levels with common names. lib/log: function `_bash-it-log-prefix-by-path()` ...to replace `_set-prefix-based-on-path()` in `scripts/reloader`. Deliberately does not use `_bash-it-get-component-name-from-path()`/`_bash-it-get-component-type-from-path()` as we need some of the intermediate state and would have to reimplement anyway. main: Glob for *.bash properly when path contains spaces - `shfmt`, `shellcheck` - Clean up legacy/compatibility code to simpler control flow - Move theme stuff down to where themes are handled - Don't use `**` as _Bash It_ has never before set `globstar`; this eliminates varying behavior by environment; this alsö fixes users having any not-enabled themes under their custom dir. - Lose weird Mac-specific alternate shell startup file (Bash loads startup files on Mac the same as it does on any other *nix system.) - Place `composure.sh` init all in one place main: adopt `_bash-it-log-prefix-by-path()` lib/reloader: adopt `_bash-it-log-prefix-by-path()` lib/appearance: `shellcheck` && `shfmt` reloader: `shellcheck` && `shfmt` Rewrite globbing per `shellcheck`'s SC2013 recommendations, and standardize whitespace. lib/preview: `shfmt` && `shellcheck` Fix theme file path globbing when $BASH_IT contains any spaces. My apologies to future `git blame` hunters ♥ uninstall: `shellcheck` && `shfmt` lint: add lib to clean_files.txt lib/theme: `shfmt` && `shellcheck` My apologies to future `git blame` hunters ♥ lib/colors: `shellcheck` && `shfmt` Alsö, clean up `__color_rgb` to just use a regular if block. lib/p4helpers: `shfmt` My apologies to future `git blame` hunters ♥ lib/githelpers: `shfmt` && `shellcheck` My apologies to future `git blame` hunters ♥ lib/theme: don't redefine battery_char() Combine the two definitions for `battery_char()` so the second one doesn't just overwrite the first one. Do one or the other, not both. Don't evaluate if `battery_percentage()` is available at load time, evaluate it at run time. lib/command_duration: `shfmt` && `shellcheck` My apologies to future `git blame` hunters ♥ lib/theme: `shellcheck` SC2154 These variables are referenced by themes already linted. test: quote things main: simplify flow of lib loader loop Eliminate the separate loop for `vendor/init.d` since it's just as easy to glob it in the `lib` loop. lib: delete `appearance.bash` This adds *three* lines to `bash_it.sh`, and two to `plugin/base`. Just not worth an extra file requiring special handling. main: load custom theme Allow for simpler directory strucutre when loading theme from `$CUSTOM_THEME_DIR`/`$BASH_IT_CUSTOM` make aliases load very late ...and update all the tests... preexec: add helper functions to loader 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()` like `__check_precmd_conflict()`, and alsö `safe_append_preexec()`. preexec: work around upstream Alsö, move `set +T` in here. test_helper already loads `composure.sh` ...and `cite()`s metadata test: new file `test_helper_libs.bash` For testing non-core files, just `load ../test_helper_libs` after `load ../test_helper` instead of trying to guess which libs must be loaded, in which order, for testing to succeed. `_command_exists` spews log messages, so our test log is littered with `_log_debug not found`. This fixes that too. test/theme: make fewer assumptions Literally copying a line from the source to be tested is perhaps not the best way to test that code. 😉 That said, we do want to verify that the function was actually loaded. TODO: actually test the function. lib/helpers: first `shellcheck` pass Quote things, SC2268, SC2143, SC2181, SC2162, SC2016, SC2013, &c. Rewrite globbing per `shellcheck`’s SC2013, and alsö s/typeset/local/g. Eliminate `compgen` where possible. Alsö: use the existing utility functions `_bash-it-get-component-type-from-path` and `_bash-it-get-component-name-from-path`, which just use parameter substitution anyway. Why was `sed` here? Alsö, don't add not-existing directories to `$PATH` in `pathmunge()` lib/helpers: fix `_command_exists()` The weird subshell is weird AF. Just do a normal `if`. Ditto `_binary_exists()`, `_completion_exists()`, and `_is_function()`! lib/helpers: second `shellcheck` pass lib/helpers: lint `_bash-it-migrate()` lib/helpers: lint `_disable-thing()` lib/helpers: lint `_enable-thing()` lib/helpers: lint `_help-list-aliases()` lib/helpers: lint `_help-plugins()` lib/helpers: some SC2034 fixes And SC2154 in `_make_reload_alias()` lib/helpers: lint `all_groups()` lib/helpers: `shfmt` My apologies to future `git blame` hunters ♥ lib/helpers: fix `all_groups()` - Don't write to disk, just pipe. - Don't loop, just do all functions. Performance of old implementation on my system: ``` real 0m9.996s user 0m5.318s sys 0m9.126s ``` Performance of new implementation on my system: ``` real 0m0.052s user 0m0.069s sys 0m0.025s ``` lib/helpers: cleanup - Improve `pushd`/`popd` somewhat - local some parameters - Lose weird Mac-specific alternate shell startup file (Bash loads startup files on Mac the same as it does on any other *nix system.) plugins/ruby: tests on Mac OS X Test was failing only on Mac OS X for some reason, so refactor a little. lib/utilities: autonomize `_bash-it-component-item-is-enabled()` lib/helpers: fix `_bash-it-describe()` Use `_bash-it-component-item-is-enabled()` Fix SC2295 lib/utilities: fix tests This subshell is...wut lib/helpers: be extra careful with word splitting Use curly braces when `$1` is unseparated from words in a string. lib/command_duration: remove temporary files lib/command_duration: dynamic clock hand Calculate the position (from 1 to 12) of the hour hand on the clock emoji used for the _command_duration string. Expressly handle COMMAND_DURATION_COLOR as blank when undefined. lib/command_duration: Refactor using `$EPOCHREALTIME` Fallback to `$SECONDS` for older versions of _Bash_. Instead of shortcircuiting the definition, just short-circuit the function. This allows the variable to be set later, e.g. on theme change. lib/command_duration: consolidate functions plugin/cmd-returned-notify: Rewrite to match/use `lib/command_duration` Use `$EPOCHREALTIME` (or `$SECONDS`) built-in variable provided by Bash instead of `date +%s`. We're only measuing the difference in seconds, so avoid both the binary invocation as well as the subshell. Alsö, Reduce environmental pollution by not exporting every variable, and unsetting when done. Change variable names to match lib/command-duration Rename `preexec_return_notification()` to match lib/command-duration's `_command_duration_pre_exec()`, and guard against redefining it. This should now use the same preexec hook and variables as the theme library `command_duration`. tests: handle nanoseconds plugin/cmd-returned-notify: remove duplicate function Remove `_command_duration_pre_exec()` from plugin; just use the one from `lib/command_duration` lib/command_duration: move `theme/command_duration.theme` Rename the `theme/command_duration.theme` file as it's not really got anything to do with theming or SCM. lib/command_duration: adopt `_bash_it_library_finalize_hook` plugins/dirs: use XDG_STATE_HOME Locate the bookmarks file in $XDG_STATE_HOME, and migrate an existing file from the old location if it exists. plugin/dirs: `shfmt` && `shellcheck` plugins/proxy: use `_command_exists` Addresses Bash-it#1632 Alsö, use `_log_notice`, quote variables, handle unbound parameters, &c. completions/sqlmap: use `_command_exists` Addresses Bash-it#1632 completion/fabric: no need for `_command_exists` If we're already inside the completion handler for `fab`...then it's a bit silly to check if `fab` is installed. plugins/latex: 2009 was 12 years ago Glob the currently installed edition, instead of transpoting us back to undergrad. plugins/osx-timemachine: code style cleanups Use bash functionality rather than external binaries, or even builtins. Alsö, if $SUDO_ASKPASS is set then pass -A to sudo. plugins/osx: code style improvements #TODO #TODO Avoid external binaries plugins/python: code style improvements Use shell functionality to avoid invoking external binaries, and quote some stuff. Alsö, use $EDITOR and related variables in order to fall through if some aren't defined. plugins/osx: unbound PROMPT_COMMAND Expressly handle undefined PROMPT_COMMAND as empty plugins/osx: dead code removal No need for gymnastics to determine if variable had been exported priort to modification. If it was, then it still is. See man bash(1). plugins/osx: unbound PROMPT_COMMAND I don't think this is possible given bash-preexec.sh dependency and early load. completion/system: accomodate multiple versions For Homebrew, switch between v1 and v2 of bash-completion based on whether the running Bash shell is new enough to use v2. plugins/go: simplify _bash-it-gopath-pathmunge() plugins/man: Add "R" to `$LESS` plugin/history: no need to set a trap Instead of globbally clearing `$HISTTIMEFORMAT` and setting a return trap to re-enable it, just make it local to the function. Also, set the defaults in a way that is happy with read-only parameters. plugin/latex: just call `pathmunge()` as it will check if the directory exists itself plugin/nginx: dont overwrite user-set variable, and quote path just in case plugin/git-subrepo: use `$HOME` instead of `~` If the outer variable is double-quoted, then the default expansion when undefined does not get tilde-expanded. Use `$HOME`. aliases/general: minor fixes - Don't define some aliases if the target isn't installed, use _command_exists to check instead of `type` and `which`. - Use `$EDITOR` for the editor for aliases about editing, excep the `sudo` ones because maybe you want those specifically? - Fix `ls` aliases to match their common definitions (-A instead of -a: don't show '.' and '..' when displaying hidden files). themes/base: use `type -P` instead of `which` Avoid external binary `which`. Use built-in `type -P` instead. Uppercase `-P` forces a path search to avoid hashed matches and functions/aliases and whatnot. plugins/git: use `type -p` completion/grunt: shellcheck completion/subversion: load system completion Load the completion script from the subversion package installed on the system, instead of bundling a copy. This addresses Bash-it#1818. NOTE: If `completions/system` is enabled, then it will load this same file anyway automatically. plugins/battery: lint plugins/xterm: not just Xterm completion/system: load earlier than other completions plugin/projects: cleanup plugins/thefuck: lint plugins/todo: lint plugin/base: use `_bash-it-component-item-is-enabled()` plugin/man: simplify Don't overwrite variables that the user has already set. completion/git: use `_completion_exists()` plugins/man: unbound `$LESS` plugins/alias: remove old `SC2154` flag This is no logner needed because the `local` keyword was moved higher up in the function.
- Loading branch information