Commit Graph

175 Commits (135d480c7da93443e6ac1354e6554e76e70a233b)

Author SHA1 Message Date
John D Pell df87b41635 lib/theme: use `_command_exists()` in `rbenv_version_prompt()` 2022-03-03 22:54:09 -08:00
John D Pell 7762aa687a lib/theme: `local hg_root` in `hg_prompt_vars()` 2022-03-03 22:54:09 -08:00
John D Pell c9efc161ff lib/theme: improve performance of `scm()`
- Don't invoke the source control utility when all we want to know is if we're somewhere inside the repository; use `_bash-it-find-in-ancestor()`.
2022-03-03 22:54:09 -08:00
John D Pell d86a182b6e lib/theme: export `$LS_COLORS` et al 2022-03-03 22:54:09 -08:00
John D Pell c6ac9109d7 lib/theme: parameter cleanup
Improve handling of parameters by adding defaults (often blank).

Alsö, eliminate newlines from `echo` in many places.
2022-03-03 22:54:09 -08:00
John D Pell 2b3af0d8c9 lib/theme: eliminate a lot of subshells
A lot of useless `echo`s in here.
2022-03-03 22:54:09 -08:00
John D Pell 1d73537dbf lib/theme: `shfmt` && `shellcheck`
My apologies to future `git blame` hunters ♥

Use the "short" host name by default (`\h`), not the fully qualified domain name (`\H`)...

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.

Don't run `date` for `$THEME_TIME_FORMAT`, use `\D{fmt}`.
2022-03-03 22:54:09 -08:00
John D Pell 0e0e0d3035 lib/theme: Fix a *few* SC2154
These variables are referenced by themes already linted.
2022-03-03 22:53:13 -08: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 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 21942f6275 lib/theme: disable THEME_CHECK_SUDO
Move `$THEME_CHECK_SUDO` to `lib/them`, and set it to `false` instead of `true`.
2022-01-24 11:46:16 -08:00
John D Pell bdaf29f84c Create lib finalize hook
Create an array `_bash_it_library_finalize_hook` and loop at the end of the main `bash_it.sh` to run each element in the array.

The purpose here is to run some command after everything else has been loaded. For example, the appearance lib checks for executables for SCM commands, but `$PATH` may be altered after appearance has loaded and therefore some available commands may never be discovered. Therefore, create `_bash_it_appearance_scm_init()` and add it to the hook. It will re-check at end of `bash_it.sh` just before prompt is first displayed.
2022-01-09 00:46:51 -08:00
John D Pell eabdf41b83 lib/theme: use `_command_exists` 2021-09-19 21:58:48 -07: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 476fcb4325 lib/theme: new `_bash_it_appearance_scm_init()`
Wrap init code in a function and call the function immediately. Several plugins do this, and it allows us to more easily implement a hooks-based system in the future.

Alsö, 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.
2021-09-11 10:22:17 -07:00
John D Pell 9c1dbbcf12 lib/scmhelpers: reorder SCM detection waterfall
This reduces the need to invoke subprocesses
2021-09-11 00:02:27 -07:00
John D Pell 8c0860588d themes/base: don't invoke svn if possible
If we are specifically in the situation #1612, then check for a working `svn` command. If we're not in that situation, then don't waste time on it.
2021-09-11 00:02:27 -07: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
ofir shtrull 2444a57cc5
feat: add k8s namespace indicator (#1887)
* Add k8s namespace to prompt
2021-06-10 16:04:56 +03:00
Noah Gorny 2ae0350f5d themes: base: Add unified scm_prompt function 2021-05-16 19:17:02 +03:00
Oliver Ruben Albertini 26118d1835 [base.theme] add support for hg's bookmarks feature
Will conditionally show the branch based on the current bookmark instead
of branch.
2021-04-27 11:36:14 -07:00
Ofir Shtrull 8ae2b1e73d fix typo 2021-03-11 18:32:10 +02:00
Ofir Shtrull ffc1701c0a Add to prompt google gcloud active account 2021-03-11 18:25:23 +02:00
Noah Gorny d2ab59fef8 Disable keep-padding option in shfmt
Has some serious bugs and not really needed
Also fixed all files that need to be changed after this
2021-01-21 22:08:45 +02:00
BarbUk 814ff562e9
Fix rbenv version prompt 2021-01-16 09:25:12 +01:00
Marcos Pereira 94d261b42d
Fix shellcheck warnings for themes/base.theme.bash 2021-01-12 00:55:15 -05:00
Marcos Pereira 5a761b7ae3
Run code fomatter for themes/base.theme.bash 2021-01-11 15:14:49 -05:00
Oliver Ruben Albertini ba02955340 hg SCM_CHANGE: prevent hexdump squeezing
hexdump by default will replace any repeated groups with an asterisk and
a newline, which breaks prompts. This can be disabled with the `-v`
flag. For example:

```
printf 'aac' | hexdump -e '1/1 "%02x"'
61*
63
printf 'abc' | hexdump -e '1/1 "%02x"'
616263
printf 'aac' | hexdump -ve '1/1 "%02x"'
616163
```
2020-09-12 09:58:37 -07:00
Noah Gorny 3eac73f613 plugins: Rename gitstatusd plugin to gitstatus 2020-06-22 14:57:05 +03:00
Noah Gorny 5d14030591 plugins: Add gitstatud plugin 2020-06-22 14:55:25 +03:00
Noah Gorny fb2e8549ad themes: Tidy base.theme and remove uneeded changes 2020-06-19 21:50:21 +03:00
Markus Krause feae99431a implement feedback 2020-06-19 19:45:59 +03:00
Markus Krause 83fdc89ec1 implement gitstatusd support 2020-06-19 19:45:58 +03:00
Nils Winkler 47512a1624
Checking for SVN return code 2020-06-14 19:31:25 +02:00
Nils Winkler 2ba3797da6
Added check for SVN not available 2020-06-09 14:07:17 +02:00
Nils Winkler caced3b65f
Using $() instead of backticks to make shellcheck happy 2020-06-09 14:07:17 +02:00
buhl 3bfec8e682 Removed empty VIRTUAL_ENV declaration in the base theme 2020-05-13 22:01:20 +02:00
buhl ad9876e6e3 Removed initialization of empty VIRTUAL_ENV
When spawning a new bash session when entering a virtual environment
the VIRTUAL_ENV is overwritten by this line.
However not having this line does not affect the bin/activate script.
2020-05-09 12:13:11 +02:00
salex 21885dabb4 add THEME_SHOW_RUBY_PROMPT. 2020-03-20 19:25:45 +08:00
salex fd162c0786 add RUBY_VERSION_PROMPT_DISABLED parameter for PS1 prompt. 2020-03-20 09:44:06 +08:00
Ofir Shtrull 936a79f619 now usable by all prompts 2020-02-27 20:53:35 +02:00
Eduardo Bellido Bellido a6e912854a Show NodeJS version in Powerline themes (#1438)
Currently, only nvm is supported.
2019-12-02 08:36:57 +01:00
Nils Winkler 721412aa4c
Merge pull request #1395 from zhao-li/toggle-able_commit_count
Toggle able commit count
2019-09-02 08:45:19 +02:00
Eduardo Bart 4c0a51aee2 Optimize SCM checks 2019-07-23 12:50:27 -03:00
Zhao Li 62757b0f3f allow the count information to be turned on or off 2019-07-08 10:52:44 -10:00
Nils Winkler 6329d3bdd2
Merge pull request #1379 from leventyalcin/feature/save_history_immediately
add an env var that themes can save history immediately
2019-07-08 08:47:09 +02:00
Nils Winkler 498f3b41f2
Merge pull request #1389 from martinus/master
Improved subversion support for powerline
2019-07-08 08:41:06 +02:00
Nils Winkler 943e887415
Merge pull request #1387 from zhao-li/feature/customizable_git_ahead_behind_prefix
allow customizing the character before ahead and behind characters
2019-07-08 08:37:12 +02:00
Martin Ankerl 0bafdbbef9 faster subversion status
Stop as soon as "svn status" shows a change, not needed to walk through
all the changes in the whole repository. For my large repository this is
about twice as fast.

Extract just the information we need from "svn info"
2019-06-24 11:28:53 +02:00
Martin Ankerl e42405705a Improved subversion support for powerline
SVN prompt also when in subdirectories that don't contain .svn
Show correct SVN status for powerline
2019-06-24 11:02:15 +02:00