Commit Graph

226 Commits (5fab574bfd4f750371bcec602e4026ede00bd89c)

Author SHA1 Message Date
Noah Gorny c81c9dcc8c
Merge pull request #1865 from NoahGorny/add-profile-subcommand
add profile subcommand
2022-01-03 14:00:39 +02:00
John D Pell 00f5f2a62e Use `_bash-it-egrep()` 2021-10-18 22:08:56 -04:00
John D Pell 253d1213e0 lib/utilities: new function `_bash-it-egrep()`
The existing function `_bash-it-grep()` is weird. New function `_bash-it-egrep()` just does the thing without requiring two subshells and manual invocation.
2021-10-18 09:14:32 -04:00
John D Pell b8ee63c67d lib/utilities: quote SC2295
Doesn't show up on my shellcheck 0.7.2, but does for NoahGorny!
2021-10-18 09:14:32 -04:00
John D Pell b986c39040 lib/utilities: XDG_CACHE_HOME
Use $XDG_CACHE_HOME environment constant instead of placing a tmp/cache folder inside the bash-it data repo. If not defined, fall back to current behavior.

This resolves Bash-It/Bash-It#1904.
2021-10-18 09:14:32 -04:00
John D Pell 7cd02781f8 lib/utilities: `_bash-it-component-help()`
No need to `rm` when we overwrite the file the line after next. Alsö, use `>|` in case the user sets `noclobber`; we do expressly intend to overwrite the file in this case.
2021-10-13 21:13:45 -07:00
John D Pell f7cc442af4 lib/utilities: simplify `_bash-it-array-dedup()`
alsö fix usage example of `_bash-it-array-contains-element()`
2021-10-13 09:28:21 -07:00
Noah Gorny e1017513d0 helpers: Disallow removing the default profile with bash-it profile rm 2021-09-29 00:30:24 +03:00
Noah Gorny 1ae407150c helpers: Improve bash-it profile messages 2021-09-29 00:30:24 +03:00
Noah Gorny 337e188d25 helpers: Add bash-it profile rm 2021-09-29 00:30:24 +03:00
Noah Gorny 81b17f795b helpers: Add bash-it profile list 2021-09-29 00:30:24 +03:00
Noah Gorny 6a923760d8 helpers: Add help message for bash-it profile 2021-09-29 00:30:24 +03:00
Noah Gorny d4ec41bef7 helpers: Add useful log in case of empty config 2021-09-29 00:30:24 +03:00
Noah Gorny cea95d72b3 lib: helpers: Rename _bash-it-process-component to _bash-it-determine-component-status-from-path 2021-09-29 00:30:23 +03:00
Noah Gorny 7f60b73a2a helpers: Add new bash-it profile subcommand 2021-09-29 00:30:23 +03:00
Noah Gorny 41cba9d7e4 helpers: Add enable-plugin and enable-alias aliases 2021-09-29 00:30:23 +03:00
Noah Gorny ffeb770593 helpers: Print type when using disable all 2021-09-29 00:30:23 +03:00
Noah Gorny 6e03a726a6 helpers: Split some processing code out of _bash-it-describe 2021-09-29 00:30:23 +03:00
Noah Gorny 7fb7bb9cb8
Merge pull request #1952 from gaelicWizard/uncle
lib/helpers: new function `_bash-it-find-in-ancestor()`
2021-09-28 16:51:30 +03:00
John D Pell 3eed0f033f
Lint: prepare `lib/utilities` for `shellcheck` (#1933)
* lib/utilities: shellcheck

SC2059

* lib/utilities: fix `_bash-it-get-component-type-from-path()`

Account for plugins with names that contain periods.

* lib/utilities: fix `_bash-it-array-dedup()`

Use fewer subprocesses and newline-delimited not space-delimited.

* lib/utilities: fix `_bash-it-component-list()`

Use fewer subprocesses and return newline-delimited, not space-delimited.

* lib/utilities: fix `_bash-it-component-list-matching()`

Use `sort -u` instead of `sort | uniq`

* lib/utilities: fix `_bash-it-component-list-enabled()`

Use fewer subprocesses, return newline-delimited instead of space-delimited, and use `sort -u` instead of `uniq | sort`

* lib/utilities: fix `_bash-it-component-list-disabled()`

Use fewer subprocesses, return newline-delimited instead of space-delimited, and use `sort -u` instead of `uniq | sort`

* lib/utilities: fix `_bash-it-grep()`

1. Executing `'/usr/bin/grep'` does *not* return the path to grep...
2. use `type -p` instead of external binary `which`.
3. Simplify parameter definition.
4. Why was there a space after `%s`?

* lib/utilities: use `_bash-it-grep`

Alsö, lose a spurious `cat`

* lib/utilities: lint `_bash-it-component-help`

* lib/utilities: lint `_bash-it-component-cache-file()`

* lib/utilities: `shfmt`

My apologies to future `git blame` hunters ♥

* lib/helpers: fix `_bash-it-get-component-name-from-path()`

Use `${BASH_IT_LOAD_PRIORITY_SEPARATOR}`
2021-09-28 15:24:18 +03:00
John D Pell e8966ea2a5 lib/helpers: cite `_bash-it-find-in-ancestor()`
Add `composure.sh` citation with examples and rewrite internal comments to describe the code flow.
2021-09-23 10:00:52 -07:00
John D Pell 0471a20c7c lib/helpers: new function `_bash-it-find-in-ancestor()`
New function to do a search looking for a sibling to a parent of the current directory, for example to find `../../.git` to indicate that `$PWD` is inside a git repository.
2021-09-22 15:30:07 -07:00
John D Pell 8a03f451b2 lib/helpers: simplify `_command_exists()` and `_binary_exists()`
Remove subshell and just use a regular `if`
2021-09-19 21:58:48 -07:00
John D Pell 5fc418e479 Use `${PWD}` instead of `$(pwd)`
Don't subshell when there's a shell parameter for it.
2021-09-18 13:15:13 -07:00
Noah Gorny 0dbf1d593c
Merge pull request #1926 from gaelicWizard/basenamed
Use parameter substitution instead of `dirname`/`basename`, where safe to do so
2021-09-18 18:26:55 +03:00
John D Pell 1c3cbf7ca6
Delete `.shellcheckrc` (#1947)
* CI: disable Ubuntu 16.04 as it's EOL

https://github.blog/changelog/2021-04-29-github-actions-ubuntu-16-04-lts-virtual-environment-will-be-removed-on-september-20-2021/

* main: lint false positive

* install: lint

* plugins/cmd-returned-notify: don't `export`

* plugins/xterm: lint

* plugins/git: lint

* plugins/goenv: lint

* plugins/alias-completion: lint false positives

* plugins/alias-completion: fix SC2155, SC2154

Declare `locals` at the top of the function

* completion: lint completions using `bash_completion` functions

Match the style of the existing code

* completion/knife: lint false positives

* completion/knife: lint

* completion/sdkman: lint

* completion/composer: lint

* Move `.shellcheckrc` under `themes/`

* lib/theme: fix SC2155, SC2154, SC2034

* lib/colors: don't warn on unused variables

We assign a large number of variables here and they may or may not be used anywhere else, so disable SC2034 for this file (only).

Alsö disable SC2005 as the functions in this file were written before `printf` was invented and have to do some fancy metascripting to get escape sequences interpreted reliably. I’m not smart enough to fix this to use `printf`, so leave it for now.

* themes/agnoster: lint

* themes: disable SC2154 for colors

Each one of these themes will need it’s own fix for SC2154, possibly upstream.

Due to the way themes are, it's entirely normal to have a *lot* of false positives for SC2034. So much so, that I have to admit that it is probably just not worth linting for SC2034 despite my dislike of blanket ignore rules.

* themes: disable SC2154, fix SC2155

Each one of these themes will need it’s own fix for SC2154, possibly upstream.

Due to the way themes are, it's entirely normal to have a *lot* of false positives for SC2034. So much so, that I have to admit that it is probably just not worth linting for SC2034 despite my dislike of blanket ignore rules.

* Delete `.shellcheckrc`

* remove executable bit
2021-09-18 12:50:59 +03:00
John D Pell 470341b23a Drop `basename` in favor of Bash strings
Convert `var=$(basename $file)` to `var="${file##*/}"`
2021-09-16 16:59:02 -07:00
John D Pell dee55a03cc drop `dirname` in favor of native Bash strings (1 of 2)
Convert `var=${dirname $filename)` to `var="${filename%/*}` in cases where there is no ambiguity.

Make sure that the path in `$BASH_IT` is absolute because this path gets embedded in the template `.bash_profile` file if selected by the user.
2021-09-16 16:59:02 -07:00
John D Pell 85408743fa lib/log: default to no logging at all
Set the default when BASH_IT_LOG_LEVEL is unbound to log level none: no warnings or errors are reported at all.
2021-08-26 14:11:41 -07:00
John D Pell bd9f4015a7 lib/helpers: handle unset parameter
Expressly handle $BASH_IT_REMOTE as blank when variable is not set.
2021-08-26 14:11:41 -07:00
John D Pell 8fb75cf0e3 lib/helpers: handle unbound parameter
Expressly handle $BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE being not-set as being blank.
2021-08-26 14:11:41 -07:00
John D Pell 0eff44930c lib/utilities: handle unbound parameter
Expressly handle unbound $BASH_IT_GREP when testing for value
2021-08-26 14:11:41 -07:00
John D Pell 233fcc3091 lib/log: handle undefined variable
Expressly deal with if $echo_yellow hasn’t been defined
2021-08-26 14:11:41 -07:00
John D Pell bcd67db4ab lib/preview: handle unbound parameter
If $BASH_PREVIEW is unset, treat it as blank.
2021-08-26 14:11:41 -07:00
John D Pell 02c13b7921 lib/log: handle undefined variables
If the user hasn't defined BASH_IT_LOG_LEVEL, then the integer comparison fails. Handle it by defaulting to '1'.
If lib/log is loaded improperly, the BASH_IT_LOG_PREFIX may be undefined. Unlikely, but no harm in handling it too.
Likewise, if no theme is loaded, then $echo_green, $echo_normal, et al are not defined.
2021-08-26 14:11:41 -07:00
John D Pell 0f28824ad5 lib/helpers: invert test in _bash_it_homebrew_check()
Check if `brew` is installed every time, and *unset* `$BASH_IT_HOMEBREW_PREFIX` if not found. This accounts for the edge-case of a user _uninstalling_ Homebrew without restarting the shell.
2021-08-22 12:48:48 -07:00
John D Pell 9e255c2139 lib/helpers: new function to set BASH_IT_HOMEBREW_PREFIX
New function `_bash_it_homebrew_check()` sets global variable `$BASH_IT_HOMEBREW_PREFIX` using `brew --prefix` if `brew` exists as a valid command. If `brew` isn't installed, then return failure.

Plugins can test for `brew` by calling this function and, if it succeeds, they can rely on `$BASH_IT_HOMEBREW_PREFIX` being defined properly.
2021-08-22 12:48:48 -07:00
Noah Gorny 9566a3ec18 helpers: Improve pull_and_update_inner by restoring old pwd
Renamed the function to _bash-it_update_migrate_and_restart
Use pushd/popd instead of passing another parameter
Document the function so it will be clear that it does not return
2021-08-18 00:29:45 +03:00
Noah Gorny caec973c18 helpers: Pop pwd correctly when not needing to update 2021-08-17 23:50:58 +03:00
John D Pell de9ea54b81
Don't call external `uname` when `$OSTYPE` will do (#1911)
* lib/helpers: use `$OSTYPE` instead of `$(uname)`

* plugins/osx: use `$OSTYPE` instead of `$(uname)`

* plugins/boot2docker: use `$OSTYPE` instead of `$(uname)`

* plugins/python: use `$OSTYPE` instead of `$(uname)`

* plugins/base: use `$OSTYPE` instead of `$(uname)`

Alsö, use `[[` instead of `[` as the former has less insane argument handling being shell syntax rather than a builtin command that must emulate being a real binary

* completion/brew: use `$OSTYPE` instead of `$(uname)`

* completion/git: use `$OSTYPE` instead of `$(uname)`

Alsö, use `[[` instead of `[`.

* completion/fabric: use `$OSTYPE` instead of `uname`

* theme/demula: use `$OSTYPE` instead of `$(uname)`

* theme/rana: use `$OSTYPE` instead of `$(uname)`
2021-08-14 10:20:12 +03:00
Gurkirat Singh e51fe1fe2b
Abort upgrade if unsaved changes found in bashit directory (#1890)
helper (improvement): added safeguard for unsaved changes
2021-06-23 13:25:42 +03:00
Gurkirat Singh 01b916c544 helpers (bugfix): restart bashit after upgrade 2021-06-11 12:41:28 +05:30
Noah Gorny 7b5f758eba helpers: Fix broken compoure references after vendor change 2021-03-21 21:52:47 +02:00
buhl 49d7d2e8c4 Getting Bash-it to use the vendored composure
Fixed tests
Fixed install.sh and bash_it.sh
Added gitattributes to the vendor folder
Changed documentation
2021-02-02 16:34:04 +01:00
Noah Gorny 2b66100c47 helpers: Add _completion_exists helper 2021-01-28 17:40:20 +02:00
buhl 29855ed1e6 Adding preexec as a vendored library
Added a vendored lib loading routine in bash-it.sh
Added documentation on how to vendor libs in bash-it
Added and fixed plugins using preexec
Added tests for two plugins
Removed the old preexec lib
2021-01-23 18:31:18 +01:00
cornfeedhobo 61f727fb96
refactor all history modifications into discrete plugins 2021-01-15 11:53:28 -06:00
Noah Gorny 6914a2345a version: Fix url in case it is ssh based one 2020-12-21 00:30:56 +02:00
Noah Gorny e023d6f851 Improve bash-it version output
As we now have "stable" releases and "dev" type of versions, `version` command should
provide usefull output on that
2020-10-27 20:01:50 +02:00
Noah Gorny 825fc88a8f Rename _bash-it_update to _bash-it-update 2020-10-25 15:24:19 +02:00