143 Commits

Author SHA1 Message Date
Noah Gorny
5487963fa7 Merge pull request #1752 from Bash-it/add-license-1
Add LICENSE
2020-12-29 22:41:34 +02:00
Noah Gorny
0565c3aa8e Merge pull request #1741 from NoahGorny/licensing
Clean up embedded licensing issues
2020-12-29 22:40:58 +02:00
Noah Gorny
8e73b538ea Deprecate homesick completion as it is unlicensed 2020-12-29 21:49:47 +02:00
Noah Gorny
012552d8b7 Deprecate drush completion as it is GPLv2 2020-12-29 21:49:47 +02:00
Noah Gorny
a369cc7c0a Deprecate virsh completion as it is GPLv2 2020-12-29 21:49:47 +02:00
Noah Gorny
cd44880c15 Deprecate todo completion scripts as it is GPLv3 2020-12-29 21:49:47 +02:00
Noah Gorny
292da7ef77 Add license notice to jboss7 completion 2020-12-29 21:49:47 +02:00
Noah Gorny
59439c2f62 Add license notice to docker-machine/compose completion 2020-12-29 21:49:47 +02:00
Noah Gorny
8cc7327c0b Add license notice to salt completion 2020-12-29 21:49:47 +02:00
Noah Gorny
5188b3b0c0 Add license notice to gulp and grunt completion 2020-12-29 21:49:47 +02:00
Noah Gorny
334005ead3 Clean up vault completion and add to clean_files.txt 2020-12-29 21:49:42 +02:00
Noah Gorny
6eb5802080 Add license notice to hub completion 2020-12-29 21:49:10 +02:00
Noah Gorny
3ba1a14eb9 Remove broken link from tmux completion 2020-12-29 21:49:10 +02:00
Noah Gorny
f4f229573d Clean up packer completion and add to clean_files.txt 2020-12-29 21:49:10 +02:00
Noah Gorny
6a69931240 Add license to invoke completion 2020-12-29 21:49:10 +02:00
Noah Gorny
f221cdca9e Clarify license on bundler completion 2020-12-29 21:49:10 +02:00
Noah Gorny
17211b0b1a Add license to apm completion script 2020-12-29 21:49:10 +02:00
Noah Gorny
2329b4395b Add license notice to gradle completion 2020-12-29 21:49:10 +02:00
Noah Gorny
3a2ccd3792 Add license notice to django completion 2020-12-29 21:49:10 +02:00
Noah Gorny
1d4b325ce9 Merge pull request #1734 from georgettica/patch-2
feat(vim-alias): add full screen help
2020-12-28 21:39:43 +02:00
Noah Gorny
a1da0087a1 Merge pull request #1748 from NoahGorny/fix-git-url-in-bashit-version
version: Fix url in case it is ssh based one
2020-12-28 21:35:53 +02:00
Ron Green
d6e2b04708 fix(vim-aliases): join '$VIM' statements 2020-12-28 10:58:09 +02:00
Noah Gorny
908fed9f50 Merge pull request #1738 from NoahGorny/fix-1354
Use command rm in alias_completion
2020-12-27 19:11:11 +02:00
BarbUk
13e795c995 add command time duration plugin (#1683) 2020-12-27 18:48:17 +02:00
Ron Green
e94b9420ac fix(vim-aliases): make alias dependant on envvar 2020-12-27 18:05:11 +02:00
Russell
b119540ce7 Add comment to install "t" and disable "todo.plugin" (#1742)
This commit is intended to help new uses of the
modern-t theme get it set up properly
and avoid the "todo.plugin" breaking it

Please see the following issues for details.
https://github.com/Bash-it/bash-it/issues/1693
https://github.com/Bash-it/bash-it/issues/1374

Co-authored-by: Russell Adams <russell.adams@avast.com>
2020-12-27 17:24:52 +02:00
Noah Gorny
d2a5524556 Add LICENSE
Woohoo!  
What a time to be alive 😄
2020-12-27 17:17:51 +02:00
Terminal for Life
921ea9ac76 Optimizations to reloader.bash (#1749)
* Optimized statement with REGEX by using `case`

REGEX is a great feature of BASH, but in this case it was energy
needlessly spent. A `case` statement suffices. Bring in REGEX when
you're going to make good use of it, otherwise it's just going to bog
down your code.

I also wanted to strip the ` || exit 1` on the last line, but I wasn't
sure if this file is meant to be sourced or not; if not, then exiting
like that is redundant because it will already exit with whichever
status the last command provides, unless `popd` specifically offers
unhelpful or no exit statuses.

* Optimize as before but with 2nd REGEX instance

This time is much like the last commit, so I won't repeat, but I will
say that you're using a double- or even triple-negative, which
obfuscates your goal. Where you were doing...

[ ! -n VAR ] &&

You were basically saying this convolution:

If it's true that it's not true that VAR is not empty.

Very confusing. Instead, I've opted for:

If it's true that Var is empty.

Makes immediate sense and is easier to parse, visually speaking.
2020-12-27 17:14:50 +02:00
Noah Gorny
b19c2b969f test: Change alias-completion completion file to capistrano 2020-12-27 17:12:22 +02:00
Ron Green
d74cc615be feat(lint): lint vim.aliases 2020-12-23 10:19:06 +02:00
Noah Gorny
5aa2612ff1 Merge pull request #1746 from NoahGorny/add-lint-clean-files-instructions
add lint clean files instructions
2020-12-21 00:31:22 +02:00
Noah Gorny
6914a2345a version: Fix url in case it is ssh based one 2020-12-21 00:30:56 +02:00
Noah Gorny
8bc83b2d48 docs: Add lint_clean_files instructions 2020-12-20 23:29:01 +02:00
Noah Gorny
9ca6841e20 docs: Add sphinx-emoji support 2020-12-20 23:29:01 +02:00
Noah Gorny
e1372dd5bd Merge pull request #1747 from NoahGorny/add-easy-installation-docs
docs: Add simple installation instructions to readme
2020-12-18 17:15:33 +02:00
Noah Gorny
7edc26f408 Merge pull request #1727 from NoahGorny/add-issue-and-pr-templates
github: Add pr template
2020-12-18 11:48:02 +02:00
Noah Gorny
d00c478ded Merge pull request #1740 from Bash-it/NoahGorny-patch-2
Add bug+feature issue templates
2020-12-18 11:47:11 +02:00
Noah Gorny
13be44ab19 Merge pull request #1735 from NoahGorny/docs-more-improvements
docs more improvements
2020-12-17 19:10:15 +02:00
Noah Gorny
181863af1d docs: Add simple installation instructions to readme
This will help newcomers, and not confuse them by redirecting them to
another site instantly.
2020-12-17 01:42:25 +02:00
Noah Gorny
859038e58f Allow trailing spaces in md/rst files 2020-12-17 01:42:25 +02:00
Noah Gorny
501b1ab3b5 Merge pull request #1730 from NoahGorny/fix-1037
Disable auto-reload in install.sh
2020-12-16 20:08:06 +02:00
Noah Gorny
89787cf261 github: Add pr template 2020-12-16 19:46:23 +02:00
Noah Gorny
2b4a81f39c Add bug+feature issue templates 2020-12-16 19:12:54 +02:00
Ron Green
5eb023cf51 Update vim.aliases.bash 2020-12-15 22:46:47 +02:00
Noah Gorny
6008006783 Merge pull request #1736 from NoahGorny/add-irc-badge
readme: Change join chat to IRC from gitter
2020-12-14 03:41:46 +02:00
Noah Gorny
f10834275f Merge pull request #1737 from NoahGorny/add-main-page-to-readme
docs: Add readthedocs main page to readme
2020-12-14 03:40:54 +02:00
Noah Gorny
1c05d71819 alias-completion: Use 'command rm' instead of rm to avoid aliases 2020-12-14 01:25:58 +02:00
Noah Gorny
f5753e4416 test: Add test for aliases rm for alias_completion 2020-12-14 01:21:00 +02:00
Noah Gorny
654a49cbd8 docs: Add readthedocs main page to readme 2020-12-14 00:49:26 +02:00
Noah Gorny
b5fecb3eb3 readme: Add docs status badge 2020-12-14 00:47:32 +02:00
Noah Gorny
0d7f145ef4 readme: Change join chat to IRC from gitter 2020-12-14 00:28:57 +02:00
Noah Gorny
dca563e606 docs: misc: Move help_screens and proxy_support into seperate pages 2020-12-14 00:14:23 +02:00
Noah Gorny
cf2df9e896 docs: Restructure sentence about adding screenshots 2020-12-14 00:05:17 +02:00
Noah Gorny
28e4633e53 Merge pull request #1721 from NoahGorny/docs-remove-themes-readmes
docs: Remove themes readmes
2020-12-14 00:01:30 +02:00
Noah Gorny
1ab755360d Merge pull request #1704 from NoahGorny/docs-migrate-themes
Docs migrate themes
2020-12-13 23:58:45 +02:00
Noah Gorny
e7d5107007 docs: Improve contributing add-screenshot instructions 2020-12-13 23:50:27 +02:00
Noah Gorny
60c8b4be9f docs: Move powerline theme docs into powerline-base.rst 2020-12-13 23:50:27 +02:00
Noah Gorny
d3d9a79f1e docs: Update contributing theme guidelines 2020-12-13 23:50:27 +02:00
Noah Gorny
bced06994b Move theme documentation to be under docs/themes-list 2020-12-13 23:50:26 +02:00
Noah Gorny
d89651dc8d Merge pull request #1703 from NoahGorny/docs-migrating-wiki
Migrate wiki docs to rtd format
2020-12-13 23:48:19 +02:00
Noah Gorny
7b21a76c6a docs: themes-list: Use gh-pages instead of wiki
Also note that its only most of the themes, not all of them
2020-12-13 23:15:06 +02:00
Ron Green
4dfd8bcc42 feat(git-aliases): add checkout with username (fixes #1712) (#1732)
* feat(git-aliases): add checkout with username

this can be useful for creating a branch with a common prefix

* fix(git-alais): change quotes
2020-12-13 22:58:01 +02:00
Ron Green
a1760af43b feat(vim-alias): add full screen help 2020-12-12 12:51:16 +02:00
egvimo
3019dc331d Add option to append template to existing config (#1723)
* Add option to append template to existing config

* Add test for append-to-config option

Co-authored-by: Egor Moor <egor.moor@edag-ps.com>
2020-12-11 16:32:23 +02:00
Noah Gorny
9b837b4f59 Merge pull request #1708 from seefood/ira/fix-knife-load
Fix knife completion load time (and pre-commit compliance)
2020-12-09 08:44:33 +02:00
Noah Gorny
b4e515f19b Merge pull request #1726 from NoahGorny/delete-travis-settings
ci: Delete travis settings as they no longer support OSS
2020-12-09 08:42:33 +02:00
Noah Gorny
0e6f10f489 docs: Add github action CI badge 2020-12-07 21:38:35 +02:00
Ira Abramov
5a85126241 complete cleanup of the knife completion file 2020-12-07 18:06:27 +02:00
Ira Abramov
6bcabb1503 Merge branch 'master' into ira/fix-knife-load
* master:
  github: Add no-response bot
  Update contribution.rst
  Add cargo completion
  Add completion for pipx. (#1719)
  Add github action to replace travis
  Address some comments.
  Add in_toolbox prompt to powerline themes
  Update atomic.theme.bash
  Add rustup completion to clean_files.txt
  Add rustup completion
  Move README to be under docs/
  docs: Transition md files to support new rtd format
  pre-commit: Exclude docs _build folder
  Add aliases for GIT-SVN (rebase and dcommit)
2020-12-07 17:33:54 +02:00
Noah Gorny
9904857132 Merge pull request #1728 from Bash-it/NoahGorny-patch-1
Update contribution.rst
2020-12-07 09:32:52 +02:00
Noah Gorny
18365035a9 Merge pull request #162 from willybarro/449d6d4fe1d969a5d60ae71db1440221304dfa48
Add aliases for GIT-SVN (rebase and dcommit)
2020-12-07 02:00:31 +02:00
Noah Gorny
b444ac4e54 Merge pull request #1729 from NoahGorny/add-no-reponse-bot
github: Add no-response bot
2020-12-07 01:13:11 +02:00
Noah Gorny
0e904abd0d github: Add no-response bot 2020-12-07 00:50:42 +02:00
Noah Gorny
e873252227 Disable auto-reload in install.sh 2020-12-06 23:55:25 +02:00
Noah Gorny
7dcf4dd186 Update contribution.rst
Now includes relevant change about `clean_files.txt` and improves the part about our coding style
2020-12-06 23:02:16 +02:00
Noah Gorny
7f1aa107d8 ci: Delete travis settings as they no longer support OSS
Very sad indeed
2020-12-06 21:43:59 +02:00
Noah Gorny
d448ea8cf1 Merge pull request #1722 from NoahGorny/migrate-to-github-actions
migrate to github actions
2020-12-06 18:55:27 +02:00
Noah Gorny
d5c2fdc672 Merge pull request #1725 from NariyasuHeseri/cargo-completion
Add cargo completion
2020-12-06 09:28:18 +02:00
Nariyasu Heseri
4d51bfcaf4 Add cargo completion 2020-12-06 15:22:36 +09:00
NariyasuHeseri
4a5ea95e2e Add completion for pipx. (#1719)
* Add completion for pipx.

* Add pipx  completion to clean_files.txt.

* Format pipx.completion.bash to match the project's coding style.

* Format pipx.completion.bash with ./lint_clean_files.sh.
2020-12-05 18:33:50 +02:00
Noah Gorny
8198fafbd9 Add github action to replace travis 2020-12-05 11:28:29 +02:00
Noah Gorny
1702e0217a docs: Remove themes readmes 2020-12-04 17:24:26 +02:00
Noah Gorny
d9364ced7a Merge pull request #1692 from NoahGorny/docs-modify-md-files
docs: Transition md files to support new rtd format
2020-12-04 16:33:09 +02:00
Noah Gorny
929321ad0a Merge pull request #1716 from likan999/in_toolbox
Add in_toolbox prompt to powerline themes
2020-12-03 21:33:55 +02:00
Kan Li
c13850faa2 Address some comments. 2020-11-28 19:07:10 -08:00
Kan Li
8ce9d8daa5 Add in_toolbox prompt to powerline themes
[Toolbox](https://github.com/containers/toolbox) is an containerized
development environment. This commit adds a promot to powerline when it
is running inside a toolbox.
2020-11-28 12:18:13 -08:00
Noah Gorny
13deafbb1b Merge pull request #1715 from lfelipe1501/patch-2
Update atomic.theme.bash
2020-11-26 19:13:04 +02:00
Luis Felipe Sánchez
794f0e321e Update atomic.theme.bash
fixed the space error after hiding the scm
2020-11-26 09:11:08 -05:00
Noah Gorny
63ad4897ef Merge pull request #1711 from NoahGorny/rustup-completion
Add rustup completion
2020-11-20 16:23:58 +02:00
Noah Gorny
b70da511f2 Add rustup completion to clean_files.txt 2020-11-20 13:01:41 +02:00
Noah Gorny
06b1ffecc0 Add rustup completion 2020-11-20 13:01:25 +02:00
Noah Gorny
bd8b8bb21e Merge pull request #1705 from NoahGorny/exclude-build-directory-pre-commit
pre-commit: Exclude docs _build folder
2020-11-14 00:12:49 +02:00
Ira Abramov
d84d6a8356 Add a credit comment 2020-11-08 18:48:29 +02:00
Ira Abramov
f5fe3dbeb0 shell-check fixes 2020-11-08 17:57:54 +02:00
Ira Abramov
689758cf71 pre-commit fixes. 2020-11-08 17:40:45 +02:00
Ira Abramov
889259dfec Cut 30s vrom the knife completion init time. 2020-11-08 17:33:21 +02:00
Noah Gorny
72f5c2ada0 Move README to be under docs/ 2020-11-06 19:16:56 +02:00
Noah Gorny
864970bcd2 docs: Transition md files to support new rtd format 2020-11-06 19:16:56 +02:00
Noah Gorny
5cdb98f802 pre-commit: Exclude docs _build folder 2020-11-06 19:14:19 +02:00
Noah Gorny
621ac92ae1 Migrate wiki docs to rtd format 2020-11-05 20:41:26 +02:00
Noah Gorny
bcc3f4080b Merge pull request #1698 from davidpfarrell/themes/clean-powerline
Clean Powerline; Add Dir Support to Clean_Files
2020-11-05 19:22:29 +02:00
David Farrell
48333b9816 Merge branch 'themes/clean-powerline' of davidpfarrell.github.com:davidpfarrell/bash-it into themes/clean-powerline 2020-11-05 08:31:16 -08:00
David Farrell
75bd5c85c1 Explain Bash-it variable clearing in lint script 2020-11-05 08:30:33 -08:00
David Farrell
ff208775a5 Explain Bash-it variable clearing in lint script 2020-11-05 08:28:33 -08:00
David Farrell
a858e75456 Add Dir Support to Clean_Files; Clean powerline theme 2020-11-03 16:14:02 -08:00
Noah Gorny
52c0f6564e Merge pull request #1701 from davidpfarrell/lint_clean_files
Moves lint logic into lint_clean_files.sh
2020-11-04 01:08:22 +02:00
David Farrell
da9b710014 Moves lint logic into lint_clean_files.sh 2020-11-03 10:10:11 -08:00
Noah Gorny
447448b357 Merge pull request #1700 from davidpfarrell/docs/fix_make_bat
Adds better support for .bat files; Fixes docs/make.bat
2020-11-03 19:44:08 +02:00
David Farrell
9edba505b5 Adds better support for .bat files; Fixes docs/make.bat 2020-11-03 09:16:14 -08:00
Noah Gorny
d5e54596a9 Merge pull request #1688 from NoahGorny/docs
Basic ReadTheDocs
2020-11-02 08:40:56 +02:00
Noah Gorny
600b425e0a Merge pull request #1695 from NoahGorny/clean-90210-theme
Clean 90210 theme
2020-11-01 17:09:29 +02:00
Noah Gorny
a717283163 docs: Add label to git_prompt section 2020-10-31 23:12:31 +02:00
Noah Gorny
0076db0efb docs: Add CI stage 2020-10-31 23:07:02 +02:00
Noah Gorny
3844b652b4 Add readthedocs configuration 2020-10-31 23:07:02 +02:00
Noah Gorny
1228418653 docs: Change theme to sphinx rtd theme 2020-10-31 23:07:02 +02:00
Noah Gorny
f7e295f691 Move most of the documentation to .rst format 2020-10-31 23:07:02 +02:00
Noah Gorny
6abb26c6c6 docs: Add empty _static and _templates directories 2020-10-31 23:07:02 +02:00
Noah Gorny
b667a71995 docs: Add basic sphinx docs 2020-10-31 23:07:02 +02:00
Noah Gorny
3f68817047 Clean 90210 theme 2020-10-31 12:33:12 +02:00
Noah Gorny
af6af2d932 Merge pull request #1687 from NoahGorny/enforce-pre-commit-only-newlines
Enforce pre-commit newline fixes
2020-10-31 12:32:02 +02:00
Noah Gorny
0b9da701c4 Rename lint CI job 2020-10-30 10:17:38 +02:00
Noah Gorny
dd1474990c Modify general editorconfig settings 2020-10-30 10:17:11 +02:00
Noah Gorny
54116fc068 Bump shellcheck, shfmt hooks to 2.1.4 2020-10-29 23:05:23 +02:00
Noah Gorny
1f5d9b757f Fix newline and trailing space issues 2020-10-29 19:57:14 +02:00
Noah Gorny
507e4bec82 Convert files with spaces and tabs to only spaces 2020-10-29 19:57:14 +02:00
Ira Abramov
eca68db8cc Fixing the indent to everyone's content 2020-10-29 19:57:14 +02:00
Ira Abramov
81f7af5036 In case we ARE committing to tabs now... 2020-10-29 19:57:14 +02:00
Ira Abramov
3a1283dad5 Fix EOF 2020-10-29 19:57:14 +02:00
Ira Abramov
c42e3e8b21 Removed trailing whitespaces 2020-10-29 19:57:14 +02:00
Noah Gorny
3f318914fd Merge pull request #1624 from NoahGorny/enforce-pre-commit
Enforce pre commit take 2
2020-10-29 19:55:55 +02:00
Noah Gorny
d150fc6ec1 ci: Run pre-commit only on whitelisted files 2020-10-28 11:51:04 +02:00
Noah Gorny
2acf26b7b3 pre-commit: Do not run shfmt/shellcheck on .bats files 2020-10-28 11:51:04 +02:00
Noah Gorny
45d076567a Add simple shellcheckrc 2020-10-28 11:51:04 +02:00
Noah Gorny
b14a38fec9 ci: Add pre-commit run and remove trailling spaces 2020-10-28 11:51:04 +02:00
Ira Abramov
5045867b2c Don't touch tab indentations, they are there for a good reason 2020-10-28 09:08:04 +02:00
Ira Abramov
d986261f98 another round of refinements after PR #1434 2020-10-28 09:08:04 +02:00
Ira Abramov
250bd2bbd8 Add a note on how to use the pre-commit yaml. 2020-10-28 09:08:04 +02:00
Ira Abramov
9ac6a6ab96 Enforce some coding standards for the contributers 2020-10-28 09:08:04 +02:00
Noah Gorny
e290af4eec Merge pull request #1690 from NoahGorny/bash-it-version-improvement
Improve bash-it version output
2020-10-28 07:33:04 +02:00
Noah Gorny
93cc173815 Merge pull request #1691 from NoahGorny/git-push-delete-alias
git: Add git push --delete alias
2020-10-28 07:32:15 +02:00
Noah Gorny
313abebbb0 git: Add git push --delete alias 2020-10-27 20:06:37 +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
Willy Barro
449d6d4fe1 Add aliases for GIT-SVN (rebase and dcommit)
- Add "gsr" for "git svn rebase"
- Add "gsd" for "git svn dcommit"
2012-09-25 17:59:45 -03:00
160 changed files with 4051 additions and 2917 deletions

View File

@@ -5,11 +5,26 @@ indent_style = space
indent_size = 2 indent_size = 2
end_of_line = lf end_of_line = lf
charset = utf-8 charset = utf-8
trim_trailing_whitespace = true trim_trailing_whitespace = true
insert_final_newline = true insert_final_newline = true
[*.md] [*.{md,rst}]
trim_trailing_whitespace = false trim_trailing_whitespace = false
[.git*] [.git*]
indent_style = tab indent_style = tab
[*.*sh]
indent_style = tab
indent_size = 4
shell_variant = bash
binary_next_line = true # like -bn
switch_case_indent = true # like -ci
space_redirects = true # like -sr
keep_padding = true # like -kp
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

7
.gitattributes vendored
View File

@@ -1,2 +1,9 @@
*.sh text eol=lf *.sh text eol=lf
*.bash text eol=lf *.bash text eol=lf
# Docs allow trailing whitespaces
*.md whitespace=-blank-at-eol
*.rst whitespace=-blank-at-eol
# Windows files
*.bat text eol=crlf

46
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,46 @@
---
name: Bug report
about: Create a bug report to help us improve
title: ''
labels: bug:general
assignees: ''
---
<!--- Provide a general summary of the issue in the Title above -->
## Expected Behavior
<!--- Tell us what should happen -->
## Current Behavior
<!--- Tell us what happens instead of the expected behavior -->
## Possible Solution
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
## Context
<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
## Steps to Reproduce
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant -->
1.
2.
3.
4.
## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
* Bash-it version used:
* List of enabled plugins, themes and aliases (use ``bash-it show (plugins/themes/aliases)``):
* ``bash-it doctor`` output:
* Bash version:
* Operating System and version:
## Your Bash Config File
<!--- Please paste here your bash config file (.bashrc/.bash_profile) -->
<!--- This will help us debug and locate the problem -->
```bash
# Your bash config file should be here
```

View File

@@ -0,0 +1,23 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: feature request
assignees: ''
---
<!--- Provide a general summary of the issue in the Title above -->
## Expected Behavior
<!--- Tell us how your feature should work -->
## Current Behavior
<!--- Explain the difference your feature will have from current behavior -->
## Possible Solution
<!--- Not obligatory, but suggest ideas on how to implement the addition or change -->
## Context
<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is most useful in the real world -->

30
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,30 @@
<!--- Provide a general summary of your changes in the Title above -->
## Description
<!--- Describe your changes in detail -->
## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->
## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->
## Screenshots (if appropriate):
## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
## Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [ ] My code follows the code style of this project.
- [ ] If my change requires a change to the documentation, I have updated the documentation accordingly.
- [ ] I have read the **CONTRIBUTING** document.
- [ ] If I have added a new file, I also added it to ``clean_files.txt`` and formatted it using ``lint_clean_files.sh``.
- [ ] I have added tests to cover my changes, and all the new and existing tests pass.

11
.github/no-response.yml vendored Normal file
View File

@@ -0,0 +1,11 @@
# Configuration for probot-no-response - https://github.com/probot/no-response
# Number of days of inactivity before an Issue is closed for lack of response
daysUntilClose: 14
# Label requiring a response
responseRequiredLabel: waiting-for-response
# Comment to post when closing an Issue for lack of response. Set to `false` to disable
closeComment: >
This issue has been automatically closed because there has been no response
to our request for more information from the original author.
You can always reopen the issue if needed.

60
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,60 @@
name: CI
# Triggers the workflow on push or pull request events
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
bats-test:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, macos-10.15, macos-11.0]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Install greadlink
if: startsWith(runner.os, 'macOS')
run: brew install coreutils
- name: Test code
run: test/run
build-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install docs dependencies
run: python3 -m pip install -r docs/requirements.txt
- name: Build the docs
run: sphinx-build -W -b html docs docs/_build/html
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install shfmt
run: GO111MODULE=on go get mvdan.cc/sh/v3/cmd/shfmt
- name: Install shellcheck
run: brew install shellcheck
- name: Install pre-commit
run: python3 -m pip install -r test/lint-requirements.txt
- name: Run lint
run: ./lint_clean_files.sh

30
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,30 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
---
# fail_fast: true
minimum_pre_commit_version: 1.18.1
exclude: "docs/_build/"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: trailing-whitespace
exclude: ".(md|rst)$"
- id: end-of-file-fixer
- id: check-merge-conflict
- id: mixed-line-ending
- id: check-added-large-files
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 2.1.4
hooks:
- id: git-check # Configure in .gitattributes
- id: shellcheck
exclude: ".bats$"
- id: shfmt
exclude: ".bats$"
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.7
hooks:
# - id: forbid-crlf
- id: remove-crlf
exclude: ".bat$"

10
.readthedocs.yml Normal file
View File

@@ -0,0 +1,10 @@
version: 2
sphinx:
builder: htmldir
configuration: docs/conf.py
python:
version: 3.7
install:
- requirements: docs/requirements.txt

6
.shellcheckrc Normal file
View File

@@ -0,0 +1,6 @@
# We use colors and not assigned
disable=SC2154
# Hard to fix
disable=SC2155
# shellcheck is wrong on some
disable=SC2034

View File

@@ -1,31 +0,0 @@
# YAML anchors need to appear first.
# Keys starting with an underscore are the custom ones, refer to
# https://docs.travis-ci.com/user/build-config-yaml#private-keys-as-yaml-anchors-and-aliases-and-external-tooling
_native_job: &native_job
script: |
test/run
language: shell
os: linux
dist: xenial
jobs:
- <<: *native_job
name: Ubuntu 16.04
- <<: *native_job
name: Ubuntu 18.04
dist: bionic
- <<: *native_job
name: MacOS xcode9.4
os: osx
osx_image: xcode9.4 # Default xcode on Travis.
- <<: *native_job
name: MacOS xcode11.5
os: osx
osx_image: xcode11.5 # Latest xcode on Travis.

View File

@@ -1,91 +0,0 @@
# Contribution Guidelines
When contributing a new feature, a bug fix, a new theme, or any other change to Bash-it, please consider the following guidelines.
Most of this is common sense, but please try to stick to the conventions listed here.
## Issues
* When opening a new issue in the issue tracker, please include information about which _Operating System_ you're using, and which version of _Bash_.
* In many cases, it also makes sense to show which Bash-it plugins you are using.
This information can be obtained using `bash-it show plugins`.
* If the issue happens while loading Bash-it, please also include your `~/.bash_profile` or `~/.bashrc` file,
as well as the install location of Bash-it (default should be `~/.bash_it`).
* When reporting a bug or requesting a new feature, consider providing a Pull Request that fixes the issue or can be used as a starting point for the new feature.
Don't be afraid, most things aren't that complex...
## Pull Requests
* Fork the Bash-it repo, create a new feature branch from _master_ and apply your changes there.
Create a _Pull Request_ from your feature branch against Bash-it's _master_ branch.
* Limit each Pull Request to one feature.
Don't bundle multiple features/changes (e.g. a new _Theme_ and a fix to an existing plugin) into a single Pull Request - create one PR for the theme, and a separate PR for the fix.
* For complex changes, try to _squash_ your changes into a single commit before
pushing code. Once you've pushed your code and opened a PR, please refrain
from force-pushing changes to the PR branch remember, Bash-it is a
distributed project and your branch may be in use already.
* When in doubt, open a PR with too many commits. Bash-it is a learning project
for everyone involved. Showing your work provides a great history for folks
to learn what works and what didn't.
## Code Style
* Try to stick to the existing code style. Please don't reformat or change the syntax of existing code simply because you don't like that style.
* Indentation is using spaces, not tabs. Most of the code is indented with 2 spaces, some with 4 spaces. Please try to stick to 2 spaces.
If you're using an editor that supports [EditorConfig](http://EditorConfig.org), the editor should automatically use the settings defined in Bash-it's [.editorconfig file](.editorconfig).
* When creating new functions, please use a dash ("-") to separate the words of the function's name, e.g. `my-new-function`.
Don't use underscores, e.g. `my_new_function`.
* Internal functions that aren't to be used by the end user should start with an underscore, e.g. `_my-new-internal-function`.
* Use the provided meta functions to document your code, e.g. `about-plugin`, `about`, `group`, `param`, `example`.
This will make it easier for other people to use your new functionality.
Take a look at the existing code for an example (e.g. [the base plugin](plugins/available/base.plugin.bash)).
* When adding files, please use the existing file naming conventions, e.g. plugin files need to end in `.plugin.bash`.
This is important for the installation functionality.
* When using the `$BASH_IT` variable, please always enclose it in double quotes to ensure that the code also works when Bash-it is installed in a directory that contains spaces in its name: `for f in "${BASH_IT}/plugins/available"/*.bash ; do echo "$f" ; done`
* Bash-it supports Bash 3.2 and higher. Please don't use features only available in Bash 4, such as associative arrays.
## Unit Tests
When adding features or making changes/fixes, please run our growing unit test suite to ensure that you did not break existing functionality.
The test suite does not cover all aspects of Bash-it, but please run it anyway to verify that you did not introduce any regression issues.
Any code pushed to GitHub as part of a Pull Request will automatically trigger a continuous integration build on [Travis CI](https://travis-ci.org/Bash-it/bash-it), where the test suite is run on both Linux and macOS.
The Pull Request will then show the result of the Travis build, indicating whether all tests ran fine, or whether there were issues.
Please pay attention to this, Pull Requests with build issues will not be merged.
Adding new functionality or changing existing functionality is a good opportunity to increase Bash-it's test coverage.
When you're changing the Bash-it codebase, please consider adding some unit tests that cover the new or changed functionality.
Ideally, when fixing a bug, a matching unit test that verifies that the bug is no longer present, is added at the same time.
To run the test suite, simply execute the following in the directory where you cloned Bash-it:
```bash
test/run
```
This command will ensure that the [Bats Test Framework](https://github.com/bats-core/bats-core) is available in the local `test_lib` directory (Bats is included as a Git submodule) and then run the test suite found in the [test](test) folder.
The test script will execute each test in turn, and will print a status for each test case.
When adding new test cases, please take a look at the existing test cases for examples.
The following libraries are used to help with the tests:
* Test Framework: https://github.com/bats-core/bats-core
* Support library for Bats-Assert: https://github.com/ztombol/bats-support
* General `assert` functions: https://github.com/ztombol/bats-assert
* File `assert` functions: https://github.com/ztombol/bats-file
When verifying test results, please try to use the `assert` functions found in these libraries.
## Features
* When adding new completions or plugins, please don't simply copy existing tools into the Bash-it codebase, try to load/integrate the tools instead.
An example is using `nvm`: Instead of copying the existing `nvm` script into Bash-it, the `nvm.plugin.bash` file tries to load an existing installation of `nvm`.
This means an additional step for the user (installing `nvm` from its own repo, or through a package manager),
but it will also ensure that `nvm` can be upgraded in an easy way.
## Themes
* When adding a new theme, please include a screenshot and a short description about what makes this theme unique in the Pull Request's description field.
Please do not add theme screenshots to the repo itself, as they will add unnecessary bloat to the repo.
The project's Wiki has a _Themes_ page where you can add a screenshot if you want.
* Ideally, each theme's folder should contain a `README.md` file describing the theme and its configuration options.

View File

@@ -1,66 +0,0 @@
# Bash-it Development
This page summarizes a couple of rules to keep in mind when developing features or making changes in Bash-it.
## Debugging and Logging
### General Logging
While developing feature or making changes in general, you can log error/warning/debug
using `_log_error` `_log_warning` and `_log_debug`. This will help you solve problems quicker
and also propagate important notes to other users of Bash-it.
You can see the logs by using `bash-it doctor` command to reload and see the logs.
Alternatively, you can set `BASH_IT_LOG_LEVEL` to `BASH_IT_LOG_LEVEL_ERROR`, `BASH_IT_LOG_LEVEL_WARNING` or `BASH_IT_LOG_LEVEL_ALL`.
### Log Prefix/Context
You can define `BASH_IT_LOG_PREFIX` in your files in order to a have a constant prefix before your logs.
Note that we prefer to uses "tags" based logging, i.e `plugins: git: DEBUG: Loading git plugin`.
## Load Order
### General Load Order
The main `bash_it.sh` script loads the frameworks individual components in the following order:
* `lib/composure.bash`
* Files in `lib` with the exception of `appearance.bash` - this means that `composure.bash` is loaded again here (possible improvement?)
* Enabled `aliases`
* Enabled `plugins`
* Enabled `completions`
* `themes/colors.theme.bash`
* `themes/base.theme.bash`
* `lib/appearance.bash`, which loads the selected theme
* Custom `aliases`
* Custom `plugins`
* Custom `completions`
* Additional custom files from either `$BASH_IT/custom` or `$BASH_IT_CUSTOM`
This order is subject to change.
### Individual Component Load Order
For `aliases`, `plugins` and `completions`, the following rules are applied that influence the load order:
* There is a global `enabled` directory, which the enabled components are linked into. Enabled plugins are symlinked from `$BASH_IT/plugins/available` to `$BASH_IT/enabled` for example. All component types are linked into the same common `$BASH_IT/enabled` directory.
* Within the common `enabled` directories, the files are loaded in alphabetical order, which is based on the item's load priority (see next item).
* When enabling a component, a _load priority_ is assigned to the file. The following default priorities are used:
* Aliases: 150
* Plugins: 250
* Completions: 350
* When symlinking a component into the `enabled` directory, the load priority is used as a prefix for the linked name, separated with three dashes from the name of the component. The `node.plugin.bash` would be symlinked to `250---node.plugin.bash` for example.
* Each file can override the default load priority by specifying a new value. To do this, the file needs to include a comment in the following form. This example would cause the `node.plugin.bash` (if included in that file) to be linked to `225---node.plugin.bash`:
```bash
# BASH_IT_LOAD_PRIORITY: 225
```
Having the order based on a numeric priority in a common directory allows for more flexibility. While in general, aliases are loaded first (since their default priority is 150), it's possible to load some aliases after the plugins, or some plugins after completions by setting the items' load priority. This is more flexible than a fixed type-based order or a strict alphabetical order based on name.
These items are subject to change. When making changes to the internal functionality, this page needs to be updated as well.
## Plugin Disable Callbacks
Plugins can define a function that will be called when the plugin is being disabled.
The callback name should be `{PLUGIN_NAME}_on_disable`, you can see `gitstatus` for usage example.

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 Bash-it
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

502
README.md
View File

@@ -1,502 +0,0 @@
# Bash-it
[![Build Status](https://travis-ci.com/Bash-it/bash-it.svg?branch=master)](https://travis-ci.com/Bash-it/bash-it)
[![Join the chat at https://gitter.im/Bash-it/bash-it](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Bash-it/bash-it?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
**Bash-it** is a collection of community Bash commands and scripts for Bash 3.2+.
(And a shameless ripoff of [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) :smiley:)
Includes autocompletion, themes, aliases, custom functions, a few stolen pieces from Steve Losh, and more.
Bash-it provides a solid framework for using, developing and maintaining shell scripts and custom commands for your daily work.
If you're using the _Bourne Again Shell_ (Bash) regularly and have been looking for an easy way on how to keep all of these nice little scripts and aliases under control, then Bash-it is for you!
Stop polluting your `~/bin` directory and your `.bashrc` file, fork/clone Bash-it and start hacking away.
- [Contributing](#contributing)
- [Installation](#installation)
- [Install Options](#install-options)
- [via Docker](#install-using-docker)
- [Updating](#updating)
- [Help](#help-screens)
- [Search](#search)
- [Syntax](#syntax)
- [Searching with Negations](#searching-with-negations)
- [Using Search to Enable or Disable Components](#using-search-to-enable-or-disable-components)
- [Disabling ASCII Color](#disabling-ascii-color)
- [Custom scripts, aliases, themes, and functions](#custom-scripts-aliases-themes-and-functions)
- [Themes](#themes)
- [Uninstalling](#uninstalling)
- [Misc](#misc)
- [Help Out](#help-out)
- [Contributors](#contributors)
## Contributing
Please take a look at the [Contribution Guidelines](CONTRIBUTING.md) before reporting a bug or providing a new feature.
The [Development Guidelines](DEVELOPMENT.md) have more information on some of the internal workings of Bash-it,
please feel free to read through this page if you're interested in how Bash-it loads its components.
## Installation
1. Check out a clone of this repo to a location of your choice, such as
`git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it`
2. Run `~/.bash_it/install.sh` (it automatically backs up your `~/.bash_profile` or `~/.bashrc`, depending on your OS)
3. Edit your modified config (`~/.bash_profile` or `~/.bashrc`) file in order to customize Bash-it.
4. Check out available aliases, completions, and plugins and enable the ones you want to use (see the next section for more details).
### Install Options
The install script can take the following options:
* `--interactive`: Asks the user which aliases, completions and plugins to enable.
* `--silent`: Ask nothing and install using default settings.
* `--no-modify-config`: Do not modify the existing config file (`~/.bash_profile` or `~/.bashrc`).
When run without the `--interactive` switch, Bash-it only enables a sane default set of functionality to keep your shell clean and to avoid issues with missing dependencies.
Feel free to enable the tools you want to use after the installation.
When you run without the `--no-modify-config` switch, the Bash-it installer automatically modifies/replaces your existing config file.
Use the `--no-modify-config` switch to avoid unwanted modifications, e.g. if your Bash config file already contains the code that loads Bash-it.
**NOTE**: Keep in mind how Bash loads its configuration files,
`.bash_profile` for login shells (and in macOS in terminal emulators like [Terminal.app](http://www.apple.com/osx/apps/) or
[iTerm2](https://www.iterm2.com/)) and `.bashrc` for interactive shells (default mode in most of the GNU/Linux terminal emulators),
to ensure that Bash-it is loaded correctly.
A good "practice" is sourcing `.bashrc` into `.bash_profile` to keep things working in all the scenarios.
To achieve this, you can add this snippet in your `.bash_profile`:
```
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
```
Refer to the official [Bash documentation](https://www.gnu.org/software/bash/manual/bashref.html#Bash-Startup-Files) to get more info.
### Install using Docker
You can try Bash-it in an isolated environment without changing any local files via a [Docker](https://www.docker.com/) Container.
(Bash Shell v4.4 with Bash-it, [bats](https://github.com/sstephenson/bats),and bash-completion based on [Alpine Linux](https://alpinelinux.org/)).
`docker pull ellerbrock/bash-it`
Have a look at our [bash-it-docker repository](https://github.com/Bash-it/bash-it-docker) for further information.
### Updating
To update Bash-it to the latest stable version, simply run:
```bash
bash-it update stable
```
If you want to update to the latest dev version (directly from master), run:
```bash
bash-it update dev
```
If you want to update automatically and unattended, you can add the optional
`-s/--silent` flag, for example:
```bash
bash-it update dev --silent
```
If you are using an older version of Bash-it, it's possible that some functionality has changed, or that the internal structure of how Bash-it organizes its functionality has been updated.
For these cases, we provide a `migrate` command:
```bash
bash-it migrate
```
This command will automatically migrate the Bash-it structure to the latest version.
The `migrate` command is run automatically if you run the `update`, `enable` or `disable` commands.
## Help Screens
```bash
bash-it show aliases # shows installed and available aliases
bash-it show completions # shows installed and available completions
bash-it show plugins # shows installed and available plugins
bash-it help aliases # shows help for installed aliases
bash-it help completions # shows help for installed completions
bash-it help plugins # shows help for installed plugins
```
## Search
If you need to quickly find out which of the plugins, aliases or completions are available for a specific framework, programming language, or an environment, you can _search_ for multiple terms related to the commands you use frequently.
Search will find and print out modules with the name or description matching the terms provided.
### Syntax
```bash
bash-it search term1 [[-]term2] [[-]term3]....
```
As an example, a ruby developer might want to enable everything related to the commands such as `ruby`, `rake`, `gem`, `bundler`, and `rails`.
Search command helps you find related modules so that you can decide which of them you'd like to use:
```bash
bash-it search ruby rake gem bundle irb rails
aliases: bundler rails
plugins: chruby chruby-auto ruby
completions: bundler gem rake
```
Currently enabled modules will be shown in green.
### Searching with Negations
You can prefix a search term with a "-" to exclude it from the results.
In the above example, if we wanted to hide `chruby` and `chruby-auto`,
we could change the command as follows:
```bash
bash-it search ruby rake gem bundle irb rails -chruby
aliases: bundler rails
plugins: ruby
completions: bundler gem rake
```
### Using Search to Enable or Disable Components
By adding a `--enable` or `--disable` to the search command, you can automatically enable all modules that come up as a result of a search query.
This could be quite handy if you like to enable a bunch of components related to the same topic.
### Disabling ASCII Color
To remove non-printing non-ASCII characters responsible for the coloring of the search output, you can set environment variable `NO_COLOR`.
Enabled components will then be shown with a checkmark:
```bash
NO_COLOR=1 bash-it search ruby rake gem bundle irb rails -chruby
aliases => ✓bundler ✓rails
plugins => ✓ruby
completions => bundler gem rake
```
## Custom scripts, aliases, themes, and functions
For custom scripts, and aliases, just create the following files (they'll be ignored by the git repo):
* `aliases/custom.aliases.bash`
* `completion/custom.completion.bash`
* `lib/custom.bash`
* `plugins/custom.plugins.bash`
* `custom/themes/<custom theme name>/<custom theme name>.theme.bash`
Anything in the custom directory will be ignored, with the exception of `custom/example.bash`.
Alternately, if you would like to keep your custom scripts under version control, you can set `BASH_IT_CUSTOM` in your `~/.bashrc` to another location outside of the `$BASH_IT` folder.
In this case, any `*.bash` file under every directory below `BASH_IT_CUSTOM` folder will be used.
## Themes
There are over 50+ Bash-it themes to pick from in `$BASH_IT/themes`.
The default theme is `bobby`.
Set `BASH_IT_THEME` to the theme name you want, or if you've developed your own custom theme outside of `$BASH_IT/themes`,
point the `BASH_IT_THEME` variable directly to the theme file.
To disable theming completely, leave the variable empty.
Examples:
```bash
# Use the "powerline-multiline" theme
export BASH_IT_THEME="powerline-multiline"
# Use a theme outside of the Bash-it folder
export BASH_IT_THEME="/home/foo/my_theme/my_theme.theme.bash"
# Disable theming
export BASH_IT_THEME=""
```
You can easily preview the themes in your own shell using `BASH_PREVIEW=true bash-it reload`.
If you've created your own custom prompts, we'd love it if you shared them with everyone else! Just submit a Pull Request.
You can see theme screenshots on [wiki/Themes](https://github.com/Bash-it/bash-it/wiki/Themes).
**NOTE**: Bash-it and some themes use UTF-8 characters, so to avoid strange behavior in your terminal, set your locale to `LC_ALL=en_US.UTF-8` or the equivalent to your language if it isn't American English.
## Uninstalling
To uninstall Bash-it, run the `uninstall.sh` script found in the `$BASH_IT` directory:
```
cd $BASH_IT
./uninstall.sh
```
This will restore your previous Bash profile.
After the uninstall script finishes, remove the Bash-it directory from your machine (`rm -rf $BASH_IT`) and start a new shell.
## Misc
### Bash Profile Aliases
Bash-it creates a `reload` alias that makes it convenient to reload
your Bash profile when you make changes.
Additionally, if you export `BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE` as a non-null value,
Bash-it will automatically reload itself after activating or deactivating plugins, aliases, or completions.
### Prompt Version Control Check
Bash-it provides prompt themes with the ability to check and display version control information for the current directory.
The information is retrieved for each directory and can slow down the navigation of projects with a large number of files and folders.
Turn version control checking off to prevent slow directory navigation within large projects.
Bash-it provides a flag (`SCM_CHECK`) within the `~/.bash_profile` file that turns off/on version control information checking and display within all themes.
Version control checking is on by default unless explicitly turned off.
Set `SCM_CHECK` to 'false' to **turn off** version control checks for all themes:
* `export SCM_CHECK=false`
Set `SCM_CHECK` to 'true' (the default value) to **turn on** version control checks for all themes:
* `export SCM_CHECK=true`
**NOTE:**
It is possible for themes to ignore the `SCM_CHECK` flag and query specific version control information directly.
For example, themes that use functions like `git_prompt_vars` skip the `SCM_CHECK` flag to retrieve and display git prompt information.
If you turned version control checking off and you still see version control information within your prompt, then functions like `git_prompt_vars` are most likely the reason why.
### Git prompt
Bash-it has some nice features related to Git, continue reading to know more about these features.
### Repository info in the prompt
Bash-it can show some information about Git repositories in the shell prompt: the current branch, tag or commit you are at, how many commits the local branch is ahead or behind from the remote branch, and if you have changes stashed.
Additionally, you can view the status of your working copy and get the count of *staged*, *unstaged* and *untracked* files.
This feature is controlled through the flag `SCM_GIT_SHOW_DETAILS` as follows:
Set `SCM_GIT_SHOW_DETAILS` to 'true' (the default value) to **show** the working copy details in your prompt:
* `export SCM_GIT_SHOW_DETAILS=true`
Set `SCM_GIT_SHOW_DETAILS` to 'false' to **don't show** it:
* `export SCM_GIT_SHOW_DETAILS=false`
**NOTE:** If using `SCM_GIT_SHOW_MINIMAL_INFO=true`, then the value of `SCM_GIT_SHOW_DETAILS` is ignored.
### Remotes and remote branches
In some git workflows, you must work with various remotes, for this reason, Bash-it can provide some useful information about your remotes and your remote branches, for example, the remote on you are working, or if your local branch is tracking a remote branch.
You can control this feature with the flag `SCM_GIT_SHOW_REMOTE_INFO` as follows:
Set `SCM_GIT_SHOW_REMOTE_INFO` to 'auto' (the default value) to activate it only when more than one remote is configured in the current repo:
* `export SCM_GIT_SHOW_REMOTE_INFO=auto`
Set `SCM_GIT_SHOW_REMOTE_INFO` to 'true' to always activate the feature:
* `export SCM_GIT_SHOW_REMOTE_INFO=true`
Set `SCM_GIT_SHOW_REMOTE_INFO` to 'false' to **disable the feature**:
* `export SCM_GIT_SHOW_REMOTE_INFO=false`
**NOTE:** If using `SCM_GIT_SHOW_MINIMAL_INFO=true`, then the value of `SCM_GIT_SHOW_REMOTE_INFO` is ignored.
### Untracked files
By default, the `git status` command shows information about *untracked* files.
This behavior can be controlled through command-line flags or git configuration files.
For big repositories, ignoring *untracked* files can make git faster.
Bash-it uses `git status` to gather the repo information it shows in the prompt, so in some circumstances, it can be useful to instruct Bash-it to ignore these files.
You can control this behavior with the flag `SCM_GIT_IGNORE_UNTRACKED`:
Set `SCM_GIT_IGNORE_UNTRACKED` to 'false' (the default value) to get information about *untracked* files:
* `export SCM_GIT_IGNORE_UNTRACKED=false`
Set `SCM_GIT_IGNORE_UNTRACKED` to 'true' to **ignore** *untracked* files:
* `export SCM_GIT_IGNORE_UNTRACKED=true`
Also, with this flag to false, Bash-it will not show the repository as dirty when the repo has *untracked* files, and will not display the count of *untracked* files.
**NOTE:** If you set in git configuration file the option to ignore *untracked* files, this flag has no effect, and Bash-it will ignore *untracked* files always.
### Stash item count
When `SCM_GIT_SHOW_DETAILS` is enabled, you can get the count of *stashed* items. This feature can be useful when a user has a lot of stash items.
This feature is controlled through the flag `SCM_GIT_SHOW_STASH_INFO` as follows:
Set `SCM_GIT_SHOW_STASH_INFO` to 'true' (the default value) to **show** the count of stashed items:
* `export SCM_GIT_SHOW_STASH_INFO=true`
Set `SCM_GIT_SHOW_STASH_INFO` to 'false' to **don't show** it:
* `export SCM_GIT_SHOW_STASH_INFO=false`
### Ahead/Behind Count
When displaying information regarding whether or not the local branch is ahead or behind its remote counterpart, you can opt to display the number of commits ahead/behind.
This is useful if you only care whether or not you are ahead or behind and do not care how far ahead/behind you are.
Set `SCM_GIT_SHOW_COMMIT_COUNT` to 'true' (the default value) to **show** the count of commits ahead/behind:
* `export SCM_GIT_SHOW_COMMIT_COUNT=true`
Set `SCM_GIT_SHOW_COMMIT_COUNT` to 'false' to **don't show** it:
* `export SCM_GIT_SHOW_COMMIT_COUNT=false`
### Git user
In some environments, it is useful to know the value of the current git user, which is used to mark all new commits.
For example, any organization that uses the practice of pair programming will typically author each commit with [combined names of the two authors](https://github.com/pivotal/git_scripts).
When another pair uses the same pairing station, the authors are changed at the beginning of the session.
To get up and running with this technique, run `gem install pivotal_git_scripts`, and then edit your `~/.pairs` file, according to the specification on the [gem's homepage](https://github.com/pivotal/git_scripts).
After that, you should be able to run `git pair kg as` to set the author to, eg. "Konstantin Gredeskoul and Alex Saxby", assuming they've been added to the `~/.pairs` file.
Please see gem's documentation for more information.
To enable the display of the current pair in the prompt, you must set `SCM_GIT_SHOW_CURRENT_USER` to `true`.
Once set, the `SCM_CURRENT_USER` variable will be automatically populated with the initials of the git author(s).
It will also be included in the default git prompt.
Even if you do not have `git pair` installed, as long as your `user.name` is set, your initials will be computed from your name and shown in the prompt.
You can control the prefix and the suffix of this component using the two variables:
* `export SCM_THEME_CURRENT_USER_PREFFIX=' ☺︎ '`
And
* `export SCM_THEME_CURRENT_USER_SUFFIX=' ☺︎ '`
**NOTE:** If using `SCM_GIT_SHOW_MINIMAL_INFO=true`, then the value of `SCM_GIT_SHOW_CURRENT_USER` is ignored.
### Git show minimal status info
To speed up the prompt while still getting minimal git status information displayed such as the value of `HEAD` and whether there are any dirty objects, you can set:
```
export SCM_GIT_SHOW_MINIMAL_INFO=true
```
### Ignore repo status
When working in repos with a large codebase, Bash-it can slow down your prompt when checking the repo status.
To avoid it, there is an option you can set via Git config to disable checking repo status in Bash-it.
To disable checking the status in the current repo:
```
$ git config --add bash-it.hide-status 1
```
But if you would like to disable it globally, and stop checking the status for all of your repos:
```
$ git config --global --add bash-it.hide-status 1
```
Setting this flag globally has the same effect as `SCM_CHECK=true`, but only for Git repos.
### Speed up git status calculations
As an alternative to ignoring repo status entirely, you can try out the `gitstatus` plugin.
This plugin speeds up all `git status` calculations by up to 10x times!
**NOTE**: You will need to clone `gitstatus` repo from [here](https://github.com/romkatv/gitstatus).
### Pass function renamed to passgen
The Bash-it `pass` function has been renamed to `passgen` in order to avoid a naming conflict with the [pass password manager](https://www.passwordstore.org/).
In order to minimize the impact on users of the legacy Bash-it `pass` function, Bash-it will create the alias `pass` that calls the new `passgen` function if the `pass` password manager command is not found on the `PATH` (default behavior).
This behavior can be overridden with the `BASH_IT_LEGACY_PASS` flag as follows:
Set `BASH_IT_LEGACY_PASS` to 'true' to force Bash-it to always **create** the `pass` alias to `passgen`:
* `export BASH_IT_LEGACY_PASS=true`
Unset `BASH_IT_LEGACY_PASS` to have Bash-it **return to default behavior**:
* `unset BASH_IT_LEGACY_PASS`
### Debugging
If you encounter problems with any part of Bash-it, run the following command:
```bash
bash-it doctor
```
This will reload your bash profile and print out logs of various parts in Bash-it.
Note that this command at default will print all logs, including debug logs.
You can call it like this:
```bash
bash-it doctor [errors/warnings/all]
```
In order to get wanted verbosity.
### Proxy Support
If you are working in a corporate environment where you have to go through a proxy server for internet access,
then you know how painful it is to configure the OS proxy variables in the shell,
especially if you are switching between environments, e.g. office (with proxy) and home (without proxy).
The Bash shell (and many shell tools) use the following variables to define the proxy to use:
* `HTTP_PROXY` (and `http_proxy`): Defines the proxy server for HTTP requests
* `HTTPS_PROXY` (and `https_proxy`): Defines the proxy server for HTTPS requests
* `ALL_PROXY` (and `all_proxy`): Used by some tools for the same purpose as above
* `NO_PROXY` (and `no_proxy`): Comma-separated list of hostnames that don't have to go through the proxy
Bash-it's `proxy` plugin allows to enable and disable these variables with a simple command.
To start using the `proxy` plugin, run the following:
```bash
bash-it enable plugin proxy
```
Bash-it also provides support for enabling/disabling proxy settings for various shell tools.
The following backends are currently supported (in addition to the shell's environment variables): Git, SVN, npm, ssh.
The `proxy` plugin changes the configuration files of these tools to enable or disable the proxy settings.
Bash-it uses the following variables to set the shell's proxy settings when you call `enable-proxy`.
These variables are best defined in a custom script in Bash-it's custom script folder (`$BASH_IT/custom`), e.g. `$BASH_IT/custom/proxy.env.bash`
* `BASH_IT_HTTP_PROXY` and `BASH_IT_HTTPS_PROXY`: Define the proxy URL to be used, e.g. 'http://localhost:1234'
* `BASH_IT_NO_PROXY`: A comma-separated list of proxy exclusions, e.g. `127.0.0.1,localhost`
Once you have defined these variables (and have run `reload` to load the changes), you can use the following commands to enable or disable the proxy settings in your current shell:
* `enable-proxy`: This sets the shell's proxy environment variables and configures proxy support in your SVN, npm, and SSH configuration files.
* `disable-proxy`: This unsets the shell's proxy environment variables and disables proxy support in your SVN, npm, and SSH configuration files.
There are many more proxy commands, e.g. for changing the local Git project's proxy settings.
Run `glossary proxy` to show the available proxy functions with a short description.
## Help out
We think everyone has their own custom scripts accumulated over time.
And so, following in the footsteps of oh-my-zsh, Bash-it is a framework for easily customizing your Bash shell.
Everyone's got a custom toolbox, so let's start making them even better, **as a community!**
Send us a pull request and we'll merge it as long as it looks good.
If you change an existing command, please give an explanation why.
That will help a lot when we merge your changes in.
Please take a look at the [Contribution Guidelines](CONTRIBUTING.md) before reporting a bug or providing a new feature.
Thanks, and happing bashing!
## Contributors
* [List of contributors][contribute]
[contribute]: https://github.com/Bash-it/bash-it/contributors
[pass password manager]: http://www.passwordstore.org/

View File

@@ -8,4 +8,3 @@ fi
alias please=fuck alias please=fuck
alias plz=please alias plz=please
alias fucking=sudo alias fucking=sudo

View File

@@ -28,6 +28,7 @@ alias gpr='git pull --rebase'
alias gpp='git pull && git push' alias gpp='git pull && git push'
alias gup='git fetch && git rebase' alias gup='git fetch && git rebase'
alias gp='git push' alias gp='git push'
alias gpd='git push --delete'
alias gpo='git push origin HEAD' alias gpo='git push origin HEAD'
alias gpu='git push --set-upstream' alias gpu='git push --set-upstream'
alias gpuo='git push --set-upstream origin' alias gpuo='git push --set-upstream origin'
@@ -64,6 +65,7 @@ alias gco='git checkout'
alias gcom='git checkout master' alias gcom='git checkout master'
alias gcb='git checkout -b' alias gcb='git checkout -b'
alias gcob='git checkout -b' alias gcob='git checkout -b'
alias gcobu='git checkout -b ${USER}/'
alias gct='git checkout --track' alias gct='git checkout --track'
alias gcpd='git checkout master; git pull; git branch -D' alias gcpd='git checkout master; git pull; git branch -D'
alias gexport='git archive --format zip --output' alias gexport='git archive --format zip --output'
@@ -121,6 +123,10 @@ fi
# Show untracked files # Show untracked files
alias gu='git ls-files . --exclude-standard --others' alias gu='git ls-files . --exclude-standard --others'
# Git SVN
alias gsr='git svn rebase'
alias gsd='git svn dcommit'
case $OSTYPE in case $OSTYPE in
darwin*) darwin*)
alias gtls="git tag -l | gsort -V" alias gtls="git tag -l | gsort -V"

View File

@@ -6,4 +6,3 @@ alias node-dev='export NODE_ENV=development'
# alias to setup nodejs production environment # alias to setup nodejs production environment
alias node-prod='export NODE_ENV=production' alias node-prod='export NODE_ENV=production'

View File

@@ -7,4 +7,3 @@ alias puplint="puppet-lint *.pp"
alias pupagt="puppet agent -t" alias pupagt="puppet agent -t"
alias pupagtd="puppet agent -t --debug" alias pupagtd="puppet agent -t --debug"
alias pupapp="puppet apply" alias pupapp="puppet apply"

View File

@@ -8,4 +8,3 @@ alias tfv='terraform validate'
alias tfp='terraform plan' alias tfp='terraform plan'
alias tfa='terraform apply' alias tfa='terraform apply'
alias tfd='terraform destory' alias tfd='terraform destory'

View File

@@ -13,4 +13,3 @@ alias tgva='terragrunt validate-all'
alias tgpa='terragrunt plan-all' alias tgpa='terragrunt plan-all'
alias tgaa='terragrunt apply-all' alias tgaa='terragrunt apply-all'
alias tgda='terragrunt destroy-all' alias tgda='terragrunt destroy-all'

View File

@@ -5,15 +5,20 @@ VIM=$(command -v vim)
GVIM=$(command -v gvim) GVIM=$(command -v gvim)
MVIM=$(command -v mvim) MVIM=$(command -v mvim)
[[ -n $VIM ]] && alias v=$VIM if [[ -n $VIM ]]; then
alias v='$VIM'
# open the vim help in fullscreen incorporated from
# https://stackoverflow.com/a/4687513
alias vimh='${VIM} -c ":h | only"'
fi
# open vim in new tab is taken from # open vim in new tab is taken from
# http://stackoverflow.com/questions/936501/let-gvim-always-run-a-single-instancek # http://stackoverflow.com/questions/936501/let-gvim-always-run-a-single-instancek
case $OSTYPE in case $OSTYPE in
darwin*) darwin*)
[[ -n $MVIM ]] && function mvimt { command mvim --remote-tab-silent "$@" || command mvim "$@"; } [[ -n $MVIM ]] && function mvimt { command mvim --remote-tab-silent "$@" || command mvim "$@"; }
;; ;;
*) *)
[[ -n $GVIM ]] && function gvimt { command gvim --remote-tab-silent "$@" || command gvim "$@"; } [[ -n $GVIM ]] && function gvimt { command gvim --remote-tab-silent "$@" || command gvim "$@"; }
;; ;;
esac esac

View File

@@ -74,6 +74,9 @@ if [[ ! -z "${BASH_IT_THEME}" ]]; then
BASH_IT_LOG_PREFIX="themes: p4helpers: " BASH_IT_LOG_PREFIX="themes: p4helpers: "
# shellcheck source=./themes/p4helpers.theme.bash # shellcheck source=./themes/p4helpers.theme.bash
source "${BASH_IT}/themes/p4helpers.theme.bash" source "${BASH_IT}/themes/p4helpers.theme.bash"
BASH_IT_LOG_PREFIX="themes: command_duration: "
# shellcheck source=./themes/command_duration.theme.bash
source "${BASH_IT}/themes/command_duration.theme.bash"
BASH_IT_LOG_PREFIX="themes: base: " BASH_IT_LOG_PREFIX="themes: base: "
# shellcheck source=./themes/base.theme.bash # shellcheck source=./themes/base.theme.bash
source "${BASH_IT}/themes/base.theme.bash" source "${BASH_IT}/themes/base.theme.bash"

41
clean_files.txt Normal file
View File

@@ -0,0 +1,41 @@
#######################################################################
# Allow-list of files to be lint-checked by CI
#
# Directory Suport
# Directory references are allowed within the file, ie:
#
# themes/powerline
#
# All files under the referenced directory will be checked
#
# Checking Files Locally
# You can manually invoke the check via:
#
# lint_clean_files.sh
#
# root directories
#
docs
# root files
#
.gitattributes
lint_clean_files.sh
# themes
#
themes/90210
themes/powerline
# completions
#
completion/available/cargo.completion.bash
completion/available/knife.completion.bash
completion/available/packer.completion.bash
completion/available/pipx.completion.bash
completion/available/rustup.completion.bash
completion/available/vault.completion.bash
# aliases
aliases/available/vim.aliases.bash

View File

@@ -1,6 +1,27 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# apm-bash-completion is written by Ugur Ozyilmazel # The MIT License (MIT)
# Copyright (c) 2015 Uğur "vigo" Özyılmazel
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# repo: https://github.com/vigo/apm-bash-completion # repo: https://github.com/vigo/apm-bash-completion
__apm(){ __apm(){

View File

@@ -1,9 +1,28 @@
#! bash #! bash
# bash completion for the `bundle` command. # bash completion for the `bundle` command.
# #
# Copyright (c) 2011-2017 Daniel Luz <dev at mernen dot com>. # Copyright (c) 2008 Daniel Luz
# Distributed under the MIT license.
# http://mernen.com/projects/completion-ruby # Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
# #
# To use, source this file on bash: # To use, source this file on bash:
# . completion-bundle # . completion-bundle

View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# cargo (Rust package manager) completion
if _binary_exists rustup && _binary_exists cargo; then
eval "$(rustup completions bash cargo)"
fi

View File

@@ -30,6 +30,36 @@
# ============ # ============
# #
# To uninstall, just remove the line from your .bash_profile and .bashrc. # To uninstall, just remove the line from your .bash_profile and .bashrc.
#
# This file is licensed under the following license:
# Copyright (c) Django Software Foundation and individual contributors.
# All rights reserved.
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of Django nor the names of its contributors may be used
# to endorse or promote products derived from this software without
# specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
_django_completion() _django_completion()
{ {
@@ -69,4 +99,3 @@ else
fi fi
complete -F _python_django_completion -o default $pythons complete -F _python_django_completion -o default $pythons

View File

@@ -1,5 +1,20 @@
#!/bin/bash #!/bin/bash
# #
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Copyright (c) 2014 Docker, Inc
# bash completion for docker-compose # bash completion for docker-compose
# #
# This work is based on the completion for the docker command. # This work is based on the completion for the docker command.

View File

@@ -1,5 +1,20 @@
# #
# bash completion file for docker-machine commands # bash completion file for docker-machine commands
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Copyright (c) 2014 Docker, Inc
# #
# This script provides completion of: # This script provides completion of:
# - commands and their options # - commands and their options

View File

@@ -1,37 +1,2 @@
#!/usr/bin/env bash _log_error 'Bash completion for "drush" is now deprecated, as it used code with incompatible license.
# Please disable this completion and use the instructions from "drush" developers instead.'
# bash completion support for Drush:
# https://github.com/drush-ops/drush
#
# Originally from:
# http://github.com/drush-ops/drush/blob/master/drush.complete.sh
# Ensure drush is available.
which drush &> /dev/null || alias drush &> /dev/null || return
__drush_ps1() {
f="${TMPDIR:-/tmp/}/drush-env/drush-drupal-site-$$"
if [ -f $f ]
then
__DRUPAL_SITE=$(cat "$f")
else
__DRUPAL_SITE="$DRUPAL_SITE"
fi
[[ -n "$__DRUPAL_SITE" ]] && printf "${1:- (%s)}" "$__DRUPAL_SITE"
}
# Completion function, uses the "drush complete" command to retrieve
# completions for a specific command line COMP_WORDS.
_drush_completion() {
# Set IFS to newline (locally), since we only use newline separators, and
# need to retain spaces (or not) after completions.
local IFS=$'\n'
# The '< /dev/null' is a work around for a bug in php libedit stdin handling.
# Note that libedit in place of libreadline in some distributions. See:
# https://bugs.launchpad.net/ubuntu/+source/php5/+bug/322214
COMPREPLY=( $(drush --early=includes/complete.inc "${COMP_WORDS[@]}" < /dev/null 2> /dev/null) )
}
# Register our completion function. We include common short aliases for Drush.
complete -o bashdefault -o default -o nospace -F _drush_completion d dr drush drush5 drush6 drush6 drush.php

View File

@@ -1,3 +1,23 @@
# Copyright (c) 2017 Eric Wendelin
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is furnished to do
# so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# Bash breaks words on : by default. Subproject tasks have ':' # Bash breaks words on : by default. Subproject tasks have ':'
# Avoid inaccurate completions for subproject tasks # Avoid inaccurate completions for subproject tasks
COMP_WORDBREAKS=$(echo "$COMP_WORDBREAKS" | sed -e 's/://g') COMP_WORDBREAKS=$(echo "$COMP_WORDBREAKS" | sed -e 's/://g')

View File

@@ -3,9 +3,35 @@
# grunt-cli # grunt-cli
# http://gruntjs.com/ # http://gruntjs.com/
# #
# Copyright (c) 2012 Tyler Kellen, contributors # Copyright jQuery Foundation and other contributors, https://jquery.org/
# Licensed under the MIT license.
# https://github.com/gruntjs/grunt/blob/master/LICENSE-MIT # This software consists of voluntary contributions made by many
# individuals. For exact contribution history, see the revision history
# available at https://github.com/gruntjs/grunt .
# The following license applies to all parts of this software except as
# documented below:
# ====
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Usage: # Usage:
# #

View File

@@ -2,9 +2,36 @@
# Borrowed from grunt-cli # Borrowed from grunt-cli
# http://gruntjs.com/ # http://gruntjs.com/
# #
# Copyright (c) 2012 Tyler Kellen, contributors # Copyright jQuery Foundation and other contributors, https://jquery.org/
# Licensed under the MIT license.
# https://github.com/gruntjs/grunt/blob/master/LICENSE-MIT # This software consists of voluntary contributions made by many
# individuals. For exact contribution history, see the revision history
# available at https://github.com/gruntjs/grunt .
# The following license applies to all parts of this software except as
# documented below:
# ====
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Usage: # Usage:
# #
# To enable bash <tab> completion for gulp, add the following line (minus the # To enable bash <tab> completion for gulp, add the following line (minus the

View File

@@ -1,60 +1,2 @@
# Bash completion script for homesick _log_error 'Bash completion for "homesick" is now deprecated, as it used unlicensed code.
# Please disable this completion and use the instructions from "homesick" bash completion developers instead.'
# The homebrew bash completion script was used as inspiration.
# Originally from https://github.com/liborw/homesick-completion
_homesick_complete()
{
local cur="${COMP_WORDS[COMP_CWORD]}"
local options="--skip --force --pretend --quiet"
local actions="cd clone commit destroy diff generate help list open pull push rc show_path status symlink track unlink version"
local repos=$(\ls ~/.homesick/repos)
# Subcommand list
[[ ${COMP_CWORD} -eq 1 ]] && {
COMPREPLY=( $(compgen -W "${options} ${actions}" -- ${cur}) )
return
}
# Find the first non-switch word
local prev_index=1
local prev="${COMP_WORDS[prev_index]}"
while [[ $prev == -* ]]; do
prev_index=$((++prev_index))
prev="${COMP_WORDS[prev_index]}"
done
# Find the number of non-"--" commands
local num=0
for word in ${COMP_WORDS[@]}
do
if [[ $word != -* ]]; then
num=$((++num))
fi
done
case "$prev" in
# Commands that take a castle
cd|commit|destroy|diff|open|pull|push|rc|show_path|status|symlink|unlink)
COMPREPLY=( $(compgen -W "${repos}" -- ${cur}) )
return
;;
# Commands that take command
help)
COMPREPLY=( $(compgen -W "${actions}" -- ${cur}) )
return
;;
# Track command take file and repo
track)
if [[ "$num" -eq 2 ]]; then
COMPREPLY=( $(compgen -X -f ${cur}) )
elif [[ "$num" -ge 3 ]]; then
COMPREPLY=( $(compgen -W "${repos}" -- ${cur}) )
fi
return
;;
esac
}
complete -o bashdefault -o default -F _homesick_complete homesick

View File

@@ -1,6 +1,27 @@
# hub tab-completion script for bash. # hub tab-completion script for bash.
# This script complements the completion script that ships with git. # This script complements the completion script that ships with git.
# Copyright (c) 2009 Chris Wanstrath
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# If there is no git tab completion, but we have the _completion loader try to load it # If there is no git tab completion, but we have the _completion loader try to load it
if ! declare -F _git > /dev/null && declare -F _completion_loader > /dev/null; then if ! declare -F _git > /dev/null && declare -F _completion_loader > /dev/null; then
_completion_loader git _completion_loader git

View File

@@ -1,4 +1,28 @@
# Invoke (pyinvoke.org) tab-completion script to be sourced with Bash shell. # Invoke (pyinvoke.org) tab-completion script to be sourced with Bash shell.
# Copyright (c) 2020 Jeff Forcier.
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# https://github.com/pyinvoke/invoke/blob/master/completion/bash # https://github.com/pyinvoke/invoke/blob/master/completion/bash
_complete_invoke() { _complete_invoke() {
@@ -28,4 +52,3 @@ _complete_invoke() {
# * -o default: when function generates no results, use filenames. # * -o default: when function generates no results, use filenames.
# * positional args: program names to complete for. # * positional args: program names to complete for.
complete -F _complete_invoke -o default invoke inv complete -F _complete_invoke -o default invoke inv

View File

@@ -3,8 +3,27 @@
# DATE: 2012-10-30 # DATE: 2012-10-30
# rparree-at-edc4it-dot-com # rparree-at-edc4it-dot-com
# MIT License
# Copyright (c) 2020 Raphael Parree
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
_serverProfiles(){ _serverProfiles(){
if [[ $COMP_WORDS == *standalone.sh* ]] if [[ $COMP_WORDS == *standalone.sh* ]]

View File

@@ -3,4 +3,3 @@
if _command_exists kind; then if _command_exists kind; then
eval "$(kind completion bash)" eval "$(kind completion bash)"
fi fi

View File

@@ -1,5 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Published originally as public domain code at https://github.com/wk8/knife-bash-autocomplete
############## ##############
### CONFIG ### ### CONFIG ###
############## ##############
@@ -19,7 +21,7 @@ _KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE=86400
### init ### init
_KAC_CACHE_TMP_DIR="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/tmp" _KAC_CACHE_TMP_DIR="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/tmp"
# make sure the cache dir exists # make sure the cache dir exists
mkdir -p $_KAC_CACHE_TMP_DIR mkdir -p "$_KAC_CACHE_TMP_DIR"
############################## ##############################
### Cache helper functions ### ### Cache helper functions ###
@@ -31,177 +33,169 @@ stat -c %Y /dev/null > /dev/null 2>&1 && _KAC_STAT_COMMAND="stat -c %Y" || _KAC_
# returns 0 iff the file whose path is given as 1st argument # returns 0 iff the file whose path is given as 1st argument
# exists and has last been modified in the last $2 seconds # exists and has last been modified in the last $2 seconds
# returns 1 otherwise # returns 1 otherwise
_KAC_is_file_newer_than() _KAC_is_file_newer_than() {
{ [ -f "$1" ] || return 1
[ -f "$1" ] || return 1 [ $(($(date +%s) - $($_KAC_STAT_COMMAND "$1"))) -gt "$2" ] && return 1 || return 0
[ $(( $(date +%s) - $($_KAC_STAT_COMMAND "$1") )) -gt $2 ] && return 1 || return 0
} }
# helper function for _KAC_get_and_regen_cache, see doc below # helper function for _KAC_get_and_regen_cache, see doc below
_KAC_regen_cache() _KAC_regen_cache() {
{ local CACHE_NAME=$1
local CACHE_NAME=$1 local CACHE_PATH="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/$CACHE_NAME"
local CACHE_PATH="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/$CACHE_NAME" local TMP_FILE=$(mktemp "$_KAC_CACHE_TMP_DIR/$CACHE_NAME.XXXX")
local TMP_FILE=$(mktemp "$_KAC_CACHE_TMP_DIR/$CACHE_NAME.XXXX") shift 1
shift 1 # discard the temp file if it's empty AND the previous command didn't exit successfully, but still mark the cache as updated
"$@" > $TMP_FILE 2> /dev/null if ! "$@" > "$TMP_FILE" 2> /dev/null; then
# discard the temp file if it's empty AND the previous command didn't exit successfully, but still mark the cache as updated [[ $(wc -l "$TMP_FILE") == 0 ]] && rm -f "$TMP_FILE" && touch "$CACHE_PATH" && return 1
[[ $? != 0 ]] && [[ $(cat $TMP_FILE | wc -l) == 0 ]] && rm -f $TMP_FILE && touch $CACHE_PATH && return 1 \ else
|| mv -f $TMP_FILE $CACHE_PATH mv -f "$TMP_FILE" "$CACHE_PATH"
fi
} }
# cached files can't have spaces in their names # cached files can't have spaces in their names
_KAC_get_cache_name_from_command() _KAC_get_cache_name_from_command() {
{ echo "${@/ /_SPACE_}"
echo "$@" | sed 's/ /_SPACE_/g'
} }
# the reverse operation from the function above # the reverse operation from the function above
_KAC_get_command_from_cache_name() _KAC_get_command_from_cache_name() {
{ echo "${@/_SPACE_/ }"
echo "$@" | sed 's/_SPACE_/ /g'
} }
# given a command as argument, it fetches the cache for that command if it can find it # given a command as argument, it fetches the cache for that command if it can find it
# otherwise it waits for the cache to be generated # otherwise it waits for the cache to be generated
# in either case, it regenerates the cache, and sets the _KAC_CACHE_PATH env variable # in either case, it regenerates the cache, and sets the _KAC_CACHE_PATH env variable
# for obvious reason, do NOT call that in a sub-shell (in particular, no piping) # for obvious reason, do NOT call that in a sub-shell (in particular, no piping)
_KAC_get_and_regen_cache() _KAC_get_and_regen_cache() {
{ # the cache name can't have space in it
# the cache name can't have space in it local CACHE_NAME=$(_KAC_get_cache_name_from_command "$@")
local CACHE_NAME=$(_KAC_get_cache_name_from_command "$@") local REGEN_CMD="_KAC_regen_cache $CACHE_NAME $*"
local REGEN_CMD="_KAC_regen_cache $CACHE_NAME $@" _KAC_CACHE_PATH="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/$CACHE_NAME"
_KAC_CACHE_PATH="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/$CACHE_NAME" # no need to wait for the regen if the file already exists
# no need to wait for the regen if the file already exists if [[ -f "$_KAC_CACHE_PATH" ]]; then
[ -f $_KAC_CACHE_PATH ] && ($REGEN_CMD &) || $REGEN_CMD ($REGEN_CMD &)
else
$REGEN_CMD
fi
} }
# performs two things: first, deletes all obsolete temp files # performs two things: first, deletes all obsolete temp files
# then refreshes stale caches that haven't been called in a long time # then refreshes stale caches that haven't been called in a long time
_KAC_clean_cache() _KAC_clean_cache() {
{ local FILE CMD
local FILE CMD # delete all obsolete temp files, could be lingering there for any kind of crash in the caching process
# delete all obsolete temp files, could be lingering there for any kind of crash in the caching process for FILE in "$_KAC_CACHE_TMP_DIR"/*; do
for FILE in $(ls $_KAC_CACHE_TMP_DIR) _KAC_is_file_newer_than "$FILE" "$_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE" || rm -f "$FILE"
do done
_KAC_is_file_newer_than $FILE $_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE || rm -f $FILE # refresh really stale caches
done find "$_KNIFE_AUTOCOMPLETE_CACHE_DIR" -maxdepth 1 -type f -not -name '.*' \
# refresh really stale caches | while read -r FILE; do
for FILE in $(find $_KNIFE_AUTOCOMPLETE_CACHE_DIR -maxdepth 1 -type f -not -name '.*') _KAC_is_file_newer_than "$FILE" "$_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE" && continue
do # first let's get the original command
_KAC_is_file_newer_than $FILE $_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE && continue CMD=$(_KAC_get_command_from_cache_name "$(basename "$FILE")")
# first let's get the original command # then regen the cache
CMD=$(_KAC_get_command_from_cache_name $(basename "$FILE")) _KAC_get_and_regen_cache "$CMD" > /dev/null
# then regen the cache done
_KAC_get_and_regen_cache "$CMD" > /dev/null
done
} }
# perform a cache cleaning when loading this file # perform a cache cleaning when loading this file
_KAC_clean_cache # On big systems this could baloon up to a 30 second run or more, so not enabling by default.
[[ "${KNIFE_CACHE_CLEAN}" ]] && _KAC_clean_cache
##################################### #####################################
### End of cache helper functions ### ### End of cache helper functions ###
##################################### #####################################
# returns all the possible knife sub-commands # returns all the possible knife sub-commands
_KAC_knife_commands() _KAC_knife_commands() {
{ knife --help | grep -E "^knife" | sed -E 's/ \(options\)//g'
knife --help | grep -E "^knife" | sed -E 's/ \(options\)//g'
} }
# rebuilds the knife base command currently being completed, and assigns it to $_KAC_CURRENT_COMMAND # rebuilds the knife base command currently being completed, and assigns it to $_KAC_CURRENT_COMMAND
# additionnally, returns 1 iff the current base command is not complete, 0 otherwise # additionnally, returns 1 iff the current base command is not complete, 0 otherwise
# also sets $_KAC_CURRENT_COMMAND_NB_WORDS if the base command is complete # also sets $_KAC_CURRENT_COMMAND_NB_WORDS if the base command is complete
_KAC_get_current_base_command() _KAC_get_current_base_command() {
{ local PREVIOUS="knife"
local PREVIOUS="knife" local I=1
local I=1 local CURRENT
local CURRENT while [ $I -le "$COMP_CWORD" ]; do
while [ $I -le $COMP_CWORD ] # command words are all lower-case
do echo "${COMP_WORDS[$I]}" | grep -E "^[a-z]+$" > /dev/null || break
# command words are all lower-case CURRENT="$PREVIOUS ${COMP_WORDS[$I]}"
echo ${COMP_WORDS[$I]} | grep -E "^[a-z]+$" > /dev/null || break grep -E "^$CURRENT" "$_KAC_CACHE_PATH" > /dev/null || break
CURRENT="$PREVIOUS ${COMP_WORDS[$I]}" PREVIOUS=$CURRENT
cat $_KAC_CACHE_PATH | grep -E "^$CURRENT" > /dev/null || break I=$((I + 1))
PREVIOUS=$CURRENT done
I=$(( $I + 1)) _KAC_CURRENT_COMMAND=$PREVIOUS
done [ $I -le "$COMP_CWORD" ] && _KAC_CURRENT_COMMAND_NB_WORDS=$I
_KAC_CURRENT_COMMAND=$PREVIOUS
[ $I -le $COMP_CWORD ] && _KAC_CURRENT_COMMAND_NB_WORDS=$I
} }
# searches the position of the currently completed argument in the current base command # searches the position of the currently completed argument in the current base command
# (i.e. handles "plural" arguments such as knife cookbook upload cookbook1 cookbook2 and so on...) # (i.e. handles "plural" arguments such as knife cookbook upload cookbook1 cookbook2 and so on...)
# assumes the current base command is complete # assumes the current base command is complete
_KAC_get_current_arg_position() _KAC_get_current_arg_position() {
{ local CURRENT_ARG_POS=$((_KAC_CURRENT_COMMAND_NB_WORDS + 1))
local CURRENT_ARG_POS=$(( $_KAC_CURRENT_COMMAND_NB_WORDS + 1 )) local COMPLETE_COMMAND=$(grep -E "^$_KAC_CURRENT_COMMAND" "$_KAC_CACHE_PATH")
local COMPLETE_COMMAND=$(cat $_KAC_CACHE_PATH | grep -E "^$_KAC_CURRENT_COMMAND") local CURRENT_ARG
local CURRENT_ARG while [ "$CURRENT_ARG_POS" -le "$COMP_CWORD" ]; do
while [ $CURRENT_ARG_POS -le $COMP_CWORD ] CURRENT_ARG=$(echo "$COMPLETE_COMMAND" | cut -d ' ' -f "$CURRENT_ARG_POS")
do # we break if the current arg is a "plural" arg
CURRENT_ARG=$(echo $COMPLETE_COMMAND | cut -d ' ' -f $CURRENT_ARG_POS) echo "$CURRENT_ARG" | grep -E "^\\[[^]]+(\\.\\.\\.\\]|$)" > /dev/null && break
# we break if the current arg is a "plural" arg CURRENT_ARG_POS=$((CURRENT_ARG_POS + 1))
echo $CURRENT_ARG | grep -E "^\\[[^]]+(\\.\\.\\.\\]|$)" > /dev/null && break done
CURRENT_ARG_POS=$(( $CURRENT_ARG_POS + 1 )) echo "$CURRENT_ARG_POS"
done
echo $CURRENT_ARG_POS
} }
# the actual auto-complete function # the actual auto-complete function
_knife() _knife() {
{ _KAC_get_and_regen_cache _KAC_knife_commands
_KAC_get_and_regen_cache _KAC_knife_commands local RAW_LIST ITEM REGEN_CMD ARG_POSITION
local RAW_LIST ITEM REGEN_CMD ARG_POSITION COMREPLY=()
COMREPLY=() # get correct command & arg pos
# get correct command & arg pos _KAC_get_current_base_command && ARG_POSITION=$(_KAC_get_current_arg_position) || ARG_POSITION=$((COMP_CWORD + 1))
_KAC_get_current_base_command && ARG_POSITION=$(_KAC_get_current_arg_position) || ARG_POSITION=$(( $COMP_CWORD + 1 )) RAW_LIST=$(grep -E "^$_KAC_CURRENT_COMMAND" "$_KAC_CACHE_PATH" | cut -d ' ' -f $ARG_POSITION | uniq)
RAW_LIST=$(cat $_KAC_CACHE_PATH | grep -E "^$_KAC_CURRENT_COMMAND" | cut -d ' ' -f $ARG_POSITION | uniq)
# we need to process that raw list a bit, most notably for placeholders # we need to process that raw list a bit, most notably for placeholders
# NOTE: I chose to explicitely fetch & cache _certain_ informations for the server (cookbooks & node names, etc) # NOTE: I chose to explicitely fetch & cache _certain_ informations for the server (cookbooks & node names, etc)
# as opposed to a generic approach by trying to find a 'list' knife command corresponding to the # as opposed to a generic approach by trying to find a 'list' knife command corresponding to the
# current base command - that might limit my script in some situation, but that way I'm sure it caches only # current base command - that might limit my script in some situation, but that way I'm sure it caches only
# not-sensitive stuff (a generic approach could be pretty bad e.g. with the knife-rackspace plugin) # not-sensitive stuff (a generic approach could be pretty bad e.g. with the knife-rackspace plugin)
LIST="" LIST=""
for ITEM in $RAW_LIST for ITEM in $RAW_LIST; do
do # always relevant if only lower-case chars : continuation of the base command
# always relevant if only lower-case chars : continuation of the base command echo "$ITEM" | grep -E "^[a-z]+$" > /dev/null && LIST="$LIST $ITEM" && continue
echo $ITEM | grep -E "^[a-z]+$" > /dev/null && LIST="$LIST $ITEM" && continue case "$ITEM" in
case $ITEM in *COOKBOOK*)
*COOKBOOK*) # special case for cookbooks : from site or local
# special case for cookbooks : from site or local [[ ${COMP_WORDS[2]} == 'site' ]] && REGEN_CMD="knife cookbook site list" || REGEN_CMD="knife cookbook list"
[[ ${COMP_WORDS[2]} == 'site' ]] && REGEN_CMD="knife cookbook site list" || REGEN_CMD="knife cookbook list" _KAC_get_and_regen_cache "$REGEN_CMD"
_KAC_get_and_regen_cache $REGEN_CMD LIST="$LIST $(cut -d ' ' -f 1 < "$_KAC_CACHE_PATH")"
LIST="$LIST $(cat $_KAC_CACHE_PATH | cut -d ' ' -f 1)" continue
continue ;;
;; *ITEM*)
*ITEM*) # data bag item : another special case
# data bag item : another special case local DATA_BAG_NAME=${COMP_WORDS[$((COMP_CWORD - 1))]}
local DATA_BAG_NAME=${COMP_WORDS[$(( COMP_CWORD-1 ))]} REGEN_CMD="knife data bag show $DATA_BAG_NAME"
REGEN_CMD="knife data bag show $DATA_BAG_NAME" ;;
;; *INDEX*)
*INDEX*) # see doc @ http://docs.opscode.com/knife_search.html
# see doc @ http://docs.opscode.com/knife_search.html LIST="$LIST client environment node role"
LIST="$LIST client environment node role" REGEN_CMD="knife data bag list"
REGEN_CMD="knife data bag list" ;;
;; *BAG*) REGEN_CMD="knife data bag list" ;;
*BAG*) REGEN_CMD="knife data bag list";; *CLIENT*) REGEN_CMD="knife client list" ;;
*CLIENT*) REGEN_CMD="knife client list";; *NODE*) REGEN_CMD="knife node list" ;;
*NODE*) REGEN_CMD="knife node list";; *ENVIRONMENT*) REGEN_CMD="knife environment list" ;;
*ENVIRONMENT*) REGEN_CMD="knife environment list";; *ROLE*) REGEN_CMD="knife role list" ;;
*ROLE*) REGEN_CMD="knife role list";; *USER*) REGEN_CMD="knife user list" ;;
*USER*) REGEN_CMD="knife user list";; # not a generic argument we support...
# not a generic argument we support... *) continue ;;
*) continue;; esac
esac _KAC_get_and_regen_cache "$REGEN_CMD"
_KAC_get_and_regen_cache $REGEN_CMD LIST="$LIST $(cat "$_KAC_CACHE_PATH")"
LIST="$LIST $(cat $_KAC_CACHE_PATH)" done
done # shellcheck disable=SC2207,SC2086
COMPREPLY=( $(compgen -W "${LIST}" -- ${COMP_WORDS[COMP_CWORD]})) COMPREPLY=($(compgen -W "${LIST}" -- ${COMP_WORDS[COMP_CWORD]}))
} }
#complete -f -F _knife knife
complete -F _knife knife complete -F _knife knife

View File

@@ -13,4 +13,3 @@ if command -v laravel > /dev/null; then
complete -F __laravel_completion laravel complete -F __laravel_completion laravel
fi fi

View File

@@ -1,4 +1,3 @@
if _command_exists ng; then if _command_exists ng; then
# No longer supported, please see https://github.com/angular/angular-cli/issues/11043 # No longer supported, please see https://github.com/angular/angular-cli/issues/11043
# Fix courtesy of https://stackoverflow.com/questions/50194674/ng-completion-no-longer-exists # Fix courtesy of https://stackoverflow.com/questions/50194674/ng-completion-no-longer-exists

View File

@@ -1,164 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
cite "about-completion"
about-completion "packer completion"
# Packer (http://www.packer.io) bash completion if _binary_exists packer; then
# complete -C packer packer
# This script provides bash completion for packer and supports: fi
#
# - template filename completion (*.json) in cwd
# - support for basic options (i.e.. -debug)
# - support for complex options (i.e. -parallel=[true|false]
#
# The scirpt has been successfully tested with packer-0.6.0 and the
# following OS:
#
# - OS X 10.9
# - CentOS-6.5
# - Ubuntu 12.04 Server
#
# The script technically is heavily inspired by the git-completion.bash
# script. Kudos to Shawn O. Pearce <spearce@spearce.org> and all other
# contributors for the inspiration and especially to the bash-completion
# team in general.
#
# Copyright (c) 2014 IT Services Department, University of Bern
#
# This script is licensed under the MIT License (MIT)
# For licsense details see the LICENSE file included in the repository
# or read the license text at http://opensource.org/licenses/MIT.
#
# Generates completion reply, appending a space to possible completion words,
# if necessary.
# It accepts 2 arguments though the second is optional:
# 1: List of possible completion words.
# 2: Generate possible completion matches for this word (optional).
__packercomp ()
{
local cur_="${2-$cur}"
case "$cur_" in
-*=)
;;
*)
local c i=0 IFS=$' \t\n'
for c in $1; do
if [[ $c == "$cur_"* ]]; then
case $c in
-*=*|*.) ;;
*) c="$c " ;;
esac
COMPREPLY[i++]="$c"
fi
done
;;
esac
}
# Generates completion reply for template files in cwd.
__packercomp_template_file ()
{
local IFS=$'\n'
COMPREPLY=($(compgen -S " " -A file -X '!*.json' -- "${cur}"))
}
# Generates completion for the build command.
__packer_build ()
{
local builders="
amazon-ebs amazon-instance amazon-chroot digitalocean docker
googlecompute openstack parallels-iso parallels-pvm qemu
virtualbox-iso virtualbox-ovf vmware-iso vmware-vmx"
case "$cur" in
-parallel=*)
__packercomp "false true" "${cur##-parallel=}"
return
;;
-except=*)
__packercomp "$builders" "${cur##-except=}"
return
;;
-only=*)
__packercomp "$builders" "${cur##-only=}"
return
;;
-*)
__packercomp "-debug -force -machine-readable -except= -only= -parallel= -var -var-file"
return
;;
*)
esac
__packercomp_template_file
}
# Generates completion for the fix command.
__packer_fix ()
{
__packercomp_template_file
}
# Generates completion for the inspect command.
__packer_inspect ()
{
case "$cur" in
-*)
__packercomp "-machine-readable"
return
;;
*)
esac
__packercomp_template_file
}
# Generates completion for the validate command.
__packer_validate ()
{
__packercomp_template_file
}
# Main function for packer completion.
#
# Searches for a command in $COMP_WORDS. If one is found
# the appropriate function from above is called, if not
# completion for global options is done.
_packer_completion ()
{
cur=${COMP_WORDS[COMP_CWORD]}
# Words containing an equal sign get split into tokens in bash > 4, which
# doesn't come in handy here.
# This is handled here. bash < 4 does not split.
declare -f _get_comp_words_by_ref >/dev/null && _get_comp_words_by_ref -n = cur
COMPREPLY=()
local i c=1 command
while [ $c -lt $COMP_CWORD ]; do
i="${COMP_WORDS[c]}"
case "$i" in
-*) ;;
*) command="$i"; break ;;
esac
((c++))
done
if [ -z $command ]; then
case "$cur" in
'-'*)
__packercomp "-machine-readable --help --version"
;;
*)
__packercomp "build fix inspect validate"
;;
esac
return
fi
local completion_func="__packer_${command}"
declare -f $completion_func >/dev/null && $completion_func
}
complete -o nospace -F _packer_completion packer

View File

@@ -8,4 +8,3 @@
if command -v pip3 >/dev/null; then if command -v pip3 >/dev/null; then
eval "$(pip3 completion --bash)" eval "$(pip3 completion --bash)"
fi fi

View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
# pipx completion
if _command_exists register-python-argcomplete && _command_exists pipx; then
eval "$(register-python-argcomplete pipx)"
fi

View File

@@ -44,4 +44,3 @@ _pj() {
complete -F _pj -o nospace pj complete -F _pj -o nospace pj
complete -F _pj -o nospace pjo complete -F _pj -o nospace pjo

View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# rustup (Rust toolchain installer) completion
if _binary_exists rustup; then
eval "$(rustup completions bash)"
fi

View File

@@ -1,3 +1,18 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Copyright (c) 2020 SaltStack Team
# Original Author:
# written by David Pravec # written by David Pravec
# - feel free to /msg alekibango on IRC if you want to talk about this file # - feel free to /msg alekibango on IRC if you want to talk about this file
@@ -35,10 +50,10 @@ _salt(){
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ ${COMP_CWORD} -gt 2 ]; then if [ ${COMP_CWORD} -gt 2 ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}" pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi fi
if [ ${COMP_CWORD} -gt 3 ]; then if [ ${COMP_CWORD} -gt 3 ]; then
ppprev="${COMP_WORDS[COMP_CWORD-3]}" ppprev="${COMP_WORDS[COMP_CWORD-3]}"
fi fi
opts="-h --help -d --doc --documentation --version --versions-report -c \ opts="-h --help -d --doc --documentation --version --versions-report -c \
@@ -96,7 +111,7 @@ _salt(){
-G|--grain|--grain-pcre) -G|--grain|--grain-pcre)
COMPREPLY=($(compgen -W "$(_salt_get_grains)" -- ${cur})) COMPREPLY=($(compgen -W "$(_salt_get_grains)" -- ${cur}))
return 0 return 0
;; ;;
-C|--compound) -C|--compound)
COMPREPLY=() # TODO: finish this one? how? COMPREPLY=() # TODO: finish this one? how?
return 0 return 0
@@ -110,7 +125,7 @@ _salt(){
return 0 return 0
;; ;;
-N|--nodegroup) -N|--nodegroup)
MASTER_CONFIG='/etc/salt/master' MASTER_CONFIG='/etc/salt/master'
COMPREPLY=($(compgen -W "`awk -F ':' 'BEGIN {print_line = 0}; /^nodegroups/ {print_line = 1;getline } print_line && /^ */ {print $1} /^[^ ]/ {print_line = 0}' <${MASTER_CONFIG}`" -- ${cur})) COMPREPLY=($(compgen -W "`awk -F ':' 'BEGIN {print_line = 0}; /^nodegroups/ {print_line = 1;getline } print_line && /^ */ {print $1} /^[^ ]/ {print_line = 0}' <${MASTER_CONFIG}`" -- ${cur}))
return 0 return 0
;; ;;
@@ -193,7 +208,7 @@ _saltkey(){
return 0 return 0
;; ;;
--accept-all) --accept-all)
return 0 return 0
;; ;;
esac esac
COMPREPLY=($(compgen -W "${opts} " -- ${cur})) COMPREPLY=($(compgen -W "${opts} " -- ${cur}))
@@ -230,21 +245,21 @@ _saltcall(){
fi fi
case ${prev} in case ${prev} in
-m|--module-dirs) -m|--module-dirs)
COMPREPLY=( $(compgen -d ${cur} )) COMPREPLY=( $(compgen -d ${cur} ))
return 0 return 0
;; ;;
-l|--log-level) -l|--log-level)
COMPREPLY=( $(compgen -W "info none garbage trace warning error debug" -- ${cur})) COMPREPLY=( $(compgen -W "info none garbage trace warning error debug" -- ${cur}))
return 0 return 0
;; ;;
-g|grains) -g|grains)
return 0 return 0
;; ;;
salt-call) salt-call)
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0 return 0
;; ;;
esac esac
_salt_coms="$(salt-call --out=txt -- sys.list_functions|sed 's/^.*\[//' | tr -d ",']" )" _salt_coms="$(salt-call --out=txt -- sys.list_functions|sed 's/^.*\[//' | tr -d ",']" )"
@@ -279,46 +294,46 @@ _saltcp(){
fi fi
case ${prev} in case ${prev} in
salt-cp) salt-cp)
COMPREPLY=($(compgen -W "${opts} `salt-key -l acc --no-color`" -- ${cur})) COMPREPLY=($(compgen -W "${opts} `salt-key -l acc --no-color`" -- ${cur}))
return 0 return 0
;; ;;
-t|--timeout) -t|--timeout)
# those numbers are just a hint # those numbers are just a hint
COMPREPLY=($(compgen -W "2 3 4 8 10 15 20 25 30 40 60 90 120 180 240 300" -- ${cur} )) COMPREPLY=($(compgen -W "2 3 4 8 10 15 20 25 30 40 60 90 120 180 240 300" -- ${cur} ))
return 0 return 0
;; ;;
-E|--pcre) -E|--pcre)
COMPREPLY=($(compgen -W "`salt-key -l acc --no-color`" -- ${cur})) COMPREPLY=($(compgen -W "`salt-key -l acc --no-color`" -- ${cur}))
return 0 return 0
;; ;;
-L|--list) -L|--list)
# IMPROVEMENTS ARE WELCOME # IMPROVEMENTS ARE WELCOME
prefpart="${cur%,*}," prefpart="${cur%,*},"
postpart=${cur##*,} postpart=${cur##*,}
filt="^\($(echo ${cur}| sed 's:,:\\|:g')\)$" filt="^\($(echo ${cur}| sed 's:,:\\|:g')\)$"
helper=($(salt-key -l acc --no-color | grep -v "${filt}" | sed "s/^/${prefpart}/")) helper=($(salt-key -l acc --no-color | grep -v "${filt}" | sed "s/^/${prefpart}/"))
COMPREPLY=($(compgen -W "${helper[*]}" -- ${cur})) COMPREPLY=($(compgen -W "${helper[*]}" -- ${cur}))
return 0 return 0
;; ;;
-G|--grain|--grain-pcre) -G|--grain|--grain-pcre)
COMPREPLY=($(compgen -W "$(_salt_get_grains)" -- ${cur})) COMPREPLY=($(compgen -W "$(_salt_get_grains)" -- ${cur}))
return 0 return 0
;; ;;
# FIXME # FIXME
-R|--range) -R|--range)
# FIXME ?? # FIXME ??
return 0 return 0
;; ;;
-C|--compound) -C|--compound)
# FIXME ?? # FIXME ??
return 0 return 0
;; ;;
-c|--config) -c|--config)
COMPREPLY=($(compgen -f -- ${cur})) COMPREPLY=($(compgen -f -- ${cur}))
return 0 return 0
;; ;;
esac esac
# default is using opts: # default is using opts:
@@ -326,4 +341,3 @@ _saltcp(){
} }
complete -F _saltcp salt-cp complete -F _saltcp salt-cp

View File

@@ -28,4 +28,3 @@ __kitchen_options () {
esac esac
} }
complete -F __kitchen_options kitchen complete -F __kitchen_options kitchen

View File

@@ -3,7 +3,6 @@
# tmux completion # tmux completion
# See: http://www.debian-administration.org/articles/317 for how to write more. # See: http://www.debian-administration.org/articles/317 for how to write more.
# Usage: Put "source bash_completion_tmux.sh" into your .bashrc # Usage: Put "source bash_completion_tmux.sh" into your .bashrc
# Based upon the example at http://paste-it.appspot.com/Pj4mLycDE
_tmux_expand () _tmux_expand ()
{ {
@@ -185,4 +184,3 @@ _tmux() {
complete -F _tmux tmux complete -F _tmux tmux
# END tmux completion # END tmux completion

View File

@@ -1,70 +1,2 @@
# link: https://github.com/ginatrapani/todo.txt-cli/blob/master/todo_completion _log_error 'Bash completion for "todo.txt-cli" is now deprecated, as it used code with incompatible license.
Please disable this completion and use the instructions from "todo.txt-cli" developers instead.'
_todo()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
local -r OPTS="-@ -@@ -+ -++ -d -f -h -p -P -PP -a -n -t -v -vv -V -x"
local -r COMMANDS="\
add a addto addm append app archive command del \
rm depri dp do help list ls listaddons listall lsa listcon \
lsc listfile lf listpri lsp listproj lsprj move \
mv prepend prep pri p replace report shorthelp"
local -r MOVE_COMMAND_PATTERN='^(move|mv)$'
local _todo_sh=${_todo_sh:-todo.sh}
local completions
if [ $COMP_CWORD -eq 1 ]; then
completions="$COMMANDS $(eval TODOTXT_VERBOSE=0 $_todo_sh command listaddons) $OPTS"
elif [[ $COMP_CWORD -gt 2 && ( \
"${COMP_WORDS[COMP_CWORD-2]}" =~ $MOVE_COMMAND_PATTERN || \
"${COMP_WORDS[COMP_CWORD-3]}" =~ $MOVE_COMMAND_PATTERN ) ]]; then
completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listfile)
else
case "$prev" in
command)
completions=$COMMANDS;;
help)
completions="$COMMANDS $(eval TODOTXT_VERBOSE=0 $_todo_sh command listaddons)";;
addto|listfile|lf)
completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listfile);;
-*) completions="$COMMANDS $(eval TODOTXT_VERBOSE=0 $_todo_sh command listaddons) $OPTS";;
*) case "$cur" in
+*) completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listproj)
COMPREPLY=( $( compgen -W "$completions" -- $cur ))
[ ${#COMPREPLY[@]} -gt 0 ] && return 0
completions=$(eval 'TODOTXT_VERBOSE=0 TODOTXT_SOURCEVAR=\$DONE_FILE' $_todo_sh command listproj)
;;
@*) completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listcon)
COMPREPLY=( $( compgen -W "$completions" -- $cur ))
[ ${#COMPREPLY[@]} -gt 0 ] && return 0
completions=$(eval 'TODOTXT_VERBOSE=0 TODOTXT_SOURCEVAR=\$DONE_FILE' $_todo_sh command listcon)
;;
*) if [[ "$cur" =~ ^[0-9]+$ ]]; then
local todo=$( \
eval TODOTXT_VERBOSE=0 $_todo_sh '-@ -+ -p -x command ls "^ *${cur} "' | \
sed -e 's/^ *[0-9]\{1,\} //' -e 's/^\((.) \)\{0,1\}[0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} /\1/' \
-e 's/^\([xX] \)\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{1,2\}/\1/' \
-e 's/[[:space:]]*$//' \
-e '1q' \
)
[ "$todo" ] && COMPREPLY[0]="$cur # $todo"
return 0
else
return 0
fi
;;
esac
;;
esac
fi
COMPREPLY=( $( compgen -W "$completions" -- $cur ))
return 0
}
complete -F _todo todo.sh
complete -F _todo t

View File

@@ -1,51 +1,7 @@
# --------------------------------------------------------------------------- #!/usr/bin/env bash
# vault-bash-completion cite "about-completion"
# about-completion "vault completion"
# This adds bash completions for [HashiCorp Vault](https://www.vaultproject.io/)
#
# see https://github.com/iljaweis/vault-bash-completion
# ---------------------------------------------------------------------------
function _vault_mounts() { if _binary_exists vault; then
( complete -C vault vault
set -euo pipefail fi
if ! vault mounts 2> /dev/null | awk 'NR > 1 {print $1}'; then
echo "secret"
fi
)
}
function _vault() {
local VAULT_COMMANDS=$(vault 2>&1 | egrep '^ +' | awk '{print $1}')
local cur
local prev
if [ $COMP_CWORD -gt 0 ]; then
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
fi
local line=${COMP_LINE}
if [[ $prev =~ ^(policies|policy-write|policy-delete) ]]; then
local policies=$(vault policies 2> /dev/null)
COMPREPLY=($(compgen -W "$policies" -- $cur))
elif [ "$(echo $line | wc -w)" -le 2 ]; then
if [[ "$line" =~ ^vault\ (read|write|delete|list)\ $ ]]; then
COMPREPLY=($(compgen -W "$(_vault_mounts)" -- ''))
else
COMPREPLY=($(compgen -W "$VAULT_COMMANDS" -- $cur))
fi
elif [[ "$line" =~ ^vault\ (read|write|delete|list)\ (.*)$ ]]; then
path=${BASH_REMATCH[2]}
if [[ "$path" =~ ^([^ ]+)/([^ /]*)$ ]]; then
list=$(vault list -format=yaml ${BASH_REMATCH[1]} 2> /dev/null | awk '{ print $2 }')
COMPREPLY=($(compgen -W "$list" -P "${BASH_REMATCH[1]}/" -- ${BASH_REMATCH[2]}))
else
COMPREPLY=($(compgen -W "$(_vault_mounts)" -- $path))
fi
fi
}
complete -o default -o nospace -F _vault vault

View File

@@ -1,148 +1,2 @@
#!/usr/bin/env bash _log_error 'Bash completion for "virsh" is now deprecated, as it used code with incompatible license.
# bash completion for virsh - main CLI of libvirt Please disable this completion and use the instructions from "virsh" developers instead.'
# This script provides bash completion for virsh,
# borrowed from https://github.com/LuyaoHuang/virsh-bash-completion
_contain_cmd()
{
local e f
local array1=($1) array2=($2)
for e in "${array1[@]}"
do
for f in "${array2[@]}"
do
if [[ "$e" == "$f" ]] ; then
echo $e
return
fi
done
done
echo "notfound"
return
}
_virsh_list_networks()
{
local flag_all=$1 flags
if [ "$flag_all" -eq 1 ]; then
flags="--all"
else
flags="--inactive"
fi
virsh -q net-list $flags | cut -d\ -f2 | awk '{print $1}'
}
_virsh_list_domains()
{
local flag_all=$1 flags
if [ "$flag_all" -eq 1 ]; then
flags="--all"
else
flags="--inactive"
fi
virsh -q list $flags | cut -d\ -f7 | awk '{print $1}'
}
_virsh_list_pools()
{
local flag_all=$1 flags
if [ "$flag_all" -eq 1 ]; then
flags="--all"
else
flags="--inactive"
fi
virsh -q pool-list $flags | cut -d\ -f2 | awk '{print $1}'
}
_virsh_list_ifaces()
{
local flag_all=$1 flags
if [ "$flag_all" -eq 1 ]; then
flags="--all"
else
flags="--inactive"
fi
virsh -q iface-list $flags | cut -d\ -f2 | awk '{print $1}'
}
_virsh_list_nwfilters()
{
virsh -q nwfilter-list | cut -d\ -f4 | awk '{print $1}'
}
_virsh()
{
local cur prev cmds doms options nets pools cmds_help
local flag_all=1 array ret a b ifaces nwfilters files
# not must use bash-completion now :)
# _init_completion -s || return
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
cmds=$( echo "$(virsh -h| grep '^ ' | cut -d\ -f5)" \
"$(virsh -h| grep '\--' | cut -d\ -f7 | cut -d= -f1)")
cmds_help=$(virsh help| grep '^ ' | cut -d\ -f5)
case "$prev" in
--domain)
doms=$(_virsh_list_domains "$flag_all")
COMPREPLY=( $(compgen -W "$doms" -- "$cur") )
return 0
;;
--network)
nets=$(_virsh_list_networks "$flag_all")
COMPREPLY=( $(compgen -W "$nets" -- "$cur") )
return 0
;;
--pool)
pools=$(_virsh_list_pools "$flag_all")
COMPREPLY=( $(compgen -W "$pools" -- "$cur") )
return 0
;;
--interface)
ifaces=$(_virsh_list_ifaces "$flag_all")
COMPREPLY=( $(compgen -W "$ifaces" -- "$cur") )
return 0
;;
--nwfilter)
nwfilters=$(_virsh_list_nwfilters)
COMPREPLY=( $(compgen -W "$nwfilters" -- "$cur") )
return 0
;;
--file|--xml)
files=$(ls)
COMPREPLY=( $(compgen -W "$files" -- "$cur") )
return 0
;;
esac
array=$(IFS=$'\n'; echo "${COMP_WORDS[*]}")
ret=$(_contain_cmd "$array" "$cmds_help")
if [[ "$ret" != "notfound" && "$ret" != "$cur" ]]; then
a=$(virsh help "$ret" |grep '^ --'|cut -d\ -f5)
b=$(virsh help "$ret" |grep '^ \[--'|cut -d\ -f5|cut -d[ -f2|cut -d] -f1)
options=$( echo $a $b )
COMPREPLY=( $(compgen -W "$options" -- "$cur") )
return 0
fi
case "$cur" in
*)
COMPREPLY=( $(compgen -W "$cmds" -- "$cur") )
return 0
;;
esac
} &&
complete -o default -F _virsh virsh

View File

@@ -10,13 +10,13 @@ __vboxmanage_startvm() {
AVAILABLE="" AVAILABLE=""
for VM in $TOTAL; do for VM in $TOTAL; do
MATCH=0; MATCH=0;
for RUN in $RUNNING "x"; do for RUN in $RUNNING "x"; do
if [ "$VM" == "$RUN" ]; then if [ "$VM" == "$RUN" ]; then
MATCH=1 MATCH=1
fi fi
done done
(( $MATCH == 0 )) && AVAILABLE="$AVAILABLE $VM " (( $MATCH == 0 )) && AVAILABLE="$AVAILABLE $VM "
done done
echo $AVAILABLE echo $AVAILABLE
} }
@@ -26,14 +26,14 @@ __vboxmanage_list() {
PRUNED="" PRUNED=""
if [ "$1" == "long" ]; then if [ "$1" == "long" ]; then
for WORD in $INPUT; do for WORD in $INPUT; do
[ "$WORD" == "-l" ] && continue; [ "$WORD" == "-l" ] && continue;
[ "$WORD" == "--long" ] && continue; [ "$WORD" == "--long" ] && continue;
PRUNED="$PRUNED $WORD" PRUNED="$PRUNED $WORD"
done done
else else
PRUNED=$INPUT PRUNED=$INPUT
fi fi
echo $PRUNED echo $PRUNED
@@ -43,14 +43,14 @@ __vboxmanage_list() {
__vboxmanage_list_vms() { __vboxmanage_list_vms() {
VMS="" VMS=""
if [ "x$1" == "x" ]; then if [ "x$1" == "x" ]; then
SEPARATOR=" " SEPARATOR=" "
else else
SEPARATOR=$1 SEPARATOR=$1
fi fi
for VM in $(vboxmanage list vms | cut -d' ' -f1 | tr -d '"'); do for VM in $(vboxmanage list vms | cut -d' ' -f1 | tr -d '"'); do
[ "$VMS" != "" ] && VMS="${VMS}${SEPARATOR}" [ "$VMS" != "" ] && VMS="${VMS}${SEPARATOR}"
VMS="${VMS}${VM}" VMS="${VMS}${VM}"
done done
echo $VMS echo $VMS
@@ -59,14 +59,14 @@ __vboxmanage_list_vms() {
__vboxmanage_list_runningvms() { __vboxmanage_list_runningvms() {
VMS="" VMS=""
if [ "$1" == "" ]; then if [ "$1" == "" ]; then
SEPARATOR=" " SEPARATOR=" "
else else
SEPARATOR=$1 SEPARATOR=$1
fi fi
for VM in $(vboxmanage list runningvms | cut -d' ' -f1 | tr -d '"'); do for VM in $(vboxmanage list runningvms | cut -d' ' -f1 | tr -d '"'); do
[ "$VMS" != "" ] && VMS="${VMS}${SEPARATOR}" [ "$VMS" != "" ] && VMS="${VMS}${SEPARATOR}"
VMS="${VMS}${VM}" VMS="${VMS}${VM}"
done done
echo $VMS echo $VMS
@@ -102,40 +102,40 @@ __vboxmanage_default() {
# echo "DEBUG: cur: $cur, prev: $prev" # echo "DEBUG: cur: $cur, prev: $prev"
# echo "DEBUG: default: |$p1|$p2|$p3|$p4|" # echo "DEBUG: default: |$p1|$p2|$p3|$p4|"
case ${cur} in case ${cur} in
-*) -*)
echo $opts echo $opts
# COMPREPLY=($(compgen -W "${opts}" -- ${cur})) # COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0 return 0
;; ;;
esac; esac;
for WORD in $opts; do for WORD in $opts; do
MATCH=0 MATCH=0
for OPT in "${COMP_WORDS[@]}"; do for OPT in "${COMP_WORDS[@]}"; do
# opts=$(echo ${opts} | grep -v $OPT); # opts=$(echo ${opts} | grep -v $OPT);
if [ "$OPT" == "$WORD" ]; then if [ "$OPT" == "$WORD" ]; then
MATCH=1 MATCH=1
break; break;
fi fi
if [ "$OPT" == "-v" ] && [ "$WORD" == "--version" ]; then if [ "$OPT" == "-v" ] && [ "$WORD" == "--version" ]; then
MATCH=1 MATCH=1
break; break;
fi fi
if [ "$OPT" == "--version" ] && [ "$WORD" == "-v" ]; then if [ "$OPT" == "--version" ] && [ "$WORD" == "-v" ]; then
MATCH=1 MATCH=1
break; break;
fi fi
if [ "$OPT" == "-q" ] && [ "$WORD" == "--nologo" ]; then if [ "$OPT" == "-q" ] && [ "$WORD" == "--nologo" ]; then
MATCH=1 MATCH=1
break; break;
fi fi
if [ "$OPT" == "--nologo" ] && [ "$WORD" == "-q" ]; then if [ "$OPT" == "--nologo" ] && [ "$WORD" == "-q" ]; then
MATCH=1 MATCH=1
break; break;
fi fi
done done
(( $MATCH == 1 )) && continue; (( $MATCH == 1 )) && continue;
pruned="$pruned $WORD" pruned="$pruned $WORD"
done done
@@ -156,65 +156,65 @@ _vboxmanage() {
# In case current is complete command # In case current is complete command
case $cur in case $cur in
startvm|list|controlvm) startvm|list|controlvm)
COMPREPLY=($(compgen -W "$cur ")) COMPREPLY=($(compgen -W "$cur "))
return 0 return 0
;; ;;
esac esac
case $prev in case $prev in
-v|--version) -v|--version)
return 0 return 0
;; ;;
-l|--long) -l|--long)
opts=$(__vboxmanage_list "long") opts=$(__vboxmanage_list "long")
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0 return 0
;; ;;
startvm|list) startvm|list)
opts=$(__vboxmanage_$prev) opts=$(__vboxmanage_$prev)
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0 return 0
;; ;;
--type) --type)
COMPREPLY=($(compgen -W "gui headless" -- ${cur})) COMPREPLY=($(compgen -W "gui headless" -- ${cur}))
return 0 return 0
;; ;;
gui|headless) gui|headless)
# Done. no more completion possible # Done. no more completion possible
return 0 return 0
;; ;;
vboxmanage|-q|--nologo) vboxmanage|-q|--nologo)
# echo "Got vboxmanage" # echo "Got vboxmanage"
opts=$(__vboxmanage_default) opts=$(__vboxmanage_default)
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0 return 0
;; ;;
controlvm) controlvm)
opts=$(__vboxmanage_list_vms) opts=$(__vboxmanage_list_vms)
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0 return 0
;; ;;
esac esac
for VM in $(__vboxmanage_list_vms); do for VM in $(__vboxmanage_list_vms); do
if [ "$VM" == "$prev" ]; then if [ "$VM" == "$prev" ]; then
pprev=${COMP_WORDS[COMP_CWORD-2]} pprev=${COMP_WORDS[COMP_CWORD-2]}
# echo "previous: $pprev" # echo "previous: $pprev"
case $pprev in case $pprev in
startvm) startvm)
opts="--type" opts="--type"
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0 return 0
;; ;;
controlvm) controlvm)
opts=$(__vboxmanage_controlvm) opts=$(__vboxmanage_controlvm)
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0; return 0;
;; ;;
esac esac
fi fi
done done
# echo "Got to end withoug completion" # echo "Got to end withoug completion"

View File

@@ -13,4 +13,3 @@ if command -v wpscan > /dev/null; then
complete -F __wpscan_completion wpscan complete -F __wpscan_completion wpscan
fi fi

20
docs/Makefile Normal file
View File

@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

58
docs/README.md Normal file
View File

@@ -0,0 +1,58 @@
# Bash-it
![Build Status](https://github.com/Bash-it/bash-it/workflows/CI/badge.svg?branch=master)
![Docs Status](https://readthedocs.org/projects/bash-it/badge/)
[![Join the chat at https://webchat.freenode.net/?channel=#bash-it](https://img.shields.io/badge/chat-on%20freenode-brightgreen.svg)](https://webchat.freenode.net/?channel=#bash-it)
**Bash-it** is a collection of community Bash commands and scripts for Bash 3.2+.
(And a shameless ripoff of [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) :smiley:)
Includes autocompletion, themes, aliases, custom functions, a few stolen pieces from Steve Losh, and more.
Bash-it provides a solid framework for using, developing and maintaining shell scripts and custom commands for your daily work.
If you're using the _Bourne Again Shell_ (Bash) regularly and have been looking for an easy way on how to keep all of these nice little scripts and aliases under control, then Bash-it is for you!
Stop polluting your `~/bin` directory and your `.bashrc` file, fork/clone Bash-it and start hacking away.
- [Main Page](https://bash-it.readthedocs.io/en/latest)
- [Contributing](#contributing)
- [Installation](#installation)
- [Install Options](https://bash-it.readthedocs.io/en/latest/installation/#install-options)
- [via Docker](https://bash-it.readthedocs.io/en/latest/installation/#install-using-docker)
- [Updating](https://bash-it.readthedocs.io/en/latest/installation/#updating)
- [Help](https://bash-it.readthedocs.io/en/latest/misc/#help-screens)
- [Search](https://bash-it.readthedocs.io/en/latest/commands/search)
- [Syntax](https://bash-it.readthedocs.io/en/latest/commands/search/#syntax)
- [Searching with Negations](
https://bash-it.readthedocs.io/en/latest/commands/search/#searching-with-negations)
- [Using Search to Enable or Disable Components](https://bash-it.readthedocs.io/en/latest/commands/search/#using-search-to-enable-or-disable-components)
- [Disabling ASCII Color](https://bash-it.readthedocs.io/en/latest/commands/search/#disabling-ascii-color)
- [Custom scripts, aliases, themes, and functions](
https://bash-it.readthedocs.io/en/latest/custom)
- [Themes](https://bash-it.readthedocs.io/en/latest/themes)
- [Uninstalling](https://bash-it.readthedocs.io/en/latest/uninstalling)
- [Misc](https://bash-it.readthedocs.io/en/latest/misc)
- [Help Out](https://bash-it.readthedocs.io/en/latest/#help-out)
- [Contributors](#contributors)
## Installation
1) Check out a clone of this repo to a location of your choice, such as
``git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it``
2) Run ``~/.bash_it/install.sh``
Thats it! :smiley:
You can check out more components of Bash-it, and customize it to your desire.
For more information, see detailed instructions [here](https://bash-it.readthedocs.io/en/latest/installation/).
## Contributing
Please take a look at the [Contribution Guidelines](https://bash-it.readthedocs.io/en/latest/contributing) before reporting a bug or providing a new feature.
The [Development Guidelines](https://bash-it.readthedocs.io/en/latest/development) have more information on some of the internal workings of Bash-it,
please feel free to read through this page if you're interested in how Bash-it loads its components.
## Contributors
* [List of contributors][contribute]
[contribute]: https://github.com/Bash-it/bash-it/contributors

0
docs/_static/.keep vendored Normal file
View File

0
docs/_templates/.keep vendored Normal file
View File

20
docs/commands/doctor.rst Normal file
View File

@@ -0,0 +1,20 @@
.. _doctor:
Bash-it doctor
^^^^^^^^^^^^^^
If you encounter problems with any part of Bash-it, run the following command:
.. code-block:: bash
bash-it doctor
This will reload your bash profile and print out logs of various parts in Bash-it.
Note that this command at default will print all logs, including debug logs.
You can call it like this:
.. code-block:: bash
bash-it doctor [errors/warnings/all]
In order to get wanted verbosity.

15
docs/commands/index.rst Normal file
View File

@@ -0,0 +1,15 @@
.. _commands:
Bash-it Commands
================
**Bash-it** boasts a wide range of available commands.
You should be familiar with them in order to fully utilize Bash-it.
.. toctree::
:maxdepth: 1
update
search
reload
doctor

10
docs/commands/reload.rst Normal file
View File

@@ -0,0 +1,10 @@
.. _reload:
Bash-it reload
^^^^^^^^^^^^^^
Bash-it creates a ``reload`` alias that makes it convenient to reload
your Bash profile when you make changes.
Additionally, if you export ``BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE`` as a non-null value,
Bash-it will automatically reload itself after activating or deactivating plugins, aliases, or completions.

59
docs/commands/search.rst Normal file
View File

@@ -0,0 +1,59 @@
.. _searching:
Bash-it search
--------------
If you need to quickly find out which of the plugins, aliases or completions are available for a specific framework, programming language, or an environment, you can *search* for multiple terms related to the commands you use frequently.
Search will find and print out modules with the name or description matching the terms provided.
Syntax
^^^^^^
.. code-block:: bash
bash-it search term1 [[-]term2] [[-]term3]....
As an example, a ruby developer might want to enable everything related to the commands such as ``ruby``\ , ``rake``\ , ``gem``\ , ``bundler``\ , and ``rails``.
Search command helps you find related modules so that you can decide which of them you'd like to use:
.. code-block:: bash
bash-it search ruby rake gem bundle irb rails
aliases: bundler rails
plugins: chruby chruby-auto ruby
completions: bundler gem rake
Currently enabled modules will be shown in green.
Searching with Negations
^^^^^^^^^^^^^^^^^^^^^^^^
You can prefix a search term with a "-" to exclude it from the results.
In the above example, if we wanted to hide ``chruby`` and ``chruby-auto``\ ,
we could change the command as follows:
.. code-block:: bash
bash-it search ruby rake gem bundle irb rails -chruby
aliases: bundler rails
plugins: ruby
completions: bundler gem rake
Using Search to Enable or Disable Components
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
By adding a ``--enable`` or ``--disable`` to the search command, you can automatically enable all modules that come up as a result of a search query.
This could be quite handy if you like to enable a bunch of components related to the same topic.
Disabling ASCII Color
^^^^^^^^^^^^^^^^^^^^^
To remove non-printing non-ASCII characters responsible for the coloring of the search output, you can set environment variable ``NO_COLOR``.
Enabled components will then be shown with a checkmark:
.. code-block:: bash
NO_COLOR=1 bash-it search ruby rake gem bundle irb rails -chruby
aliases => ✓bundler ✓rails
plugins => ✓ruby
completions => bundler gem rake

38
docs/commands/update.rst Normal file
View File

@@ -0,0 +1,38 @@
.. _update:
Bash-it update
^^^^^^^^^^^^^^
To update Bash-it to the latest stable version, simply run:
.. code-block:: bash
bash-it update stable
If you want to update to the latest dev version (directly from master), run:
.. code-block:: bash
bash-it update dev
If you want to update automatically and unattended, you can add the optional
``-s/--silent`` flag, for example:
.. code-block:: bash
bash-it update dev --silent
.. _migrate:
Bash-it migrate
^^^^^^^^^^^^^^^
If you are using an older version of Bash-it, it's possible that some functionality has changed, or that the internal structure of how Bash-it organizes its functionality has been updated.
For these cases, we provide a ``migrate`` command:
.. code-block:: bash
bash-it migrate
This command will automatically migrate the Bash-it structure to the latest version.
The ``migrate`` command is run automatically if you run the ``update``\ , ``enable`` or ``disable`` commands.

57
docs/conf.py Normal file
View File

@@ -0,0 +1,57 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# -- Project information -----------------------------------------------------
project = 'Bash-it'
copyright = '2020, Bash-it Team'
author = 'Bash-it Team'
# The full version, including alpha/beta/rc tags
release = ''
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx_rtd_theme',
'sphinxemoji.sphinxemoji',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

118
docs/contributing.rst Normal file
View File

@@ -0,0 +1,118 @@
.. _contributing:
Contribution Guidelines
=======================
When contributing a new feature, a bug fix, a new theme, or any other change to Bash-it, please consider the following guidelines.
Most of this is common sense, but please try to stick to the conventions listed here.
Issues
------
* When opening a new issue in the issue tracker, please include information about which *Operating System* you're using, and which version of *Bash*.
* In many cases, it also makes sense to show which Bash-it plugins you are using.
This information can be obtained using ``bash-it show plugins``.
* If the issue happens while loading Bash-it, please also include your ``~/.bash_profile`` or ``~/.bashrc`` file,
as well as the install location of Bash-it (default should be ``~/.bash_it``\ ).
* When reporting a bug or requesting a new feature, consider providing a Pull Request that fixes the issue or can be used as a starting point for the new feature.
Don't be afraid, most things aren't that complex...
Pull Requests
-------------
* Fork the Bash-it repo, create a new feature branch from *master* and apply your changes there.
Create a *Pull Request* from your feature branch against Bash-it's *master* branch.
* Limit each Pull Request to one feature.
Don't bundle multiple features/changes (e.g. a new *Theme* and a fix to an existing plugin) into a single Pull Request - create one PR for the theme, and a separate PR for the fix.
* For complex changes, try to *squash* your changes into a single commit before
pushing code. Once you've pushed your code and opened a PR, please refrain
from force-pushing changes to the PR branch remember, Bash-it is a
distributed project and your branch may be in use already.
* When in doubt, open a PR with too many commits. Bash-it is a learning project
for everyone involved. Showing your work provides a great history for folks
to learn what works and what didn't.
Code Style
----------
* When adding new files, be sure to add them into `clean_files.txt`, which is a growing list of linted files in the project.
* When changing existing files, consider also adding them into `clean_files.txt` and fixing the linting errors that arise. See :ref:`linting_your_changes` for more information.
* Indentation is using tabs, not spaces. Most of the code is indented with 2 spaces, some with 4 spaced tabs. Please try to stick to tabs.
If you're using an editor that supports `EditorConfig <http://EditorConfig.org>`_\ , the editor should automatically use the settings defined in Bash-it's `.editorconfig file <.editorconfig>`_.
* When creating new functions, please use a dash ("-") to separate the words of the function's name, e.g. ``my-new-function``.
Don't use underscores, e.g. ``my_new_function``.
* Internal functions that aren't to be used by the end user should start with an underscore, e.g. ``_my-new-internal-function``.
* Use the provided meta functions to document your code, e.g. ``about-plugin``\ , ``about``\ , ``group``\ , ``param``\ , ``example``.
This will make it easier for other people to use your new functionality.
Take a look at the existing code for an example (e.g. `the base plugin <plugins/available/base.plugin.bash>`_\ ).
* When adding files, please use the existing file naming conventions, e.g. plugin files need to end in ``.plugin.bash``.
This is important for the installation functionality.
* When using the ``$BASH_IT`` variable, please always enclose it in double quotes to ensure that the code also works when Bash-it is installed in a directory that contains spaces in its name: ``for f in "${BASH_IT}/plugins/available"/*.bash ; do echo "$f" ; done``
* Bash-it supports Bash 3.2 and higher. Please don't use features only available in Bash 4, such as associative arrays.
Unit Tests
----------
When adding features or making changes/fixes, please run our growing unit test suite to ensure that you did not break existing functionality.
The test suite does not cover all aspects of Bash-it, but please run it anyway to verify that you did not introduce any regression issues.
Any code pushed to GitHub as part of a Pull Request will automatically trigger a continuous integration build on `Travis CI <https://travis-ci.org/Bash-it/bash-it>`_\ , where the test suite is run on both Linux and macOS.
The Pull Request will then show the result of the Travis build, indicating whether all tests ran fine, or whether there were issues.
Please pay attention to this, Pull Requests with build issues will not be merged.
Adding new functionality or changing existing functionality is a good opportunity to increase Bash-it's test coverage.
When you're changing the Bash-it codebase, please consider adding some unit tests that cover the new or changed functionality.
Ideally, when fixing a bug, a matching unit test that verifies that the bug is no longer present, is added at the same time.
To run the test suite, simply execute the following in the directory where you cloned Bash-it:
.. code-block:: bash
test/run
This command will ensure that the `Bats Test Framework <https://github.com/bats-core/bats-core>`_ is available in the local ``test_lib`` directory (Bats is included as a Git submodule) and then run the test suite found in the `test <test>`_ folder.
The test script will execute each test in turn, and will print a status for each test case.
When adding new test cases, please take a look at the existing test cases for examples.
The following libraries are used to help with the tests:
* Test Framework: https://github.com/bats-core/bats-core
* Support library for Bats-Assert: https://github.com/ztombol/bats-support
* General ``assert`` functions: https://github.com/ztombol/bats-assert
* File ``assert`` functions: https://github.com/ztombol/bats-file
When verifying test results, please try to use the ``assert`` functions found in these libraries.
Features
--------
* When adding new completions or plugins, please don't simply copy existing tools into the Bash-it codebase, try to load/integrate the tools instead.
An example is using ``nvm``\ : Instead of copying the existing ``nvm`` script into Bash-it, the ``nvm.plugin.bash`` file tries to load an existing installation of ``nvm``.
This means an additional step for the user (installing ``nvm`` from its own repo, or through a package manager),
but it will also ensure that ``nvm`` can be upgraded in an easy way.
.. _contributing_theme:
Themes
------
* When adding a new theme, please include a screenshot and a short description about what makes this theme unique in the Pull Request's description field.
Please do not add theme screenshots to the main PR itself, as they will add unnecessary bloat to the main branch in the repo.
The project's docs has a `Themes page <https://github.com/Bash-it/bash-it/blob/master/docs/themes-list/index.rst>`_ where you should add a screenshot, see how :ref:`here<add_screenshot>`.
* Ideally, you should add a ``<theme_name>.rst`` file describing the theme and its configuration options to ``docs/themes-list`` folder.
.. _add_screenshot:
Adding a Screenshot
-------------------
In order to add a new screenshot, use the ``gh-pages`` branch.
Add your new screenshot to the ``docs/images`` folder, and open a PR.
In the `Themes page <https://github.com/Bash-it/bash-it/blob/master/docs/themes-list/index.rst>`_, see the other screenshots to know what kind of link you should use.

18
docs/custom.rst Normal file
View File

@@ -0,0 +1,18 @@
.. _custom:
Custom Content
--------------
For custom scripts, and aliases, just create the following files (they'll be ignored by the git repo):
* ``aliases/custom.aliases.bash``
* ``completion/custom.completion.bash``
* ``lib/custom.bash``
* ``plugins/custom.plugins.bash``
* ``custom/themes/<custom theme name>/<custom theme name>.theme.bash``
Anything in the custom directory will be ignored, with the exception of ``custom/example.bash``.
Alternately, if you would like to keep your custom scripts under version control, you can set ``BASH_IT_CUSTOM`` in your ``~/.bashrc`` to another location outside of the ``$BASH_IT`` folder.
In this case, any ``*.bash`` file under every directory below ``BASH_IT_CUSTOM`` folder will be used.

112
docs/development.rst Normal file
View File

@@ -0,0 +1,112 @@
.. _development:
Bash-it Development
===================
This page summarizes a couple of rules to keep in mind when developing features or making changes in Bash-it.
Testing
-------
Make sure to read the :ref:`testing docs<test>`.
Debugging and Logging
---------------------
General Logging
^^^^^^^^^^^^^^^
While developing feature or making changes in general, you can log error/warning/debug
using ``_log_error`` ``_log_warning`` and ``_log_debug``. This will help you solve problems quicker
and also propagate important notes to other users of Bash-it.
You can see the logs by using ``bash-it doctor`` command to reload and see the logs.
Alternatively, you can set ``BASH_IT_LOG_LEVEL`` to ``BASH_IT_LOG_LEVEL_ERROR``\ , ``BASH_IT_LOG_LEVEL_WARNING`` or ``BASH_IT_LOG_LEVEL_ALL``.
Log Prefix/Context
^^^^^^^^^^^^^^^^^^
You can define ``BASH_IT_LOG_PREFIX`` in your files in order to a have a constant prefix before your logs.
Note that we prefer to uses "tags" based logging, i.e ``plugins: git: DEBUG: Loading git plugin``.
Load Order
----------
General Load Order
^^^^^^^^^^^^^^^^^^
The main ``bash_it.sh`` script loads the frameworks individual components in the following order:
* ``lib/composure.bash``
* Files in ``lib`` with the exception of ``appearance.bash`` - this means that ``composure.bash`` is loaded again here (possible improvement?)
* Enabled ``aliases``
* Enabled ``plugins``
* Enabled ``completions``
* ``themes/colors.theme.bash``
* ``themes/base.theme.bash``
* ``lib/appearance.bash``\ , which loads the selected theme
* Custom ``aliases``
* Custom ``plugins``
* Custom ``completions``
* Additional custom files from either ``$BASH_IT/custom`` or ``$BASH_IT_CUSTOM``
This order is subject to change.
Individual Component Load Order
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
For ``aliases``\ , ``plugins`` and ``completions``\ , the following rules are applied that influence the load order:
* There is a global ``enabled`` directory, which the enabled components are linked into. Enabled plugins are symlinked from ``$BASH_IT/plugins/available`` to ``$BASH_IT/enabled`` for example. All component types are linked into the same common ``$BASH_IT/enabled`` directory.
* Within the common ``enabled`` directories, the files are loaded in alphabetical order, which is based on the item's load priority (see next item).
* When enabling a component, a *load priority* is assigned to the file. The following default priorities are used:
* Aliases: 150
* Plugins: 250
* Completions: 350
* When symlinking a component into the ``enabled`` directory, the load priority is used as a prefix for the linked name, separated with three dashes from the name of the component. The ``node.plugin.bash`` would be symlinked to ``250---node.plugin.bash`` for example.
*
Each file can override the default load priority by specifying a new value. To do this, the file needs to include a comment in the following form. This example would cause the ``node.plugin.bash`` (if included in that file) to be linked to ``225---node.plugin.bash``\ :
.. code-block:: bash
# BASH_IT_LOAD_PRIORITY: 225
Having the order based on a numeric priority in a common directory allows for more flexibility. While in general, aliases are loaded first (since their default priority is 150), it's possible to load some aliases after the plugins, or some plugins after completions by setting the items' load priority. This is more flexible than a fixed type-based order or a strict alphabetical order based on name.
These items are subject to change. When making changes to the internal functionality, this page needs to be updated as well.
Plugin Disable Callbacks
------------------------
Plugins can define a function that will be called when the plugin is being disabled.
The callback name should be ``{PLUGIN_NAME}_on_disable``\ , you can see ``gitstatus`` for usage example.
Using the pre-commit hook
-------------------------
Note the file .pre-commit-config.yaml at the top of the repo.
This file configures the behavior of the a pre-commit hook based on `the Pre-Commit framework <https://pre-commit.com/>`_. Please see the site about
installing it (with pip, brew or other tools) then run ``pre-commit install`` in the repo's root to activate the hook.
For the full use of the tool, you may need to install also other third-party tools, such as
`shellcheck <https://github.com/koalaman/shellcheck/>`_ and `shfmt <https://github.com/mvdan/sh>`_.
.. _linting_your_changes:
Linting Your Changes
--------------------
In order to properly lint your changes, you should use our linting script,
by simply running ``./lint_clean_files.sh``. This script iterates over all marked-as-clean
files, and runs the pre-commit hook on them.
Please note that most of the files in the project are currently not linted,
as we want to make the linting process easier.
In order to add your changed/added files to the linting process,
please add your files to ``clean_files.txt``. This way ``lint_clean_files.sh``
will know to pick them up and lint them.
Thank you for helping clean up Bash-it, and making it a nicer and better project |:heart:|

13
docs/help_screens.rst Normal file
View File

@@ -0,0 +1,13 @@
.. _help_screens:
Help Screens
^^^^^^^^^^^^
.. code-block:: bash
bash-it show aliases # shows installed and available aliases
bash-it show completions # shows installed and available completions
bash-it show plugins # shows installed and available plugins
bash-it help aliases # shows help for installed aliases
bash-it help completions # shows help for installed completions
bash-it help plugins # shows help for installed plugins

44
docs/index.rst Normal file
View File

@@ -0,0 +1,44 @@
Welcome to Bash-it's documentation!
===================================
**Bash-it** is a collection of community Bash commands and scripts for Bash 3.2+.
(And a shameless ripoff of `oh-my-zsh <https://github.com/robbyrussell/oh-my-zsh>`_)
Includes autocompletion, themes, aliases, custom functions, a few stolen pieces from Steve Losh, and more.
Bash-it provides a solid framework for using, developing and maintaining shell scripts and custom commands for your daily work.
If you're using the *Bourne Again Shell* (Bash) regularly and have been looking for an easy way on how to keep all of these nice little scripts and aliases under control, then Bash-it is for you!
Stop polluting your ``~/bin`` directory and your ``.bashrc`` file, fork/clone Bash-it and start hacking away.
.. toctree::
:maxdepth: 1
contributing
development
test
installation
commands/index
custom
themes
themes-list/index
vcs_user
misc
troubleshooting
uninstalling
Help out
--------
We think everyone has their own custom scripts accumulated over time.
And so, following in the footsteps of oh-my-zsh, Bash-it is a framework for easily customizing your Bash shell.
Everyone's got a custom toolbox, so let's start making them even better, **as a community!**
Send us a pull request and we'll merge it as long as it looks good.
If you change an existing command, please give an explanation why.
That will help a lot when we merge your changes in.
Please take a look at the :ref:`Contribution Guidelines <contributing>` before reporting a bug or providing a new feature.
Thanks, and happing bashing!

58
docs/installation.rst Normal file
View File

@@ -0,0 +1,58 @@
.. _installation:
Installation
------------
#. Check out a clone of this repo to a location of your choice, such as
``git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it``
#. Run ``~/.bash_it/install.sh`` (it automatically backs up your ``~/.bash_profile`` or ``~/.bashrc``\ , depending on your OS)
#. Edit your modified config (\ ``~/.bash_profile`` or ``~/.bashrc``\ ) file in order to customize Bash-it.
#. Check out available aliases, completions, and plugins and enable the ones you want to use (see the next section for more details).
Install Options
^^^^^^^^^^^^^^^
The install script can take the following options:
* ``--interactive``\ : Asks the user which aliases, completions and plugins to enable.
* ``--silent``\ : Ask nothing and install using default settings.
* ``--no-modify-config``\ : Do not modify the existing config file (\ ``~/.bash_profile`` or ``~/.bashrc``\ ).
* ``--append-to-config``\ : Back up existing config file and append bash-it templates at the end.
When run without the ``--interactive`` switch, Bash-it only enables a sane default set of functionality to keep your shell clean and to avoid issues with missing dependencies.
Feel free to enable the tools you want to use after the installation.
When you run without the ``--no-modify-config`` switch, the Bash-it installer automatically modifies/replaces your existing config file.
Use the ``--no-modify-config`` switch to avoid unwanted modifications, e.g. if your Bash config file already contains the code that loads Bash-it.
**NOTE**\ : Keep in mind how Bash loads its configuration files,
``.bash_profile`` for login shells (and in macOS in terminal emulators like `Terminal.app <http://www.apple.com/osx/apps/>`_ or
`iTerm2 <https://www.iterm2.com/>`_\ ) and ``.bashrc`` for interactive shells (default mode in most of the GNU/Linux terminal emulators),
to ensure that Bash-it is loaded correctly.
A good "practice" is sourcing ``.bashrc`` into ``.bash_profile`` to keep things working in all the scenarios.
To achieve this, you can add this snippet in your ``.bash_profile``\ :
.. code-block::
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
Refer to the official `Bash documentation <https://www.gnu.org/software/bash/manual/bashref.html#Bash-Startup-Files>`_ to get more info.
Install using Docker
^^^^^^^^^^^^^^^^^^^^
You can try Bash-it in an isolated environment without changing any local files via a `Docker <https://www.docker.com/>`_ Container.
(Bash Shell v4.4 with Bash-it, `bats <https://github.com/sstephenson/bats>`_\ ,and bash-completion based on `Alpine Linux <https://alpinelinux.org/>`_\ ).
``docker pull ellerbrock/bash-it``
Have a look at our `bash-it-docker repository <https://github.com/Bash-it/bash-it-docker>`_ for further information.
Updating
^^^^^^^^
See :ref:`update command <update>`.

35
docs/make.bat Normal file
View File

@@ -0,0 +1,35 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd

10
docs/misc.rst Normal file
View File

@@ -0,0 +1,10 @@
.. _misc:
Misc
----
.. toctree::
:maxdepth: 2
help_screens
proxy_support

43
docs/proxy_support.rst Normal file
View File

@@ -0,0 +1,43 @@
.. _proxy_support:
Proxy Support
^^^^^^^^^^^^^
If you are working in a corporate environment where you have to go through a proxy server for internet access,
then you know how painful it is to configure the OS proxy variables in the shell,
especially if you are switching between environments, e.g. office (with proxy) and home (without proxy).
The Bash shell (and many shell tools) use the following variables to define the proxy to use:
* ``HTTP_PROXY`` (and ``http_proxy``\ ): Defines the proxy server for HTTP requests
* ``HTTPS_PROXY`` (and ``https_proxy``\ ): Defines the proxy server for HTTPS requests
* ``ALL_PROXY`` (and ``all_proxy``\ ): Used by some tools for the same purpose as above
* ``NO_PROXY`` (and ``no_proxy``\ ): Comma-separated list of hostnames that don't have to go through the proxy
Bash-it's ``proxy`` plugin allows to enable and disable these variables with a simple command.
To start using the ``proxy`` plugin, run the following:
.. code-block:: bash
bash-it enable plugin proxy
Bash-it also provides support for enabling/disabling proxy settings for various shell tools.
The following backends are currently supported (in addition to the shell's environment variables): Git, SVN, npm, ssh.
The ``proxy`` plugin changes the configuration files of these tools to enable or disable the proxy settings.
Bash-it uses the following variables to set the shell's proxy settings when you call ``enable-proxy``.
These variables are best defined in a custom script in Bash-it's custom script folder (\ ``$BASH_IT/custom``\ ), e.g. ``$BASH_IT/custom/proxy.env.bash``
* ``BASH_IT_HTTP_PROXY`` and `BASH_IT_HTTPS_PROXY`: Define the proxy URL to be used, e.g. 'http://localhost:1234'
* ``BASH_IT_NO_PROXY``\ : A comma-separated list of proxy exclusions, e.g. ``127.0.0.1,localhost``
Once you have defined these variables (and have run ``reload`` to load the changes), you can use the following commands to enable or disable the proxy settings in your current shell:
* ``enable-proxy``\ : This sets the shell's proxy environment variables and configures proxy support in your SVN, npm, and SSH configuration files.
* ``disable-proxy``\ : This unsets the shell's proxy environment variables and disables proxy support in your SVN, npm, and SSH configuration files.
There are many more proxy commands, e.g. for changing the local Git project's proxy settings.
Run ``glossary proxy`` to show the available proxy functions with a short description.

3
docs/requirements.txt Normal file
View File

@@ -0,0 +1,3 @@
sphinx==3.2.1
sphinx-rtd-theme==0.5.0
sphinxemoji==0.1.8

46
docs/test.rst Normal file
View File

@@ -0,0 +1,46 @@
.. _test:
Testing Bash-it
===============
Overview
--------
The Bash-it unit tests leverage the `Bats unit test framework for Bash <https://github.com/bats-core/bats-core>`_.
There is no need to install Bats explicitly, the test run script will automatically download and install Bats and its dependencies.
When making changes to Bash-it, the tests are automatically executed in a test build environment on `Travis CI <https://travis-ci.com>`_.
Test Execution
--------------
To execute the unit tests, please run the ``run`` script:
.. code-block:: bash
# If you are in the `test` directory:
./run
# If you are in the root `.bash_it` directory:
test/run
The ``run`` script will automatically install if it is not already present, and will then run all tests found under the ``test`` directory, including subdirectories.
To run only a subset of the tests, you can provide the name of the test subdirectory that you want to run, e.g. like this for the tests in the ``test/themes`` directory:
.. code-block:: bash
# If you are in the root `.bash_it` directory:
test/run test/themes
By default, the tests run in single-threaded mode.
If you want to speed up the test execution, you can install the `GNU ``parallel`` tool <https://www.gnu.org/software/parallel/>`_\ , which is supported by Bats.
When using ``parallel``\ , the ``test/run`` script will use a number of threads in parallel, depending on the available CPU cores of your system.
This can speed up test execution significantly.
Writing Tests
-------------
When adding or modifying tests, please stick to the format and conventions of the existing test cases.
The ``test_helper.bash`` script provides a couple of reusable helper functions that you should use when writing a test case,
for example for setting up an isolated test environment.

200
docs/themes-list/atomic.rst Normal file
View File

@@ -0,0 +1,200 @@
.. _atomic:
Atomic theme
============
The Best ColorFull terminal prompt theme inspired by a number of themes and based on the theme of @MunifTanjim :ref:`brainy <brainy>`.
Supported on all operating systems.
In constant maintenance and improvement
.. image:: https://raw.githubusercontent.com/lfelipe1501/lfelipe-projects/master/AtomicTheme.gif
:target: https://raw.githubusercontent.com/lfelipe1501/lfelipe-projects/master/AtomicTheme.gif
:alt: Atomic-Theme
Install Theme
-------------
Manually
^^^^^^^^
You can install the theme manually by following these steps:
Edit your modified config ``~/.bashrc`` file in order to customize Bash-it, set ``BASH_IT_THEME`` to the theme name ``atomic``.
Examples:
.. code-block:: bash
# Use the "atomic" theme
export BASH_IT_THEME="atomic"
Automatically via terminal
^^^^^^^^^^^^^^^^^^^^^^^^^^
#. You can install the theme automatically using the ``sed`` command from your Linux or OSX Terminal.
#. On macOS, the ~/.bash_profile is used, not the ~/.bashrc.
#. For installation on windows you should use `\ ``Git-Bash`` <https://git-for-windows.github.io/>`_ or make sure the terminal emulator you use (ej: cygwin, mintty, etc) has the ``sed`` command installed.
Command to execute For Windows and Linux:
.. code-block:: bash
# Set the "atomic" theme replacing the theme you are using of bash-it
sed -i 's/'"$BASH_IT_THEME"'/atomic/g' ~/.bashrc
Command to execute for macOS:
.. code-block:: bash
# Set the "atomic" theme replacing the theme you are using of bash-it
sed -i '' 's/'"$BASH_IT_THEME"'/atomic/g' ~/.bash_profile
Features
--------
Prompt Segments
^^^^^^^^^^^^^^^
* Username & Hostname
* Current Directory
* SCM Information
* Battery Charge
* Clock
* `Todo.txt <https://github.com/ginatrapani/todo.txt-cli>`_ status
* Ruby Environment
* Python Environment
* Exit Code
Others
^^^^^^
* Indicator for cached ``sudo`` credential
* Indicator for abort (ctrl + C) the current task and regain user control
* ``atomic`` command for showing/hiding various prompt segments on-the-fly
Configuration
-------------
Various prompt segments can be shown/hidden or modified according to your choice. There are two ways for doing that:
#. On-the-fly using ``atomic`` command
#. Theme Environment Variables
On-the-fly using ``atomic`` command
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This theme provides a command for showing/hiding prompt segments.
``atomic show <segment>``
``atomic hide <segment>``
Tab-completion for this command is enabled by default.
Configuration specified by this command will only be applied to current and subsequent child shells.
Theme Environment Variables
^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is used for permanent settings that apply to all terminal sessions. You have to define the value of specific theme variables in your ``bashrc`` (or equivalent) file.
The name of the variables are listed below along with their default values.
User Information
~~~~~~~~~~~~~~~~
Indicator for cached ``sudo`` credential (see ``sudo`` manpage for more information):
``THEME_SHOW_SUDO=true``
SCM Information
~~~~~~~~~~~~~~~
Information about SCM repository status:
``THEME_SHOW_SCM=true``
Ruby Environment
~~~~~~~~~~~~~~~~
Ruby environment version information:
``THEME_SHOW_RUBY=false``
Python Environment
~~~~~~~~~~~~~~~~~~
Python environment version information:
``THEME_SHOW_PYTHON=false``
ToDo.txt status
~~~~~~~~~~~~~~~
`Todo.txt <https://github.com/ginatrapani/todo.txt-cli>`_ status:
``THEME_SHOW_TODO=false``
Clock
~~~~~
``THEME_SHOW_CLOCK=true``
``THEME_CLOCK_COLOR=$bold_cyan``
Format of the clock (see ``date`` manpage for more information):
``THEME_CLOCK_FORMAT="%H:%M:%S"``
Battery Charge
~~~~~~~~~~~~~~
Battery charge percentage:
``THEME_SHOW_BATTERY=false``
Exit Code
~~~~~~~~~
Exit code of the last command:
``THEME_SHOW_EXITCODE=true``
Prompt Segments Order
---------------------
Currently available prompt segments are:
* battery
* char
* clock
* dir
* exitcode
* python
* ruby
* scm
* todo
* user_info
Three environment variables can be defined to rearrange the segments order. The default values are:
``___ATOMIC_TOP_LEFT="user_info dir scm"``
``___ATOMIC_TOP_RIGHT="exitcode python ruby todo clock battery"``
``___ATOMIC_BOTTOM="char"``
Development by
^^^^^^^^^^^^^^
Developer / Author: `Luis Felipe Sánchez <https://github.com/lfelipe1501>`_
This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.

138
docs/themes-list/barbuk.rst Normal file
View File

@@ -0,0 +1,138 @@
.. _barbuk:
BarbUk theme
============
A minimal theme with a clean git prompt
Provided Information
--------------------
* Current git remote tool logo (support: github, gitlab, bitbucket)
* Current path (red when user is root)
* Current git info
* Last command exit code (only shown when the exit code is greater than 0)
* user@hostname for ssh connection
Fonts and glyphs
----------------
A font with SCM glyphs is required to display the default tool/host logos.
You can use a font from https://www.nerdfonts.com/ or patch your own font with the tool
provided by https://github.com/ryanoasis/nerd-fonts.
You can also override the default variables if you want to use different glyphs or standard ASCII characters.
Default theme glyphs
^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
BARBUK_GITLAB_CHAR=' '
BARBUK_BITBUCKET_CHAR=' '
BARBUK_GITHUB_CHAR=' '
BARBUK_GIT_DEFAULT_CHAR=' '
BARBUK_GIT_BRANCH_ICON=''
BARBUK_HG_CHAR='☿ '
BARBUK_SVN_CHAR='⑆ '
BARBUK_EXIT_CODE_ICON=' '
BARBUK_PYTHON_VENV_CHAR=' '
BARBUK_COMMAND_DURATION_ICON='  '
Customize glyphs
^^^^^^^^^^^^^^^^
Define your custom glyphs before sourcing bash-it:
.. code-block:: bash
export BARBUK_GITHUB_CHAR='•'
source "$BASH_IT"/bash_it.sh
SSH prompt
----------
Usage
^^^^^
When using a ssh session, the theme will display ``user@hostname``.
You can disable this information with ``BARBUK_SSH_INFO``.
The hostname is displayed in the FQDN format by default. You
can use the short hostname format with ``BARBUK_HOST_INFO``.
.. code-block:: bash
# short or long
export BARBUK_HOST_INFO=short
# true or false
export BARBUK_SSH_INFO=false
source "$BASH_IT"/bash_it.sh
Keep theme with sudoer
^^^^^^^^^^^^^^^^^^^^^^
If you want the theme to persist using ``sudo -s`` in a ssh session, you need to configure sudo to keep the ``HOME`` and ``SSH_CONNECTION`` environment variables.
``HOME`` contains the path to the home directory of the current user. Keeping it will allow to use your user dotfiles when elevating privileges.
Keeping ``SSH_CONNECTION`` env is necessary for ssh detection in the theme.
Please refer to the following documentation for more information:
* `sudo manual <https://www.sudo.ws/man/1.8.13/sudoers.man.html>`_ for ``env_keep`` configuration
* `openssh manual <https://linux.die.net/man/1/ssh>`_ for information about ``SSH_CONNECTION`` environment
.. code-block:: bash
cat << EOF > /etc/sudoers.d/keepenv
Defaults env_keep += HOME
Defaults env_keep += SSH_CONNECTION
EOF
chmod 400 /etc/sudoers.d/keepenv
Command duration
----------------
See :ref:`Command duration <command_duration>`.
Examples
--------
Clean
^^^^^
.. code-block:: bash
~
Git
^^^
.. code-block:: bash
 ~/.dotfiles on  master ⤏ origin ↑2 •7 ✗
Ssh
^^^
.. code-block:: bash
user@hostname in  ~/bash-it on  master ✓
Python venv
^^^^^^^^^^^
.. code-block:: bash
  flask ~/test on  master ✓
Command duration
^^^^^^^^^^^^^^^^
.. code-block:: bash
# sleep 3s
user@hostname in  ~/bash-it on  master ✓  3.2s

12
docs/themes-list/bira.rst Normal file
View File

@@ -0,0 +1,12 @@
.. _bira:
Bira Theme
==========
This is a port of Oh My Zsh's `'Bira' <https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/bira.zsh-theme>`_ theme. It looks the same as the original, except for the following changes:
* Exit code of last command is not shown
* More informative git prompt (if you want to keep it minimal, please read: :ref:`git_prompt`)
* Position and colour of virtualenv prompt
* No ruby version prompt

145
docs/themes-list/brainy.rst Normal file
View File

@@ -0,0 +1,145 @@
.. _brainy:
Brainy theme
============
Simple colorful terminal prompt theme (inspired by a number of themes).
Features
--------
Prompt Segments
^^^^^^^^^^^^^^^
* Username & Hostname
* Current Directory
* SCM Information
* Battery Charge
* Clock
* `Todo.txt <https://github.com/ginatrapani/todo.txt-cli>`_ status
* Ruby Environment
* Python Environment
* Exit Code
Others
^^^^^^
* Indicator for cached ``sudo`` credential
* Indicator for ssh login
* ``brainy`` command for showing/hiding various prompt segments on-the-fly
Configuration
-------------
Various prompt segments can be shown/hidden or modified according to your choice. There are two ways for doing that:
#. On-the-fly using ``brainy`` command
#. Theme Environment Variables
On-the-fly using ``brainy`` command
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This theme provides a command for showing/hiding prompt segments.
``brainy show <segment>``
``brainy hide <segment>``
Tab-completion for this command is enabled by default.
Configuration specified by this command will only be applied to current and subsequent child shells.
Theme Environment Variables
^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is used for permanent settings that apply to all terminal sessions. You have to define the value of specific theme variables in your ``bashrc`` (or equivalent) file.
The name of the variables are listed below along with their default values.
User Information
~~~~~~~~~~~~~~~~
Indicator for cached ``sudo`` credential (see ``sudo`` manpage for more information):
``THEME_SHOW_SUDO=true``
SCM Information
~~~~~~~~~~~~~~~
Information about SCM repository status:
``THEME_SHOW_SCM=true``
Ruby Environment
~~~~~~~~~~~~~~~~
Ruby environment version information:
``THEME_SHOW_RUBY=false``
Python Environment
~~~~~~~~~~~~~~~~~~
Python environment version information:
``THEME_SHOW_PYTHON=false``
ToDo.txt status
~~~~~~~~~~~~~~~
`Todo.txt <https://github.com/ginatrapani/todo.txt-cli>`_ status:
``THEME_SHOW_TODO=false``
Clock
~~~~~
``THEME_SHOW_CLOCK=true``
``THEME_CLOCK_COLOR=$bold_cyan``
Format of the clock (see ``date`` manpage for more information):
``THEME_CLOCK_FORMAT="%H:%M:%S"``
Battery Charge
~~~~~~~~~~~~~~
Battery charge percentage:
``THEME_SHOW_BATTERY=false``
Exit Code
~~~~~~~~~
Exit code of the last command:
``THEME_SHOW_EXITCODE=true``
Prompt Segments Order
---------------------
Currently available prompt segments are:
* battery
* char
* clock
* dir
* exitcode
* python
* ruby
* scm
* todo
* user_info
Three environment variables can be defined to rearrange the segments order. The default values are:
``___BRAINY_TOP_LEFT="user_info dir scm"``
``___BRAINY_TOP_RIGHT="python ruby todo clock battery"``
``___BRAINY_BOTTOM="exitcode char"``

View File

@@ -0,0 +1,28 @@
.. _codeword:
Codeword Theme
==============
Single line PS1 theme w/realtime history among windows.
Minimal theme overrides from bash_it base theming
``user@host:path[virt-env][scm] $``
---------------------------------------
Breakdown of the segments:
* **user@host:path** - *convienient for LAN based ``ssh`` and ``scp`` tasks*
* [\ **virtualenv**\ ] - *only appears when activated*
* [\ **scm**\ ] - *only appears when activated*
* **marker** - *$ or # depending on current user*
Examples
^^^^^^^^
.. code-block:: bash
user@example.lan:~ $ cd /tmp/foo/bar/baz
user@example.lan:/tmp/foo/bar/baz $ cd $HOME/workspace
user@example.lan:~/workspace $ cd sampleRepo/
user@example.lan:~/workspace/sampleRepo [± |master ↑1 ↓3 {1} S:2 ?:1 ✗|] $

570
docs/themes-list/index.rst Normal file
View File

@@ -0,0 +1,570 @@
.. _list_of_themes:
List of Themes
==============
Below is a list of most of the themes (with screenshots) and their documentation that `bash-it <https://github.com/Bash-it/bash-it/>`_ ships with.
.. note::
Not all themes have documentation!
.. toctree::
:maxdepth: 1
:caption: Documentation of Themes
:glob:
*
Alphabetical Screenshots List
-----------------------------
Bakke
^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/bakke-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/bakke-black.jpg
:alt: Bakke
.. image:: https://bash-it.github.io/bash-it/docs/images/bakke-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/bakke-white.jpg
:alt: Bakke
----
BarbUk
^^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/BarbUk-black.png
:target: https://bash-it.github.io/bash-it/docs/images/BarbUk-black.png
:alt: BarbUk
.. image:: https://bash-it.github.io/bash-it/docs/images/BarbUk-white.png
:target: https://bash-it.github.io/bash-it/docs/images/BarbUk-white.png
:alt: BarbUk
----
Bobby
^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/bobby-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/bobby-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/bobby-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/bobby-white.jpg
:alt:
----
Brunton
^^^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/brunton-black.png
:target: https://bash-it.github.io/bash-it/docs/images/brunton-black.png
:alt:
----
Candy
^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/candy-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/candy-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/candy-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/candy-white.jpg
:alt:
----
Clean
^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/clean-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/clean-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/clean-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/clean-white.jpg
:alt:
----
Demula
^^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/demula-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/demula-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/demula-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/demula-white.jpg
:alt:
----
DOS
^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/dos-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/dos-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/dos-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/dos-white.jpg
:alt:
----
DoubleTime
^^^^^^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/doubletime-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/doubletime-white.jpg
:alt:
----
DoubleTime Multiline
^^^^^^^^^^^^^^^^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline-white.jpg
:alt:
----
Doubletime Multiline Python Only
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline_pyonly-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline_pyonly-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline_pyonly-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline_pyonly-white.jpg
:alt:
----
Envy
^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/envy-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/envy-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/envy-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/envy-white.jpg
:alt:
----
Iterate
^^^^^^^
Responsively wraps prompt based on terminal width.
.. image:: https://cloud.githubusercontent.com/assets/1319655/2923152/3a763194-d70e-11e3-9e52-3740de9bbb9b.png
:target: https://cloud.githubusercontent.com/assets/1319655/2923152/3a763194-d70e-11e3-9e52-3740de9bbb9b.png
:alt:
.. image:: https://cloud.githubusercontent.com/assets/1319655/2923143/14b8e0d2-d70e-11e3-9706-f5341fff8e5c.png
:target: https://cloud.githubusercontent.com/assets/1319655/2923143/14b8e0d2-d70e-11e3-9706-f5341fff8e5c.png
:alt:
----
Mr Briggs
^^^^^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/mbriggs-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/mbriggs-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/mbriggs-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/mbriggs-white.jpg
:alt:
----
Minimal
^^^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/minimal-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/minimal-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/minimal-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/minimal-white.jpg
:alt:
----
Modern
^^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/modern-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/modern-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/modern-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/modern-white.jpg
:alt:
----
Modern T
^^^^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/modern-t-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/modern-t-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/modern-t-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/modern-t-white.jpg
:alt:
----
Metal
^^^^^
.. image:: https://raw.githubusercontent.com/jrab66/bash-it/7cc82b518d6286fc68c8477d809ce9f417501976/themes/metal/metalthemeblack.png
:target: https://raw.githubusercontent.com/jrab66/bash-it/7cc82b518d6286fc68c8477d809ce9f417501976/themes/metal/metalthemeblack.png
:alt:
----
n0Qorg
^^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/n0qorg-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/n0qorg-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/n0qorg-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/n0qorg-white.jpg
:alt:
----
.. _nwinkler_image:
NWinkler
^^^^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/nwinkler-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/nwinkler-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/nwinkler-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/nwinkler-white.jpg
:alt:
----
Pete
^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/pete-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/pete-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/pete-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/pete-white.jpg
:alt:
----
Powerline
^^^^^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/powerline-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/powerline-white.jpg
:alt:
----
Powerline Naked
^^^^^^^^^^^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-naked-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/powerline-naked-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-naked-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/powerline-naked-white.jpg
:alt:
----
Powerline Plain
^^^^^^^^^^^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-plain-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/powerline-plain-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-plain-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/powerline-plain-white.jpg
:alt:
----
Pure
^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/pure-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/pure-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/pure-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/pure-white.jpg
:alt:
----
RainbowBrite
^^^^^^^^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/rainbowbrite-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/rainbowbrite-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/rainbowbrite-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/rainbowbrite-white.jpg
:alt:
----
R Jorgenson
^^^^^^^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/rjorgenson-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/rjorgenson-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/rjorgenson-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/rjorgenson-white.jpg
:alt:
----
Sexy
^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/sexy-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/sexy-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/sexy-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/sexy-white.jpg
:alt:
----
Simple
^^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/simple-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/simple-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/simple-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/simple-white.jpg
:alt:
----
SirUp
^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/sirup-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/sirup-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/sirup-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/sirup-white.jpg
:alt:
----
Standard
^^^^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/standard-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/standard-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/standard-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/standard-white.jpg
:alt:
----
Tonka
^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/tonka-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/tonka-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/tonka-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/tonka-white.jpg
:alt:
----
Tylenol
^^^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/tylenol-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/tylenol-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/tylenol-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/tylenol-white.jpg
:alt:
----
Zitron
^^^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/zitron-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/zitron-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/zitron-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/zitron-white.jpg
:alt:
----
Zork
^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/zork-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/zork-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/zork-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/zork-white.jpg
:alt:

View File

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

View File

@@ -0,0 +1,39 @@
.. _nwinkler_random_color:
Nwinkler Random Color Theme
===========================
Description
-----------
The *Nwinkler Random Color* Theme is based on the :ref:`Nwinkler Theme <nwinkler_image>` , but it randomizes the colors for:
* time
* username
* hostname
* path
The random colors are chosen the first time this theme is used and saved to the ``~/.nwinkler_random_colors`` file. So, the next time you connect to the same machine, you will get the same colors.
To force new random colors to be selected, run the command:
.. code-block:: sh
randomize_nwinkler
Screenshot
----------
Here it is in action:
.. image:: nwinkler_random_colors.png
:target: nwinkler_random_colors.png
:alt: alt text
Usage Scenario
--------------
This theme is especially useful when connecting to many different machines and switching between them often. Yes, the hostname *is* present in the prompt. But I argue that it's a lot faster to get a "feel" of what machine you are currently on because of the custom colors on that machine's prompt than by reading the hostname.

View File

@@ -0,0 +1,127 @@
.. _powerline_base:
Base Powerline Theme Information
================================
This page explains base powerline theme information, shared between
all powerline themes.
**IMPORTANT:** This theme requires that `a font with the Powerline symbols <https://github.com/powerline/fonts>`_ needs to be used in your terminal emulator, otherwise the prompt won't be displayed correctly, i.e. some of the additional icons and characters will be missing. Please follow your operating system's instructions to install one of the fonts from the above link and select it in your terminal emulator.
**NOTICE:** The default behavior of this theme assumes that you have sudo privileges on your workstation. If that is not the case (e.g. if you are running on a corporate network where ``sudo`` usage is tracked), you can set the flag 'export THEME_CHECK_SUDO=false' in your ``~/.bashrc`` or ``~/.bash_profile`` to disable the Powerline theme's ``sudo`` check. This will apply to all ``powerline*`` themes.
Provided Information
--------------------
* Current path
* Current username and hostname
* Current time
* Current shell level
* Current dirstack level (\ ``pushd`` / ``popd``\ )
* Current history number
* Current command number
* An indicator when connected by SSH
* An indicator when ``sudo`` has the credentials cached (see the ``sudo`` manpage for more info about this)
* An indicator when the current shell is inside the Vim editor
* Battery charging status (depends on the battery plugin)
* SCM Repository status (e.g. Git, SVN)
* The current Kubernetes environment
* The current Python environment (Virtualenv, venv, and Conda are supported) in use
* The current Ruby environment (rvm and rbenv are supported) in use
* Last command exit code (only shown when the exit code is greater than 0)
Configuration
-------------
This theme is pretty configurable, all the configuration is done by setting environment variables.
User Information
^^^^^^^^^^^^^^^^
By default, the username and hostname are shown, but you can change this behavior by setting the value of the following variable:
.. code-block:: bash
export POWERLINE_PROMPT_USER_INFO_MODE="sudo"
For now, the only supported value is ``sudo``\ , which hides the username and hostname, and shows an indicator when ``sudo`` has the credentials cached. Other values have no effect at this time.
Clock Format
^^^^^^^^^^^^
You can change the format using the following variable:
.. code-block:: bash
export THEME_CLOCK_FORMAT="%H:%M:%S"
The time/date is printed by the ``date`` command, so refer to its man page to change the format.
Segment Order
^^^^^^^^^^^^^
The contents of the prompt can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are:
* ``aws_profile`` - Show the current value of the ``AWS_PROFILE`` environment variable
* ``battery`` - Battery information (you'll need to enable the ``battery`` plugin)
* ``clock`` - Current time in ``HH:MM:SS`` format
* ``cwd`` - Current working directory including full folder hierarchy (c.f. ``wd``\ )
* ``hostname`` - Host name of machine
* ``in_toolbox`` - Show identifier if running inside a `toolbox <https://github.com/containers/toolbox>`_
* ``in_vim`` - Show identifier if running in ``:terminal`` from vim
* ``k8s_context`` - Show current kubernetes context
* ``last_status`` - Exit status of last run command
* ``python_venv`` - Python virtual environment information (\ ``virtualenv``\ , ``venv``
and ``conda`` supported)
* ``ruby`` - Current ruby version if using ``rvm``
* ``node`` - Current node version (only ``nvm`` is supported)
* ``scm`` - Version control information, ``git``
* ``terraform`` - Current terraform workspace
* ``user_info`` - Current user
* ``wd`` - Working directory, like ``cwd`` but doesn't show the full folder
hierarchy, only the directory you're currently in.
* ``shlvl`` - Show the current shell level (based on ``SHLVL`` environment variable), but only if you are not in root shell
* ``dirstack`` - Show the current dirstack level (based on ``DIRSTACK`` environment variable), but only if the stack is not empty
* ``history_number`` - Show current history number
* ``command_number`` - Show current command number
A variable can be defined to set the order of the prompt segments:
.. code-block::
POWERLINE_PROMPT="user_info scm python_venv ruby cwd"
The example values above are the current default values, but if you want to remove anything from the prompt, simply remove the "string" that represents the segment from the variable.
.. _powerline_compact_settings:
Compact Settings
^^^^^^^^^^^^^^^^
You can configure various aspects of the prompt to use less whitespace. Supported variables are:
.. list-table::
:header-rows: 1
* - Variable
- Description
* - POWERLINE_COMPACT_BEFORE_SEPARATOR
- Removes the leading space before each separator
* - POWERLINE_COMPACT_AFTER_SEPARATOR
- Removes the trailing space after each separator
* - POWERLINE_COMPACT_BEFOR_FIRST_SEGMENT
- Removes the leading space on the first segment
* - POWERLINE_COMPACT_AFTER_LAST_SEGMENT
- Removes the trailing space on the last segment
* - POWERLINE_COMPACT_PROMPT
- Removes the space after the prompt character
* - POWERLINE_COMPACT
- Enable all Compact settings (you can still override individual settings)
The default value for all settings is ``0`` (disabled). Use ``1`` to enable.

View File

@@ -0,0 +1,36 @@
.. _powerline_multiline:
Powerline Multiline Theme
=========================
A colorful multiline theme, where the first line shows information about your shell session (divided into two parts, left and right), and the second one is where the shell commands are introduced.
See :ref:`powerline_base` for general information about the powerline theme.
Soft Separators
^^^^^^^^^^^^^^^
Adjacent segments having the same background color will use a less-pronouced (i.e. soft) separator between them.
Padding
^^^^^^^
To get the length of the left and right segments right, a *padding* value is used.
In most cases, the default value (\ *2*\ ) works fine, but on some operating systems, this needs to be adjusted.
One example is *macOS High Sierra*\ , where the default padding causes the right segment to extend to the next line.
On macOS High Sierra, the padding value needs to be changed to *3* to make the theme look right.
This can be done by setting the ``POWERLINE_PADDING`` variable before Bash-it is loaded, e.g. in your ``~/.bash_profile`` or ``~/.bashrc`` file:
.. code-block:: bash
export POWERLINE_PADDING=3
Multiline Mode Right Prompt
^^^^^^^^^^^^^^^^^^^^^^^^^^^
For the purposes of the :ref:`Compact <powerline_compact_settings>` settings, the segments within the **Right Prompt** are considered to run "right-to-left", i.e.:
* The **right-most** segment is considered to be the ``"first"`` segment, while the **left-most** segment is considered to be the ``"last"``
* The space to the **right** of the separator character is considered to be ``"before"``\ , while the space to the **left** is considered to be ``"after"``

View File

@@ -0,0 +1,9 @@
.. _powerline_naked:
Powerline Naked Theme
=====================
A colorful theme, where shows a lot information about your shell session.
The naked powerline theme provides a cleaner shell with less background colors.
See :ref:`powerline_base` for general information about the powerline theme.

View File

@@ -0,0 +1,14 @@
.. _powerline_plain:
Powerline Plain Theme
=====================
A colorful theme, where shows a lot information about your shell session.
The plain powerline theme provides a simpler shell with less information.
See :ref:`powerline_base` for general information about the powerline theme.
Soft Separators
^^^^^^^^^^^^^^^
Adjacent segments having the same background color will use a less-pronouced (i.e. soft) separator between them.

View File

@@ -0,0 +1,13 @@
.. _powerline:
Powerline Theme
===============
A colorful theme, where shows a lot information about your shell session.
See :ref:`powerline_base` for general information about the powerline theme.
Soft Separators
^^^^^^^^^^^^^^^
Adjacent segments having the same background color will use a less-pronouced (i.e. soft) separator between them.

View File

@@ -0,0 +1,25 @@
.. _radek:
Radek Theme
===========
A colorful theme for Python developers.
It does not have any requirements.
Provided Information
--------------------
* Current username and hostname
* Current path
* Git repository status
* Current Python environment (venv, Conda )
* Current Python version
Examples
--------
.. code-block:: bash
[radek@photon][~/src/nokia2/cbis] ±[master → origin ↑1 {1}][venv-cbis][py-3.7.5]

View File

Before

Width:  |  Height:  |  Size: 962 KiB

After

Width:  |  Height:  |  Size: 962 KiB

View File

@@ -0,0 +1,56 @@
.. _redline:
Redline Theme
=============
changed up the powerline base a little.
It plays nicest with this font: `DroidSansMonoForPowerline <https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/DroidSansMono>`_
Read the :ref:`powerline theme documentation <powerline>`
added
-----
* hostname
* distro logo
changed
-------
* sudo credential check
* required font
* some icons
Works real good like with:
.. code-block:: bash
## set the theme
export BASH_IT_THEME='redline'
# Set this to false to turn off version control status checking within the prompt for all themes
export SCM_CHECK=true
## Set Xterm/screen/Tmux title with only a short hostname.
export SHORT_HOSTNAME=$(hostname -s)
## enable sudo prompt
export POWERLINE_PROMPT_USER_INFO_MODE="sudo"
## prompt part string
export POWERLINE_PROMPT="python_venv user_info hostname cwd scm"
enable your distro logo with
----------------------------
.. code-block:: bash
export POWERLINE_PROMPT_DISTRO_LOGO="yes"
.. image:: redline.png
:target: redline.png?raw=true
:alt: screenshot

93
docs/themes.rst Normal file
View File

@@ -0,0 +1,93 @@
.. _themes:
Themes
------
There are over 50+ Bash-it themes to pick from in ``$BASH_IT/themes``.
The default theme is ``bobby``.
Set ``BASH_IT_THEME`` to the theme name you want, or if you've developed your own custom theme outside of ``$BASH_IT/themes``\ ,
point the ``BASH_IT_THEME`` variable directly to the theme file.
To disable theming completely, leave the variable empty.
Examples:
.. code-block:: bash
# Use the "powerline-multiline" theme
export BASH_IT_THEME="powerline-multiline"
# Use a theme outside of the Bash-it folder
export BASH_IT_THEME="/home/foo/my_theme/my_theme.theme.bash"
# Disable theming
export BASH_IT_THEME=""
You can easily preview the themes in your own shell using ``BASH_PREVIEW=true bash-it reload``.
If you've created your own custom prompts, we'd love it if you shared them with everyone else! Just submit a Pull Request.
You can see theme screenshots on `wiki/Themes <https://github.com/Bash-it/bash-it/wiki/Themes>`_.
**NOTE**\ : Bash-it and some themes use UTF-8 characters, so to avoid strange behavior in your terminal, set your locale to ``LC_ALL=en_US.UTF-8`` or the equivalent to your language if it isn't American English.
List of Themes
^^^^^^^^^^^^^^
See :ref:`here <list_of_themes>`.
Theme Switches & Variables
^^^^^^^^^^^^^^^^^^^^^^^^^^
.. _command_duration:
Command duration
================
Prints last command duration
Usage
#####
Command duration can be enabled by exporting ``BASH_IT_COMMAND_DURATION``:
.. code-block:: bash
export BASH_IT_COMMAND_DURATION=true
The default configuration display last command duration for command lasting one second or more.
You can customize the minimum time in seconds before command duration is displayed in your ``.bashrc``:
.. code-block:: bash
export COMMAND_DURATION_MIN_SECONDS=5
Clock Related
=============
function: ``clock_char``
########################
Prints a character indicating clock.
* ``THEME_SHOW_CLOCK_CHAR`` : **true**\ /false
* ``THEME_CLOCK_CHAR`` : "\ **⌚**\ "
* ``THEME_CLOCK_CHAR_COLOR`` : "\ **$normal**\ "
function: ``clock_prompt``
##########################
Prints the clock prompt (date, time).
* ``THEME_SHOW_CLOCK`` : **true**\ /false
* ``THEME_CLOCK_COLOR`` : "\ **$normal**\ "
* ``THEME_CLOCK_FORMAT`` : "\ **%H:%M:%S**\ "
Contributing a new theme
^^^^^^^^^^^^^^^^^^^^^^^^
See the :ref:`instructions <contributing_theme>`.

16
docs/troubleshooting.rst Normal file
View File

@@ -0,0 +1,16 @@
.. _troubleshooting:
Troubleshooting Guide
=====================
Table of Contents
-----------------
* `I'm stuck in the LightDM login screen after setting up bash-it. <im-stuck-in-the-lightdm-login-screen-after-setting-up-bash-it>`_
I'm stuck in the LightDM login screen after setting up bash-it
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**Possible issue**\ : `#672 <https://github.com/Bash-it/bash-it/issues/672>`_
**Solution**\ : Check `this comment <https://github.com/Bash-it/bash-it/issues/672#issuecomment-257870653>`_ for detailed information about the cause and solution for this issue.

14
docs/uninstalling.rst Normal file
View File

@@ -0,0 +1,14 @@
.. _uninstalling:
Uninstalling
------------
To uninstall Bash-it, run the ``uninstall.sh`` script found in the ``$BASH_IT`` directory:
.. code-block::
cd $BASH_IT
./uninstall.sh
This will restore your previous Bash profile.
After the uninstall script finishes, remove the Bash-it directory from your machine (\ ``rm -rf $BASH_IT``\ ) and start a new shell.

200
docs/vcs_user.rst Normal file
View File

@@ -0,0 +1,200 @@
.. _vcs_user:
Prompt Version Control Information
==================================
Bash-it provides prompt :ref:`themes` with the ability to check and display version control information for the current directory.
The information is retrieved for each directory and can slow down the navigation of projects with a large number of files and folders.
Turn version control checking off to prevent slow directory navigation within large projects.
Controlling Flags
^^^^^^^^^^^^^^^^^
Bash-it provides a flag (\ ``SCM_CHECK``\ ) within the ``~/.bash_profile`` file that turns off/on version control information checking and display within all themes.
Version control checking is on by default unless explicitly turned off.
Set ``SCM_CHECK`` to 'false' to **turn off** version control checks for all themes:
* ``export SCM_CHECK=false``
Set ``SCM_CHECK`` to 'true' (the default value) to **turn on** version control checks for all themes:
* ``export SCM_CHECK=true``
**NOTE:**
It is possible for themes to ignore the ``SCM_CHECK`` flag and query specific version control information directly.
For example, themes that use functions like ``git_prompt_vars`` skip the ``SCM_CHECK`` flag to retrieve and display git prompt information.
If you turned version control checking off and you still see version control information within your prompt, then functions like ``git_prompt_vars`` are most likely the reason why.
.. _git_prompt:
Git prompt
^^^^^^^^^^
Bash-it has some nice features related to Git, continue reading to know more about these features.
Repository info in the prompt
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Bash-it can show some information about Git repositories in the shell prompt: the current branch, tag or commit you are at, how many commits the local branch is ahead or behind from the remote branch, and if you have changes stashed.
Additionally, you can view the status of your working copy and get the count of *staged*\ , *unstaged* and *untracked* files.
This feature is controlled through the flag ``SCM_GIT_SHOW_DETAILS`` as follows:
Set ``SCM_GIT_SHOW_DETAILS`` to 'true' (the default value) to **show** the working copy details in your prompt:
* ``export SCM_GIT_SHOW_DETAILS=true``
Set ``SCM_GIT_SHOW_DETAILS`` to 'false' to **don't show** it:
* ``export SCM_GIT_SHOW_DETAILS=false``
**NOTE:** If using ``SCM_GIT_SHOW_MINIMAL_INFO=true``\ , then the value of ``SCM_GIT_SHOW_DETAILS`` is ignored.
Remotes and remote branches
^^^^^^^^^^^^^^^^^^^^^^^^^^^
In some git workflows, you must work with various remotes, for this reason, Bash-it can provide some useful information about your remotes and your remote branches, for example, the remote on you are working, or if your local branch is tracking a remote branch.
You can control this feature with the flag ``SCM_GIT_SHOW_REMOTE_INFO`` as follows:
Set ``SCM_GIT_SHOW_REMOTE_INFO`` to 'auto' (the default value) to activate it only when more than one remote is configured in the current repo:
* ``export SCM_GIT_SHOW_REMOTE_INFO=auto``
Set ``SCM_GIT_SHOW_REMOTE_INFO`` to 'true' to always activate the feature:
* ``export SCM_GIT_SHOW_REMOTE_INFO=true``
Set ``SCM_GIT_SHOW_REMOTE_INFO`` to 'false' to **disable the feature**\ :
* ``export SCM_GIT_SHOW_REMOTE_INFO=false``
**NOTE:** If using ``SCM_GIT_SHOW_MINIMAL_INFO=true``\ , then the value of ``SCM_GIT_SHOW_REMOTE_INFO`` is ignored.
Untracked files
^^^^^^^^^^^^^^^
By default, the ``git status`` command shows information about *untracked* files.
This behavior can be controlled through command-line flags or git configuration files.
For big repositories, ignoring *untracked* files can make git faster.
Bash-it uses ``git status`` to gather the repo information it shows in the prompt, so in some circumstances, it can be useful to instruct Bash-it to ignore these files.
You can control this behavior with the flag ``SCM_GIT_IGNORE_UNTRACKED``\ :
Set ``SCM_GIT_IGNORE_UNTRACKED`` to 'false' (the default value) to get information about *untracked* files:
* ``export SCM_GIT_IGNORE_UNTRACKED=false``
Set ``SCM_GIT_IGNORE_UNTRACKED`` to 'true' to **ignore** *untracked* files:
* ``export SCM_GIT_IGNORE_UNTRACKED=true``
Also, with this flag to false, Bash-it will not show the repository as dirty when the repo has *untracked* files, and will not display the count of *untracked* files.
**NOTE:** If you set in git configuration file the option to ignore *untracked* files, this flag has no effect, and Bash-it will ignore *untracked* files always.
Stash item count
^^^^^^^^^^^^^^^^
When ``SCM_GIT_SHOW_DETAILS`` is enabled, you can get the count of *stashed* items. This feature can be useful when a user has a lot of stash items.
This feature is controlled through the flag ``SCM_GIT_SHOW_STASH_INFO`` as follows:
Set ``SCM_GIT_SHOW_STASH_INFO`` to 'true' (the default value) to **show** the count of stashed items:
* ``export SCM_GIT_SHOW_STASH_INFO=true``
Set ``SCM_GIT_SHOW_STASH_INFO`` to 'false' to **don't show** it:
* ``export SCM_GIT_SHOW_STASH_INFO=false``
Ahead/Behind Count
^^^^^^^^^^^^^^^^^^
When displaying information regarding whether or not the local branch is ahead or behind its remote counterpart, you can opt to display the number of commits ahead/behind.
This is useful if you only care whether or not you are ahead or behind and do not care how far ahead/behind you are.
Set ``SCM_GIT_SHOW_COMMIT_COUNT`` to 'true' (the default value) to **show** the count of commits ahead/behind:
* ``export SCM_GIT_SHOW_COMMIT_COUNT=true``
Set ``SCM_GIT_SHOW_COMMIT_COUNT`` to 'false' to **don't show** it:
* ``export SCM_GIT_SHOW_COMMIT_COUNT=false``
Git user
^^^^^^^^
In some environments, it is useful to know the value of the current git user, which is used to mark all new commits.
For example, any organization that uses the practice of pair programming will typically author each commit with `combined names of the two authors <https://github.com/pivotal/git_scripts>`_.
When another pair uses the same pairing station, the authors are changed at the beginning of the session.
To get up and running with this technique, run ``gem install pivotal_git_scripts``\ , and then edit your ``~/.pairs`` file, according to the specification on the `gem's homepage <https://github.com/pivotal/git_scripts>`_.
After that, you should be able to run ``git pair kg as`` to set the author to, eg. "Konstantin Gredeskoul and Alex Saxby", assuming they've been added to the ``~/.pairs`` file.
Please see gem's documentation for more information.
To enable the display of the current pair in the prompt, you must set ``SCM_GIT_SHOW_CURRENT_USER`` to ``true``.
Once set, the ``SCM_CURRENT_USER`` variable will be automatically populated with the initials of the git author(s).
It will also be included in the default git prompt.
Even if you do not have ``git pair`` installed, as long as your ``user.name`` is set, your initials will be computed from your name and shown in the prompt.
You can control the prefix and the suffix of this component using the two variables:
* ``export SCM_THEME_CURRENT_USER_PREFFIX=' ☺︎ '``
And
* ``export SCM_THEME_CURRENT_USER_SUFFIX=' ☺︎ '``
**NOTE:** If using ``SCM_GIT_SHOW_MINIMAL_INFO=true``\ , then the value of ``SCM_GIT_SHOW_CURRENT_USER`` is ignored.
Git show minimal status info
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To speed up the prompt while still getting minimal git status information displayed such as the value of ``HEAD`` and whether there are any dirty objects, you can set:
.. code-block::
export SCM_GIT_SHOW_MINIMAL_INFO=true
Ignore repo status
^^^^^^^^^^^^^^^^^^
When working in repos with a large codebase, Bash-it can slow down your prompt when checking the repo status.
To avoid it, there is an option you can set via Git config to disable checking repo status in Bash-it.
To disable checking the status in the current repo:
.. code-block::
$ git config --add bash-it.hide-status 1
But if you would like to disable it globally, and stop checking the status for all of your repos:
.. code-block::
$ git config --global --add bash-it.hide-status 1
Setting this flag globally has the same effect as ``SCM_CHECK=true``\ , but only for Git repos.
Speed up git status calculations
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
As an alternative to ignoring repo status entirely, you can try out the ``gitstatus`` plugin.
This plugin speeds up all ``git status`` calculations by up to 10x times!
**NOTE**\ : You will need to clone ``gitstatus`` repo from `here <https://github.com/romkatv/gitstatus>`_.

View File

@@ -10,6 +10,7 @@ function show_usage() {
echo "--silent (-s): Install default settings without prompting for input"; echo "--silent (-s): Install default settings without prompting for input";
echo "--interactive (-i): Interactively choose plugins" echo "--interactive (-i): Interactively choose plugins"
echo "--no-modify-config (-n): Do not modify existing config file" echo "--no-modify-config (-n): Do not modify existing config file"
echo "--append-to-config (-a): Keep existing config file and append bash-it templates at the end"
exit 0; exit 0;
} }
@@ -56,15 +57,27 @@ function load_some() {
done done
} }
# Back up existing profile and create new one for bash-it # Back up existing profile
function backup_new() { function backup() {
test -w "$HOME/$CONFIG_FILE" && test -w "$HOME/$CONFIG_FILE" &&
cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" && cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" &&
echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m" echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m"
}
# Back up existing profile and create new one for bash-it
function backup_new() {
backup
sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" > "$HOME/$CONFIG_FILE" sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" > "$HOME/$CONFIG_FILE"
echo -e "\033[0;32mCopied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it\033[0m" echo -e "\033[0;32mCopied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it\033[0m"
} }
# Back up existing profile and append bash-it templates at the end
function backup_append() {
backup
(sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" | tail -n +2) >> "$HOME/$CONFIG_FILE"
echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m"
}
for param in "$@"; do for param in "$@"; do
shift shift
case "$param" in case "$param" in
@@ -72,18 +85,20 @@ for param in "$@"; do
"--silent") set -- "$@" "-s" ;; "--silent") set -- "$@" "-s" ;;
"--interactive") set -- "$@" "-i" ;; "--interactive") set -- "$@" "-i" ;;
"--no-modify-config") set -- "$@" "-n" ;; "--no-modify-config") set -- "$@" "-n" ;;
"--append-to-config") set -- "$@" "-a" ;;
*) set -- "$@" "$param" *) set -- "$@" "$param"
esac esac
done done
OPTIND=1 OPTIND=1
while getopts "hsin" opt while getopts "hsina" opt
do do
case "$opt" in case "$opt" in
"h") show_usage; exit 0 ;; "h") show_usage; exit 0 ;;
"s") silent=true ;; "s") silent=true ;;
"i") interactive=true ;; "i") interactive=true ;;
"n") no_modify_config=true ;; "n") no_modify_config=true ;;
"a") append_to_config=true ;;
"?") show_usage >&2; exit 1 ;; "?") show_usage >&2; exit 1 ;;
esac esac
done done
@@ -94,6 +109,11 @@ if [[ $silent ]] && [[ $interactive ]]; then
exit 1; exit 1;
fi fi
if [[ $no_modify_config ]] && [[ $append_to_config ]]; then
echo -e "\033[91mOptions --no-modify-config and --append-to-config are mutually exclusive. Please choose one or the other.\033[m"
exit 1;
fi
BASH_IT="$(cd "$(dirname "$0")" && pwd)" BASH_IT="$(cd "$(dirname "$0")" && pwd)"
case $OSTYPE in case $OSTYPE in
@@ -127,16 +147,11 @@ if ! [[ $silent ]] && ! [[ $no_modify_config ]]; then
done done
fi fi
while ! [ $silent ]; do while ! [ $append_to_config ]; do
read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash-it templates at the end? [y/N] " choice read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash-it templates at the end? [y/N] " choice
case $choice in case $choice in
[yY]) [yY])
test -w "$HOME/$CONFIG_FILE" && backup_append
cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" &&
echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m"
(sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" | tail -n +2) >> "$HOME/$CONFIG_FILE"
echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m"
break break
;; ;;
[nN]|"") [nN]|"")
@@ -148,11 +163,16 @@ if ! [[ $silent ]] && ! [[ $no_modify_config ]]; then
;; ;;
esac esac
done done
elif [[ $append_to_config ]]; then
# backup/append
backup_append
elif [[ $silent ]] && ! [[ $no_modify_config ]]; then elif [[ $silent ]] && ! [[ $no_modify_config ]]; then
# backup/new by default # backup/new by default
backup_new backup_new
fi fi
# Disable auto-reload in case its enabled
export BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE=''
# Load dependencies for enabling components # Load dependencies for enabling components
source "$BASH_IT/lib/composure.bash" source "$BASH_IT/lib/composure.bash"
source "$BASH_IT/lib/utilities.bash" source "$BASH_IT/lib/utilities.bash"

View File

@@ -346,13 +346,28 @@ _bash-it-version() {
BASH_IT_GIT_REMOTE=$(git remote get-url $BASH_IT_REMOTE) BASH_IT_GIT_REMOTE=$(git remote get-url $BASH_IT_REMOTE)
BASH_IT_GIT_URL=${BASH_IT_GIT_REMOTE%.git} BASH_IT_GIT_URL=${BASH_IT_GIT_REMOTE%.git}
if [[ "$BASH_IT_GIT_URL" == *"git@"* ]]; then
# Fix URL in case it is ssh based URL
BASH_IT_GIT_URL=${BASH_IT_GIT_URL/://}
BASH_IT_GIT_URL=${BASH_IT_GIT_URL/git@/https://}
fi
BASH_IT_GIT_VERSION_INFO="$(git log --pretty=format:'%h on %aI' -n 1)" current_tag=$(git describe --exact-match --tags 2> /dev/null)
BASH_IT_GIT_SHA=${BASH_IT_GIT_VERSION_INFO%% *}
echo "Current git SHA: $BASH_IT_GIT_VERSION_INFO" if [[ -z $current_tag ]]; then
echo "$BASH_IT_GIT_URL/commit/$BASH_IT_GIT_SHA" BASH_IT_GIT_VERSION_INFO="$(git log --pretty=format:'%h on %aI' -n 1)"
echo "Compare to latest: $BASH_IT_GIT_URL/compare/$BASH_IT_GIT_SHA...master" TARGET=${BASH_IT_GIT_VERSION_INFO%% *}
echo "Version type: dev"
echo "Current git SHA: $BASH_IT_GIT_VERSION_INFO"
echo "Commit info: $BASH_IT_GIT_URL/commit/$TARGET"
else
TARGET=$current_tag
echo "Version type: stable"
echo "Current tag: $current_tag"
echo "Tag information: $BASH_IT_GIT_URL/releases/tag/$current_tag"
fi
echo "Compare to latest: $BASH_IT_GIT_URL/compare/$TARGET...master"
cd - &> /dev/null || return cd - &> /dev/null || return
} }

23
lint_clean_files.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Pull list of checkable files from clean_files.txt
# - Folder references are allowed
# - Empty lines are ignored
# - Comment lines (#) are ignored
#
# shellcheck disable=SC2002 # Prefer 'cat' for cleaner script
mapfile -t FILES < <(
cat clean_files.txt \
| grep -v -E '^\s*$' \
| grep -v -E '^\s*#' \
| xargs -n1 -I{} find "{}" -type f
)
# We clear the BASH_IT variable to help the shellcheck checker
# identify source includes within our scripts that require a
# 'source' directive. For more information, see:
#
# "Shellcheck SC1090 - Can't follow non-constant source"
# https://www.shellcheck.net/wiki/SC1090
#
BASH_IT='' pre-commit run --files "${FILES[@]}"

View File

@@ -91,5 +91,5 @@ function alias_completion {
echo "$new_completion" >> "$tmp_file" echo "$new_completion" >> "$tmp_file"
fi fi
done < <(alias -p | sed -Ene "s/$alias_regex/\2 '\3' '\4'/p") done < <(alias -p | sed -Ene "s/$alias_regex/\2 '\3' '\4'/p")
source "$tmp_file" && rm -f "$tmp_file" source "$tmp_file" && command rm -f "$tmp_file"
}; alias_completion }; alias_completion

Some files were not shown because too many files have changed in this diff Show More