Commit Graph

3400 Commits (1a96dd1947587d521049d0e8a188bcff1c6eee99)

Author SHA1 Message Date
John D Pell 1a96dd1947 lib/theme: use `_command_exists()` 2022-02-23 16:02:02 -08:00
Konstantin Gredeskoul b935ddd309
`node_version_prompt` should work without NVM
Adding `node` prompt that does not depend on `nvm` and will work with other version managers as well.

There are now alternative version managers available, such as a much more streamlined [volta.sh](https://volta.sh).  It feels like a deja-vu of `rvm` to `rbenv` switch, all over again.

Regardless, we should be able to show the current `node` version whether you are using NVM, VOLTA or a hot potato.

I decided not to add dedicated PREFIX variables for now, but it can be done later.

We still check if `nvm` prompt returns something first because the `declare` check is practically free, and if it returns something — we use it. Only if the output of NVM is blank do we use the new function to grab the version of NodeJS.

There is a caveat — if `node` is installed with the OS, eg `/usr/bin/node` the new function will now pick up the version of that "system" node and show it. Therefore "system" node version will now be visible in the prompt of those who added `node` component to their prompt. Personally, I believe this is the correct behavior, because why should we hide the system node version if that's what's available and in the PATH? We shouldn't.  In fact, I think it's rather confusing that previously we wouldn't show the system node version at all.

Tested locally on OS-X/bash:

    * with/without NVM
    * with/without VOLTA
    * with/without system node
2021-09-13 00:27:41 -07:00
Noah Gorny 99eab7a76c
Merge pull request #1936 from NoahGorny/fix-shellcheck-warnings
plugins: Fix shellcheck warnings on already linted files
2021-09-12 08:13:44 +03:00
Noah Gorny f0690c09fb
Merge pull request #1939 from Bash-it/revert-1767-disable-macos-11
Reinstate macOS 11 job
2021-09-11 16:43:36 +03:00
Noah Gorny ec3b8d645f
Revert "ci: Remove macos-11.0 as it is unreliable" 2021-09-10 16:54:51 +03:00
Noah Gorny c6f6d8c27a plugins: Fix shellcheck warnings on already linted files 2021-09-09 20:57:03 +03:00
Noah Gorny 9ea60020ae
Merge pull request #1915 from gaelicWizard/bash_completion
Support multiple versions of _Bash Completion_
2021-09-07 10:12:12 +03:00
John D Pell feacd560b6 completion/system: update wording on shell version 2021-09-05 15:43:05 -07:00
John D Pell ecfcaba32e 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.
2021-09-05 15:43:05 -07:00
Noah Gorny 5782325dea
Merge pull request #1903 from gaelicWizard/unbound
Gracefully handle unbound parameters
2021-08-31 20:16:26 +03: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 3654198deb Tests for 'default' prefix 2021-08-26 14:11:41 -07:00
John D Pell 0c412442f5 completion/system: give up hope
Give up and accept defeat that bash-completion can't reasonably be audited for unbound parameters. Wrap invocation with disabling strictness, and restore after if it was enabled.
2021-08-26 14:11:41 -07:00
John D Pell cd65e0925f plugins/base: unbound BASH_IT_LEGACY_PASS
Expressly handle as blank when $BASH_IT_LEGACY_PASS is not set.
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 f71fa5be2c Handle unbound variables
Handle BASH_IT, BASH_IT_OLD_BASH_SETUP, BASH_IT_THEME, BASH_THEME, and PROMPT.
2021-08-26 14:11:41 -07:00
John D Pell 5001995e92 Deal with unabound BASH_IT_RELOAD_LEGACY 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
Noah Gorny 8b3867fe35
Merge pull request #1910 from gaelicWizard/brew
lib/helpers: new function to set BASH_IT_HOMEBREW_PREFIX
2021-08-26 22:17:57 +03: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 65ef8e2e8b Use _bash_it_homebrew_check() in plugins, completions
Use new function `_bash_it_homebrew_check()` in existing plugins and completions which look for Homebrew.

Alsö, use `$OSTYPE` instead of calling external `uname` binary.
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 226454b069
Merge pull request #1921 from NoahGorny/fix-update-not-popping-back-cwd
fix update not popping back cwd
2021-08-18 21:17:11 +03: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
Noah Gorny 9cc36de58e
Merge pull request #1918 from NoahGorny/fix-defaults-completion
defaults: Revert to old comparison
2021-08-17 23:36:19 +03:00
Noah Gorny 67eff71d72 defaults: Revert to old comparison
Also fix a small bug along the way :)
2021-08-15 21:28:00 +03:00
Noah Gorny 907fa1de96
Merge pull request #1916 from gaelicWizard/EditorConfig
Don't set `indent_size` when using tabs
2021-08-15 21:04:51 +03:00
John D Pell 6ee4cb4597 EditorConfig: don't specify indent size
When using tabs, `indent_size` should be set to `tab`, which is the default. Furthermore, `tab_width` (which is likely what was intended when `indent_size` was entered) should be left up to the user. If the user likes an 8-character indent, then let them. If they like 2-character indent size, then let them. Using tabs means that this all works normally for everyone, even if it's different on different screens.
2021-08-14 20:14:01 -07: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
Noah Gorny e321a3d657
Merge pull request #1913 from Bash-it/ksuther/master
Fixed defaults autocompletion.
2021-08-12 00:35:13 +03:00
Kent Sutherland a6d58351e7 Fixed defaults autocompletion.
Need to use grep WITHOUT case-sensitivity. Otherwise results such as com.apple.iChat and com.apple.imagent won't be handled correctly and neither one can be completed.
Fixed another comparison that prevented "defaults read com.apple.iChat <complete>" from correctly returning the available defaults keys in that file.
2021-08-12 00:15:18 +03:00
Noah Gorny 0fb9d0c090
Merge pull request #1908 from gaelicWizard/bash_completion
Import bash-completion slightly more carefully
2021-08-12 00:11:47 +03:00
John D Pell 893c8dbb96 completion/system: support $BASH_COMPLETION
Bash-completion supports pre-defining $BASH_COMPLETION as the path to the main script, so use that if it's defined.

Alsö, don't load homebrew's completion if we've successfully loaded one already.
2021-08-08 23:08:39 -04:00
John D Pell 43947e2cbc completion/system: prefer direct invocation
Instead of using the profile.d version, just invoke the script. The profile.d script preemptively short-circuits if it thinks that bash-completions has already been loaded, which it does by using the $BASH_COMPLETION variable, which is expressly supported by upstream to specify the location of the script...so it will entirely be never loaded if this is set.
2021-08-08 23:08:39 -04:00
Noah Gorny 9ea290a5ed
Merge pull request #1852 from tbhaxor/feature/completion/dart
Added completion for dart cli
2021-08-03 23:58:16 +03:00
Noah Gorny e89403d59b
Merge pull request #1881 from NoahGorny/lint-pure-theme
Refactor scm_prompt usage in many themes
2021-08-03 23:22:09 +03:00
cornfeedhobo e13f7d1b07
Merge pull request #1901 from cornfeedhobo/libera-chat
move to Libera.Chat
2021-07-11 11:30:21 -05:00
cornfeedhobo aad58bc910
move to Libera.Chat 2021-07-06 22:21:46 -05:00
Ron Green d4ebba174c
feat(git): add git unpushed alias (#1897)
* feat(git): add git unpushed alias
2021-06-23 15:02:04 +03:00
Zhengnan Zhao 0f3e4dc8be
Have git check out main branch if present (#1886)
Create function to get default git branch, and use main branch if present
2021-06-23 13:26:48 +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
Noah Gorny d979c32c8a
Merge pull request #1891 from tbhaxor/bugfix/helper/upgrade
Replace reload with restart bash it after upgrade
2021-06-23 13:24:49 +03:00
Noah Gorny f6e3fc358c
Merge pull request #1898 from tbhaxor/bugfix/lint/wpscan
FIxed wpscan completion linting
2021-06-23 13:22:25 +03:00
Noah Gorny e70211549f
Merge pull request #1899 from georgettica/georgettica/bump-pre-commit-hooks
chore(pre-commit): bump version
2021-06-23 13:21:06 +03:00
Ron Green a3f5b5f29a chore(pre-commit): bump version
done in the beginning because of build issues, but was solved during the work on #1897
2021-06-17 10:37:19 +03:00