Commit Graph

647 Commits (ec3c06fa33e56cc4245f2ad1a4d3f8fa1953e20e)

Author SHA1 Message Date
David Farrell 00062bfcb6
chore: Use grep -E / grep -F instead of egrep / fgrep (#2164)
Ensures that the -E or -F option, when used, is the first option
* i.e. grep -oE => grep -E -o

Updates _bash-it-grep to invoke grep with just the provided arguments
* This function was (and still is) unused, but decided this new functionality was actually more useful

Introduces _bash-it-fgrep to invoke grep -F

Removes type -P egrep from the _bash-it-*grep functions

For usages that were already going to be modified, use -F if appropriate
* Does not touch grep usages that may have benefited from -F, but were not otherwise considered for this PR

Adds shellcheck header to modified .bash files that didn't already have it
2022-10-13 10:34:57 -07:00
David Farrell c0dc83edfc
plugin(dirs): Create backup file parent directory 2022-05-09 13:08:52 -07:00
Eric Villard 088212fd32 fix projects plugin regression
This regression was introduced in ea2002a.

Before this commit, when the provided project was unique under all the
project paths, the command automatically change the directory to it.
Currently this is no more the case.
If there are many project paths set, then the project path menu is shown
at every call.
This PR solves this issue.

Signed-off-by: Eric Villard <dev@eviweb.fr>
2022-03-16 08:43:52 +01:00
John D Pell 6ca10cf84c 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

Remove `preexec_return_notification()` in favor of `lib/command-duration`'s `_command_duration_pre_exec()`.

This should now use the same preexec hook and variables as the theme library `command_duration`.

tests: handle nanoseconds
2022-03-04 12:58:07 -08:00
John D Pell 029e53a433 plugin/battery: fix handling of multiple batteries with `upower` 2022-03-03 23:45:40 -08:00
Koichi Murase 41cf3cfaf2 plugin/blesh: override possible arguments inherited by callers 2022-02-19 16:34:22 +09:00
Noah Gorny 379813b671
Merge pull request #2086 from seefood/ira/fix-dirs
Tilde expanstion won't work once it is a quoted string, expanding in advance
2022-02-16 22:45:02 +02:00
John D Pell c982a881a2 completion/aliases: typo 2022-02-14 16:00:15 -08:00
Ira Abramov 16bf32be65 Merge branch 'master' of https://github.com/Bash-it/bash-it into ira/fix-dirs
* 'master' of https://github.com/Bash-it/bash-it: (22 commits)
  main: variable name cleanup
  lib/history: new functions `_bash-it-history-auto-*()`
  plugin/history*search: no need to load after `plugin/history`
  plugin/history-eternal: Use `readonly` instead of `export`
  plugin/history: don't use `export`
  lib/preview: add full completion
  lib/helpers: add `preview` to `bash-it` spaghetti
  lib/preview: refactor into a function
  completion/system: correctly load version when not linked
  main: adopt `_bash-it-log-prefix-by-path()`
  main: Glob for *.bash properly when path contains spaces
  completion/aliases: rename init function
  test/battery: require matching battery identifier
  test/battery: add multiple-battery edge case
  plugin/battery: split `upower` to two variables
  completion/alias: add stub file
  completion/alias: fix tests
  completion/alias: rename
  completion/alias: `shfmt` && `shellcheck`
  completion/alias: eliminate use of `eval`
  ...
2022-02-14 10:31:04 +02:00
Noah Gorny 0619c19f65
Merge pull request #2074 from NariyasuHeseri/master
plugin/battery: bug fix
2022-02-14 08:22:33 +02:00
Noah Gorny 561e282585
Merge pull request #2044 from gaelicWizard/completion/alias
completion/aliases: eliminate use of `eval`
2022-02-13 23:59:35 +02:00
Ira Abramov 98889b208c Tilde expanstion won't work once it is a quoted string, expanding in advance. 2022-02-11 09:56:10 +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 f6119567e8 plugin/history*search: no need to load after `plugin/history`
There's no need for these plugins to load after `plugin/history`. None of the history plugins depend upon each other loading before, after, or at all.
2022-02-08 16:59:29 -08:00
John D Pell 267a721ac6 plugin/history-eternal: Use `readonly` instead of `export`
...and hide errors relating to setting already-readonly variables.

`plugin/history-eternal` does not need to force loading after `plugin/history` because both plugins will play nicely with read-only variables, and since we're overwritting and marking read-only then the intended result survives no matter which loads first.

plugin/history-eternal: require Bash v4.3+

Unlimited history is only possible in _Bash_ version 4.3 and up
2022-02-08 16:59:29 -08:00
John D Pell 8052911861 plugin/history: don't use `export`
...so the plugin is friendly to variables already marked read-only.
2022-02-08 16:59:29 -08:00
John D Pell cade0a1e7a plugin/battery: split `upower` to two variables 2022-02-03 10:45:27 -08:00
John D Pell 880488ec9a completion/alias: add stub file
- put a loader to remove the symlink at `enabled/***---alias-completion.plugin.bash`.
2022-01-30 16:13:54 -08:00
John D Pell 7fcad6ed0d completion/alias: rename
There is no reason for this to be in the `plugins` directory, it just needs to have a load priority sufficiently high that it runs after any aliases are defined.
2022-01-30 16:13:54 -08:00
John D Pell d214621d39 completion/alias: `shfmt` && `shellcheck` 2022-01-30 16:13:54 -08:00
John D Pell b0f23d8e98 completion/alias: eliminate use of `eval` 2022-01-30 16:13:54 -08:00
Nariyasu Heseri c794f4f0e7 plugin/battery: use `--max-count` of `grep` instead of `head` 2022-01-29 15:50:36 +09:00
John D Pell bf4ddf5951 plugin/colors: `shfmt` 2022-01-28 13:09:00 -08:00
John D Pell 399f0265aa plugin/colors: revert #699
This reverts commit 2a3fde2b14 but does *not* restore the previous variables. Those are still provided by `lib/colors`.

This plugin exists for anyone who likes the metaprogramming adventure of computing colors dynamically rather than using hard-coded value. Potentially this could be used by themes, or possibly by a theme color-scheme randomizer?
2022-01-28 13:09:00 -08:00
John D Pell 5f19de8d51 plugin/colors: rename `theme/colors` 2022-01-28 13:09:00 -08:00
Nariyasu Heseri b87f3067b5 plugin/battery: bug fix
When `upower --enumerate | grep -i BAT` returns multiple lines of results (which are file paths),
the added quotation (from commit 3cb5f3f7e6) concatenates them all to provide an invalid path.
Thus to make the plugin work as before the commit,
take only the first line of the results.
2022-01-29 03:30:35 +09:00
John D Pell 3cb5f3f7e6 plugin/battery: `shellcheck` 2022-01-25 23:54:24 -08:00
John D Pell a78d72eed1 plugin/projects: refactor a bit 2022-01-18 20:47:08 -08:00
John D Pell ea2002a2e4 plugin/projects: cleanup
I'm deliberately leaving the possibility that one might `pjo` without a project name...
2022-01-18 11:08:51 -08:00
John D Pell 6e480d7a8a plugin/proxy: `shellcheck` && `shfmt`
plugins/proxy: use `_command_exists()`

Alsö, quote variables, handle unbound parameters, &c.
2022-01-09 00:40:49 -08:00
Noah Gorny 1fd601db7f
Merge pull request #2007 from gaelicWizard/plugin-latex
Plugin/LaTeX: 2009 was thirteen years ago
2022-01-09 01:11:41 +02:00
Noah Gorny 21e7c1f00c
Merge pull request #2011 from gaelicWizard/plugin-nginx
plugin/nginx: cleanup
2022-01-09 01:11:06 +02:00
John D Pell 079652e6e7 plugin/nginx: cleanup
Dont overwrite user-set variable, and quote path. Local some variables, `shellcheck`, `shfmt`
2022-01-08 08:44:05 -08:00
John D Pell 2fe9e01051 plugins/latex: 2009 was 12 years ago
Locate the currently installed edition, instead of transpoting us back to undergrad.
2022-01-08 08:43:32 -08:00
John D Pell ce22710e00 plugin/gif: `shfmt`
My apologies to future `git blame` hunters ♥
2022-01-08 08:43:17 -08:00
John D Pell b1b08de626 plugins/gif: use `type -p` 2022-01-08 08:43:00 -08:00
Noah Gorny 931f27ee3e
Merge pull request #2016 from gaelicWizard/plugin/python
plugin/python: OS detection & `shfmt`
2022-01-07 08:50:07 +02:00
Noah Gorny c060eb46ea
Merge pull request #2001 from gaelicWizard/plugin-dirs
Plugin/dirs: use `$XDG_STATE_HOME`
2022-01-07 08:42:24 +02:00
Noah Gorny dba610cdc8
Merge pull request #2009 from gaelicWizard/plugin-man
Plugin/man: Add `R` to `$LESS`
2022-01-07 08:41:41 +02:00
Noah Gorny 5d68fca7e5
Merge pull request #2008 from gaelicWizard/plugin-osx
Plugin/OSX: cleanup
2022-01-07 08:41:17 +02:00
Noah Gorny 48a1ff7fb4
Merge pull request #2005 from gaelicWizard/plugin-todo
Plugin/todo: cleanup and simplify
2022-01-07 08:40:52 +02:00
Noah Gorny 682b51c195
Merge pull request #2015 from gaelicWizard/plugin/git-subrepo
plugin/git-subrepo: use `$HOME` instead of `~`
2022-01-07 08:31:49 +02:00
John D Pell 139baedf5d plugin/python: Pyton 2 is dead; Long Live Python 3! 2022-01-05 13:29:35 -08:00
Noah Gorny f0abc3fbc4
Merge pull request #1998 from tsiflimagas/fzf-plugin
Fix checking whether fzf is already in PATH
2022-01-03 13:33:14 +02:00
John D Pell 29216c0fd4 plugin/python: `shfmt`
My apologies to future `git blame` hunters ♥
2022-01-01 23:00:48 -08:00
John D Pell dd911f1256 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.
2022-01-01 23:00:48 -08:00
John D Pell c030f2108b plugin/git-subrepo: `shellcheck` 2022-01-01 22:48:01 -08:00
John D Pell a99b597217 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`.
2022-01-01 22:32:03 -08:00
John D Pell d6bcedfa96 plugin/base: rewrite `t()` function to use `todo.sh`
Move the test for whether `plugin/todo` is enabled inside the function, and remove the alias from there.

Alsö, respect `$XDG_STATE_HOME` and move the old `~/.t` file if it exists.
2022-01-01 17:50:55 -08:00
John D Pell 02b57a83ef plugins/todo: lint
plugin/base: use `_bash-it-component-item-is-enabled()`
2022-01-01 17:50:55 -08:00