264 Commits

Author SHA1 Message Date
Noah Gorny
e89403d59b Merge pull request #1881 from NoahGorny/lint-pure-theme
Refactor scm_prompt usage in many themes
2021-08-03 23:22:09 +03:00
cornfeedhobo
e13f7d1b07 Merge pull request #1901 from cornfeedhobo/libera-chat
move to Libera.Chat
2021-07-11 11:30:21 -05:00
cornfeedhobo
aad58bc910 move to Libera.Chat 2021-07-06 22:21:46 -05:00
Ron Green
d4ebba174c feat(git): add git unpushed alias (#1897)
* feat(git): add git unpushed alias
2021-06-23 15:02:04 +03:00
Zhengnan Zhao
0f3e4dc8be Have git check out main branch if present (#1886)
Create function to get default git branch, and use main branch if present
2021-06-23 13:26:48 +03:00
Gurkirat Singh
e51fe1fe2b Abort upgrade if unsaved changes found in bashit directory (#1890)
helper (improvement): added safeguard for unsaved changes
2021-06-23 13:25:42 +03:00
Noah Gorny
d979c32c8a Merge pull request #1891 from tbhaxor/bugfix/helper/upgrade
Replace reload with restart bash it after upgrade
2021-06-23 13:24:49 +03:00
Noah Gorny
f6e3fc358c Merge pull request #1898 from tbhaxor/bugfix/lint/wpscan
FIxed wpscan completion linting
2021-06-23 13:22:25 +03:00
Noah Gorny
e70211549f Merge pull request #1899 from georgettica/georgettica/bump-pre-commit-hooks
chore(pre-commit): bump version
2021-06-23 13:21:06 +03:00
Ron Green
a3f5b5f29a chore(pre-commit): bump version
done in the beginning because of build issues, but was solved during the work on #1897
2021-06-17 10:37:19 +03:00
Gurkirat Singh
682fd32a13 lint (bugfix): wpscan completion linting fix 2021-06-17 08:51:02 +05:30
Gurkirat Singh
01b916c544 helpers (bugfix): restart bashit after upgrade 2021-06-11 12:41:28 +05:30
ofir shtrull
2444a57cc5 feat: add k8s namespace indicator (#1887)
* Add k8s namespace to prompt
2021-06-10 16:04:56 +03:00
Noah Gorny
9b62a5c4df Merge pull request #1888 from clupasq/feature/powerline-command-duration
Add command duration to the powerline theme family
2021-06-10 16:04:28 +03:00
Cristian Lupascu
1e6113f7b7 Add command duration to the powerline theme family
Fix the __powerline_duration_prompt: location & unused variable `prompt`

Remove the duration segment from powerline* theme defaults

Different color for duration prompt segment
2021-06-05 13:47:54 +03:00
Noah Gorny
dff892e0a3 themes: Adapt themes to new scm_prompt api 2021-05-16 19:17:02 +03:00
Noah Gorny
2ae0350f5d themes: base: Add unified scm_prompt function 2021-05-16 19:17:02 +03:00
Noah Gorny
b65a7cc67c themes: Lint pure theme 2021-05-16 13:59:18 +03:00
Noah Gorny
7f193a2e05 Add pure theme to clean_files.txt 2021-05-16 13:52:36 +03:00
Noah Gorny
8c47706139 Merge pull request #1877 from NoahGorny/fix-alias-completion-for-real
plugins: Fix alias-completion by comparing completions to alias literally
2021-05-15 18:58:15 +03:00
Noah Gorny
2120be9372 plugins: Fix alias-completion by using helper util
By using _bash-it-array-contains-element, we can safetly iterate over
elements in the $completions array
2021-05-15 11:42:10 +03:00
Noah Gorny
476c568566 Merge pull request #1874 from oliverralbertini/add-hg-bookmarks-support
[base.theme] add support for hg's bookmarks feature
2021-05-08 00:13:20 +03:00
Oliver Ruben Albertini
26118d1835 [base.theme] add support for hg's bookmarks feature
Will conditionally show the branch based on the current bookmark instead
of branch.
2021-04-27 11:36:14 -07:00
Noah Gorny
d3bb347786 Merge pull request #1837 from NoahGorny/vendor-jboss-completion
vendor jboss completion
2021-04-27 01:32:34 +03:00
Noah Gorny
b8da4cb68c Merge pull request #1875 from NoahGorny/fix-alias-completion
plugins: alias-completion: Revert back to read without -r
2021-04-23 17:05:17 +03:00
Noah Gorny
940739a8a0 Merge pull request #1873 from NoahGorny/improve-clean-files-txt
Add clean_files.txt sorting hook
2021-04-23 00:19:05 +03:00
Noah Gorny
716b49fa0e lint: Sort clean_files.txt according to check-clean-files-txt.sh 2021-04-22 20:53:30 +03:00
Noah Gorny
e15b53ea61 hooks: Use compat31 in check-clean-files-txt.sh 2021-04-22 20:53:30 +03:00
Noah Gorny
1b7448bc9d plugins: alias-completion: Revert back to read without -r 2021-04-22 20:38:30 +03:00
Noah Gorny
d0aa9cb542 hooks: Add check-clean-files-txt.sh 2021-04-22 01:48:20 +03:00
Noah Gorny
c731e45770 lint: Make clean_files.txt more tidy 2021-04-22 01:48:13 +03:00
John Fred Fadrigalan
7b8dbd39bc Clean alias completion plugin (#1872)
* Sort plugins/available

* Clean alias-completion plugin

* Fix shellcheck warning. SC1090

* Change shellcheck source to /dev/null for explicity

* Disable shellcheck warning SC2162
2021-04-22 01:46:50 +03:00
Noah Gorny
31bea24da6 Merge pull request #1859 from tbhaxor/feature/completion/dmidecode
Feature/completion/dmidecode
2021-04-22 01:41:56 +03:00
Noah Gorny
7cd94e1f7f Merge pull request #1870 from cevhyruz/clean-candy-theme
Clean candy theme
2021-04-19 21:49:23 +03:00
John Fred Fadrigalan
370c5b349e Sort theme section 2021-04-20 01:48:37 +08:00
John Fred Fadrigalan
c0fa514f7d Place 'theme/clean' alphabetically on clean_files.txt 2021-04-20 01:40:52 +08:00
John Fred Fadrigalan
409e18f7cb Clean candy theme 2021-04-20 01:18:40 +08:00
Noah Gorny
5e723842b8 Merge pull request #1869 from NoahGorny/add-restart-docs
docs: Add a section about bash-it restart
2021-04-14 19:28:12 +03:00
Noah Gorny
7e620fed63 docs: Add a section about bash-it restart 2021-04-14 16:55:23 +03:00
Noah Gorny
58f2240789 Merge pull request #1845 from NoahGorny/docs-add-logo
docs: Add logo of bash-it to readme
2021-04-08 21:48:31 +03:00
Noah Gorny
2201f6658b Add 2021 to license 2021-04-06 20:59:08 +03:00
Noah Gorny
c7f125a85d docs: Improve readme readability 2021-04-06 20:58:26 +03:00
Noah Gorny
80f143c90b docs: Add nice badges to readme 2021-04-06 20:56:31 +03:00
Noah Gorny
5d809dd73d docs: Add logo of bash-it to readme 2021-04-06 20:56:31 +03:00
Noah Gorny
ebe59c9adc Merge pull request #1850 from tbhaxor/feature/completion/ngrok
Added completion for ngrok tool
2021-04-04 22:36:13 +03:00
Noah Gorny
a6e2c2fc13 Merge pull request #1863 from artemkovalyov/patch-2
add --no-start to docker-compose up command
2021-04-04 22:35:19 +03:00
Noah Gorny
6678788f19 Merge pull request #1857 from bingzhangdai/bindai/extract-plugin
Update extract.plugin.bash, extract compressed file to target directory
2021-04-04 22:34:48 +03:00
Noah Gorny
4f0fa7ebe7 Merge pull request #1862 from NoahGorny/fix-install-error
install: Dont quote number vars, to support older bash versions
2021-04-04 22:34:25 +03:00
Artem Kovalov
905abd37f8 add --no-start to up command 2021-04-03 13:15:04 +02:00
Noah Gorny
a8b43620f8 install: Dont quote number vars, to support older bash versions 2021-04-01 17:59:59 +03:00
Noah Gorny
0239ab8c31 completion: ngrok: Add --help option 2021-04-01 00:37:49 +03:00
Noah Gorny
1dfaf36d91 completion: ngrok: Only complete the list in case prev is ngrok 2021-04-01 00:37:49 +03:00
Noah Gorny
e06066c367 Merge pull request #1842 from Titivoot/master
easy theme added
2021-04-01 00:35:15 +03:00
Gurkirat Singh
035fc920ad completion (improvement): remove if statement 2021-04-01 00:34:37 +03:00
Gurkirat Singh
ab011cd9ba completion (improvement): fixed linting 2021-04-01 00:34:37 +03:00
Gurkirat Singh
d42a1206f9 completion (feature): implemented ngrok 2021-04-01 00:34:37 +03:00
Noah Gorny
ce854255b4 Merge pull request #1833 from NoahGorny/add-license-to-docs
add license to docs
2021-04-01 00:29:07 +03:00
Noah Gorny
9524bf85ae docs: Add easy theme to themes image list 2021-04-01 00:28:28 +03:00
Titivoot Pangrit
6866648ac6 Add theme Easy 2021-04-01 00:28:28 +03:00
Noah Gorny
514a753901 Merge pull request #1858 from lintonf/patch-1
Fix spelling mistake with terraform destroy alias
2021-03-31 23:56:58 +03:00
Gurkirat Singh
e481eb41e5 completion (improvement): dmidecode lint fixed 2021-03-30 11:03:18 +05:30
Gurkirat Singh
a3ae37b385 completion (feature): dmidecode 2021-03-30 11:01:19 +05:30
Linton Fisher
0b808b17f1 Fix spelling mistake 2021-03-30 00:57:13 +01:00
Noah Gorny
4860fb8c60 Merge pull request #1849 from tiagobarros99/purity-add-virtualenv
purity theme, added virtualenv name display
2021-03-25 19:16:35 +02:00
tiago
cda81f3d74 cleaned and linted purity theme 2021-03-24 21:39:57 +00:00
Bingzhang Dai
7331cd2676 Update extract.plugin.bash 2021-03-24 18:42:44 +08:00
Bingzhang Dai
399b5199b0 Update extract.plugin.bash, support to extract zip to target directory 2021-03-24 17:04:21 +08:00
Noah Gorny
eced6802d0 Merge pull request #1856 from NoahGorny/fix-typeset-command-not-found
helpers: Fix broken compoure references after vendor change
2021-03-22 21:40:29 +02:00
Noah Gorny
02f6654841 test: Add bash-it help plugins test 2021-03-21 22:07:24 +02:00
Noah Gorny
7b5f758eba helpers: Fix broken compoure references after vendor change 2021-03-21 21:52:47 +02:00
tiago
64c4c30706 minor change 2021-03-17 15:39:57 +00:00
tiago
ea444459cf improved PS1, function rename 2021-03-17 15:26:39 +00:00
Noah Gorny
6f02b8d194 Merge pull request #1851 from ofirshtrull/master
Add support for active gcloud account in powerline prompt
2021-03-15 23:01:43 +02:00
Noah Gorny
c8ef6c9146 Merge pull request #1848 from matthewadams/master
add npm alias nt="npm test"
2021-03-13 18:55:02 +02:00
Ofir Shtrull
8ae2b1e73d fix typo 2021-03-11 18:32:10 +02:00
Ofir Shtrull
ffc1701c0a Add to prompt google gcloud active account 2021-03-11 18:25:23 +02:00
tiago
682d6d728d added python's virtualenv name 2021-03-10 15:24:32 +00:00
Matthew Adams
96586dd575 add alias nt="npm test" 2021-03-09 14:14:19 -06:00
Noah Gorny
c59886b8ab Merge pull request #1847 from tbhaxor/patch-2
Added alias for git rebase
2021-03-09 00:15:58 +02:00
Gurkirat Singh
5c6306deb7 alias (improvement): continue rebase after conflict resolve 2021-03-09 02:24:12 +05:30
Noah Gorny
6093ecbb60 Merge pull request #1841 from ddaza/master
fix: Git alias quote style broke functionality
2021-02-26 10:17:01 +02:00
ddaza
e289549a50 fix alias quotes 2021-02-25 19:45:59 -06:00
Artem Kovalov
9d7738d14d Improved systemd aliases
Refactor naming
Add restart
2021-02-25 00:01:38 +02:00
Noah Gorny
7827907154 Merge pull request #1838 from bialad/patch-1
Remove deprecated kubectl run --generator
2021-02-24 19:06:55 +02:00
Tobias Månsson
0ed6f045f6 Remove deprecated kubectl run --generator
It now defaults to pod, so the --generator option is not required.
2021-02-15 07:41:39 +01:00
Noah Gorny
64d827c3da completion: Use vendored jboss completion
Also include new jboss5 vendored completion
2021-02-13 10:41:16 +02:00
Noah Gorny
a30a76906c Add "jboss-completion" from "https://github.com/rparree/jboss-bash-completion@master"
git-vendor-name: jboss-completion
git-vendor-dir: vendor/github.com/rparree/jboss-bash-completion
git-vendor-repository: https://github.com/rparree/jboss-bash-completion
git-vendor-ref: master
2021-02-13 10:34:49 +02:00
Noah Gorny
e89948a7f0 Squashed 'vendor/github.com/rparree/jboss-bash-completion/' content from commit fc87d94
git-subtree-dir: vendor/github.com/rparree/jboss-bash-completion
git-subtree-split: fc87d94e7da9431133190f60f5a84367e44d650c
2021-02-13 10:34:49 +02:00
Noah Gorny
4607ee7452 Merge pull request #1836 from buhl/django-complete
vendoring django completion
2021-02-13 10:30:31 +02:00
Noah Gorny
0eab2962d3 Merge pull request #1835 from buhl/vendor-apm-completion
Vendor apm completion
2021-02-12 15:50:42 +02:00
buhl
0e77a94140 Vendored django completion 2021-02-09 11:01:37 +01:00
buhl
a0ba2a1787 Add "django-completion" from "https://github.com/django/django@3.1.6"
git-vendor-name: django-completion
git-vendor-dir: vendor/github.com/django/django
git-vendor-repository: https://github.com/django/django
git-vendor-ref: 3.1.6
2021-02-09 10:56:10 +01:00
buhl
0dd01da4b7 Squashed 'vendor/github.com/django/django/' content from commit 32bb1421
git-subtree-dir: vendor/github.com/django/django
git-subtree-split: 32bb1421ae4bf8e3b730be0cb47ee026a72961f7
2021-02-09 10:45:13 +01:00
buhl
7fb7e27921 Added vendored apm completion 2021-02-08 16:05:45 +01:00
buhl
751d3e2496 Add "apm-completion" from "https://github.com/vigo/apm-bash-completion@master"
git-vendor-name: apm-completion
git-vendor-dir: vendor/github.com/vigo/apm-bash-completion
git-vendor-repository: https://github.com/vigo/apm-bash-completion
git-vendor-ref: master
2021-02-08 16:05:40 +01:00
buhl
e8342c1d97 Squashed 'vendor/github.com/vigo/apm-bash-completion/' content from commit d44593c
git-subtree-dir: vendor/github.com/vigo/apm-bash-completion
git-subtree-split: d44593c3f0514e1fcc668e47f875f83ceb054b36
2021-02-08 16:05:40 +01:00
Noah Gorny
2d56cc4167 Merge pull request #1788 from tbhaxor/lint/notify-send-completion
Lint/notify send completion
2021-02-08 10:24:24 +02:00
Noah Gorny
25c1c8978e Merge pull request #1807 from NoahGorny/cleanup/composer-completions
formatted composer completion and used helper function
2021-02-06 23:32:58 +02:00
cornfeedhobo
133e48229a Merge pull request #1832 from cornfeedhobo/gocomplete
ensure go completion works well with goenv
2021-02-06 15:27:12 -06:00
Noah Gorny
e25e371ba7 docs: Add newline in readme and index.rst 2021-02-06 23:17:18 +02:00
Noah Gorny
e4e0c151b2 docs: Add license notice to readme 2021-02-06 23:16:58 +02:00
Noah Gorny
db318cdd3e Merge pull request #1830 from NoahGorny/simplify-install
simplify install
2021-02-06 22:57:17 +02:00
cornfeedhobo
6870abc4fc ensure go completion works well with goenv 2021-02-06 14:34:24 -06:00
Noah Gorny
e4f6006797 completion: composer: Rename _composer->__composer_completion 2021-02-06 20:37:28 +02:00
Noah Gorny
5c192575ce install: Add bash-it prefix to all functions 2021-02-06 20:36:04 +02:00
Noah Gorny
3e7adde638 install: Move to double brackets in check_for-backup check 2021-02-06 20:25:56 +02:00
Noah Gorny
fe9ef1e4bd Merge pull request #1816 from tbhaxor/lint/git-plugins
Lint/git plugins
2021-02-06 00:31:41 +02:00
Noah Gorny
75058ebf22 plugins: git: Fix git_stats
Also remove uneeded newline
2021-02-06 00:26:15 +02:00
Gurkirat Singh
5cb52fa239 fixed linting for plugins/available/git.plugin.bash file 2021-02-06 00:26:15 +02:00
Gurkirat Singh
77654875e5 fixed git-changelog plugin 2021-02-06 00:26:12 +02:00
Gurkirat Singh
63f9f660a9 credit given to original author 2021-02-06 00:25:33 +02:00
Gurkirat Singh
92d814b2f6 added plugin to create git changelog and formatted code 2021-02-06 00:25:33 +02:00
Noah Gorny
0d963b224f completion: composer: Remove uneeded local "scripts" var 2021-02-06 00:23:31 +02:00
Noah Gorny
e9f28ff745 completion: composer: Add shellcheck directives 2021-02-06 00:23:31 +02:00
Gurkirat Singh
dbfcb431a8 formatted composer completion and used helper function 2021-02-06 00:23:31 +02:00
Gurkirat Singh
1d2a2fcd9a added completion for notify-send command 2021-02-06 00:23:14 +02:00
Noah Gorny
af17501318 install: Add --overwrite-backup flag
This will ensure users will specify whether they want to overwrite the
backup or not, and check it even when we do silent installation
This does change the default behaviour and exits if the -f flag is not
specified and a backup is present.
2021-02-06 00:15:20 +02:00
Noah Gorny
9e37f0d09e install: Move backup check into a separate function 2021-02-06 00:15:20 +02:00
Noah Gorny
ef10bcd151 install: Move modify config check into separate function
This helps us make the logic easier to read, and remove unneeded
confusion.
2021-02-06 00:15:20 +02:00
Noah Gorny
1fbd91ebf9 Merge pull request #1824 from cornfeedhobo/goenv-go
Ensure goenv and go play together well
2021-02-06 00:14:07 +02:00
Noah Gorny
71116f785f Merge pull request #1828 from cornfeedhobo/composure-bump
Composure bump
2021-02-05 10:51:28 +02:00
cornfeedhobo
84049a4542 Update "composure" from "https://github.com/erichs/composure@55fdb9fa3cd0f181208a46d90da4d87d5b7e4351"
git-vendor-name: composure
git-vendor-dir: vendor/github.com/erichs/composure
git-vendor-repository: https://github.com/erichs/composure
git-vendor-ref: 55fdb9fa3cd0f181208a46d90da4d87d5b7e4351
2021-02-05 00:15:02 -06:00
cornfeedhobo
aebe193136 Squashed 'vendor/github.com/erichs/composure/' changes from 5c3698d..55fdb9f
55fdb9f Merge pull request #24 from bvberkum/pr-21
b360ca5 Use command name, not last argument as shell-name [#23]
5c458c9 22 - Document revise behavior with GUI editors
7de4304 Update LICENSE copyright
f784e3a Merge pull request #20 from akatrevorjay/pr/zsh-plugin
1901dbe Merge pull request #19 from DrVanScott/master
6bcbc7b Add zsh-style plugin for easy load
37bccee fix _typeset_functions_about for functions starting with a dash
27623a9 fix zsh specific issues
2efc446 glossary: list only functions containing 'about'
7899d11 glossary: call _typeset_functions only once
072856e shell(): Fix for cygwin environment
2dc31de avoid error message if gprintf does not exist

git-subtree-dir: vendor/github.com/erichs/composure
git-subtree-split: 55fdb9fa3cd0f181208a46d90da4d87d5b7e4351
2021-02-05 00:15:02 -06:00
cornfeedhobo
e690f21e4e Ensure goenv and go play together well
This PR seeks to address several issues surrounding the go and goenv plugins.
The nature of goenv allows for a situation where the initial shell does not
point to a working go binary, and instead at the included shim script. The
result is that one must run reload after moving to a project directory with a
version file, however in doing so, PATH is updated, requiring they exit the
shell or risk lookup collisions and unexpected behavior.

This is solved by using preexec to check the version before changing
directories and restarting the shell if the version has changed. The exec
pattern is copied from _bash-it-restart, but is edited to support this specific
use case.

Additionally, tests have been uploaded and these are now being linted.
2021-02-04 23:51:17 -06:00
cornfeedhobo
ff2f961ad7 Merge pull request #1822 from cornfeedhobo/stop-changing-working-directory
use absolute paths instead of changing directory
2021-02-03 09:05:59 -06:00
Noah Gorny
ce6487f63e Merge pull request #1820 from buhl/composure
Vendoring the composure
2021-02-03 09:06:35 +02:00
buhl
49d7d2e8c4 Getting Bash-it to use the vendored composure
Fixed tests
Fixed install.sh and bash_it.sh
Added gitattributes to the vendor folder
Changed documentation
2021-02-02 16:34:04 +01:00
cornfeedhobo
8fcf713541 use absolute paths instead of changing directory 2021-01-31 15:32:23 -06:00
buhl
90dd69c8ad Squashed 'vendor/github.com/erichs/composure/' content from commit 5c3698d
git-subtree-dir: vendor/github.com/erichs/composure
git-subtree-split: 5c3698df33cf92f9dbe75b807b1d29729989baaa
2021-01-31 14:56:34 +01:00
buhl
a0b6c4993a Add "composure" from "https://github.com/erichs/composure@1.3.1"
git-vendor-name: composure
git-vendor-dir: vendor/github.com/erichs/composure
git-vendor-repository: https://github.com/erichs/composure
git-vendor-ref: 1.3.1
2021-01-31 14:56:34 +01:00
Noah Gorny
293d86771a Merge pull request #1779 from NoahGorny/deprecate-docker-machine
docker-machine: Deprecate both plugin and completion file
2021-01-29 16:48:07 +02:00
Noah Gorny
e8dc0f7434 deprecation: Replace errors with warnings
Deprecated component is not an error, but instead should be a warning to
the user
2021-01-29 16:06:53 +02:00
Noah Gorny
2500fe7dda docker-machine: Deprecate both plugin and completion file 2021-01-29 16:06:51 +02:00
Noah Gorny
1ce93fd60e Merge pull request #1795 from NoahGorny/cleanup/lerna-completions
formatted lerna completion and used helper function
2021-01-29 01:27:16 +02:00
Noah Gorny
b6d95c71ce completion: lerna: Add shellcheck ignore directive 2021-01-28 20:53:34 +02:00
Gurkirat Singh
69e5a28ed3 formatted lerna completion and used helper function 2021-01-28 20:53:34 +02:00
Noah Gorny
28b2a2ba2b Merge pull request #1797 from NoahGorny/cleanup/npm-completions
formatted npm completion and used helper function
2021-01-28 19:34:45 +02:00
Gurkirat Singh
3d3322d0c9 formatted npm completion and used helper function 2021-01-28 19:23:56 +02:00
Noah Gorny
6fb9379f92 Merge pull request #1796 from NoahGorny/cleanup/minikube-completions
formatted minikube completion and used helper function
2021-01-28 19:22:23 +02:00
Gurkirat Singh
645054a8c4 formatted minikube completion and used helper function 2021-01-28 19:18:36 +02:00
Noah Gorny
868d64ebb8 Merge pull request #1793 from NoahGorny/cleanup/kubectl-completions
formatted kubectl completion and used helper function
2021-01-28 19:16:51 +02:00
Gurkirat Singh
202531321d formatted kubectl completion and used helper function 2021-01-28 18:57:00 +02:00
Noah Gorny
253e87e4a2 Merge pull request #1792 from NoahGorny/cleanup/kontena-completion
formatted kontena completion and used helper function
2021-01-28 18:55:14 +02:00
Gurkirat Singh
d4bf4e6a89 formatted kontena completion and used helper function 2021-01-28 18:32:51 +02:00
Noah Gorny
0748b3085e Merge pull request #1799 from NoahGorny/cleanup/jungle-completions
formatted jungle completion and used helper function
2021-01-28 18:16:24 +02:00
Gurkirat Singh
714bf84528 formatted jungle completion and used helper function 2021-01-28 18:10:25 +02:00
Noah Gorny
391ce6e91f Merge pull request #1802 from NoahGorny/cleanup/gem-completions
formatted gem completion
2021-01-28 18:07:51 +02:00
Noah Gorny
42695c22d0 completion: gem: Fix completion file 2021-01-28 17:55:51 +02:00
Gurkirat Singh
a8695edc8f formatted gem completion 2021-01-28 17:55:50 +02:00
Noah Gorny
71c0c06a78 Merge pull request #1798 from NoahGorny/cleanup/pip-completions
cleanup/pip completions
2021-01-28 17:54:59 +02:00
Noah Gorny
5df1e653d9 completion: pip: Lint all pip files and clarify comment 2021-01-28 17:46:22 +02:00
Gurkirat Singh
7959acddd9 formatted pip pip3 and pipenv completion and used helper functions 2021-01-28 17:45:06 +02:00
Noah Gorny
c2d971f20e Merge pull request #1801 from NoahGorny/cleanup/gh-completions
cleanup/gh completions
2021-01-28 17:44:21 +02:00
Noah Gorny
adc77bb622 completion: Lint github-cli completion and use completion_exists 2021-01-28 17:40:35 +02:00
Noah Gorny
2b66100c47 helpers: Add _completion_exists helper 2021-01-28 17:40:20 +02:00
Gurkirat Singh
759cdd5a6d formatted github-cli completion 2021-01-28 17:40:20 +02:00
Noah Gorny
8969f018a4 Merge pull request #1800 from NoahGorny/cleanup/helm-completions
formatted helm completion and used helper function
2021-01-28 17:36:23 +02:00
Gurkirat Singh
9915f85e8b formatted helm completion and used helper function 2021-01-28 17:30:26 +02:00
Noah Gorny
94a9c639c7 Merge pull request #1803 from NoahGorny/cleanup/gcloud-completions
cleanup/gcloud completions
2021-01-28 17:28:12 +02:00
Noah Gorny
067149725d completion: Add about-completion to gcloud 2021-01-28 17:18:52 +02:00
Gurkirat Singh
ba5700e555 formatted gcloud completion and used helper function 2021-01-28 17:18:51 +02:00
Noah Gorny
8dfc4cee20 Merge pull request #1804 from NoahGorny/cleanup/docker-completions
completion: Lint docker completion and add about-completion
2021-01-28 17:17:55 +02:00
Noah Gorny
2e3cf0b3c0 completion: Lint docker completion and add about-completion 2021-01-28 17:03:25 +02:00
Noah Gorny
5b51842b54 Merge pull request #1805 from NoahGorny/bugfix/consul-completions
formatted consul completion and used helper function
2021-01-28 16:56:10 +02:00
Gurkirat Singh
846a576978 formatted consul completion and used helper function 2021-01-28 16:35:55 +02:00
Noah Gorny
284819e718 Merge pull request #1806 from NoahGorny/cleanup/conda-completions
formatted conda completion and used helper function
2021-01-28 16:34:51 +02:00
Gurkirat Singh
f9bc244718 formatted conda completion and used helper function 2021-01-28 16:27:34 +02:00
Noah Gorny
2c429e5bb1 Merge pull request #1809 from NoahGorny/cleanup/awless-completions
formatted awless completion and used helper function
2021-01-28 16:24:33 +02:00
Gurkirat Singh
b93ac7785c formatted awless completion and used helper function 2021-01-28 16:19:48 +02:00
Noah Gorny
ef110e167c Merge pull request #1808 from NoahGorny/cleanup/brew-completions
formatted brew completion
2021-01-28 16:19:09 +02:00
Noah Gorny
37a7fac128 completion: brew: Add shellcheck ignore directives 2021-01-28 16:09:02 +02:00
Gurkirat Singh
1d569573da formatted brew completion 2021-01-28 16:09:00 +02:00
Noah Gorny
0d0fde9904 Merge pull request #1813 from NoahGorny/improve-test-helper
test: helper: cite plumbing metadata
2021-01-28 16:08:03 +02:00
Noah Gorny
25b3c96f43 Merge pull request #1817 from tiagobarros99/cleanup/modern-theme
Cleanup for modern theme
2021-01-28 12:25:07 +02:00
tiago
cb5047734b retval check 2021-01-27 22:55:44 +00:00
tiago
3a846a2d47 cleanup modern theme 2021-01-27 22:55:44 +00:00
Noah Gorny
2388c74d84 Merge pull request #1776 from buhl/vendor
Add git vendor and vendor pre-exec lib
2021-01-27 23:25:30 +02:00
Noah Gorny
c79d6cd609 vendor: Add init.d directory to clean_files.txt
Also fix and lint the directory.
This is our code, and as such, should be linted.
2021-01-27 23:21:14 +02:00
Noah Gorny
9b04e11bfc Merge branch 'master' into vendor 2021-01-27 16:43:34 +02:00
Noah Gorny
4f8fd5957f Merge pull request #1780 from tbhaxor/lint/vue-completions
Lint/vue completions
2021-01-26 20:03:34 +02:00
Noah Gorny
7b817f388d Merge pull request #1790 from BarbUk/clean/theme_starting_by_b
Clean b* themes
2021-01-26 19:57:45 +02:00
Noah Gorny
2db806fe0d Merge pull request #1812 from tiagobarros99/fix-modern-theme
modern theme, added virtualenv name display, changed first bracket and second bracket
2021-01-26 19:56:44 +02:00
tiago
e80e29be6d Merge remote-tracking branch 'upstream/master' into fix-modern-theme 2021-01-24 14:09:48 +00:00
Noah Gorny
70f0111f69 completion: vue: Remove uneeded condition
Also move the shellcheck warnings to be on their respective line
2021-01-23 23:14:24 +02:00
Gurkirat Singh
812efaab90 added vuejs completion in clean_files 2021-01-23 23:14:24 +02:00
Noah Gorny
49cf84c4fe test: helper: cite plumbing metadata 2021-01-23 23:04:29 +02:00
Noah Gorny
6b3788051f test: plugin: xterm: Use correct _command_exists invocation 2021-01-23 23:03:41 +02:00
Noah Gorny
046e528cc2 plugins: xterm: Fix shfmt complaints 2021-01-23 22:47:15 +02:00
buhl
29855ed1e6 Adding preexec as a vendored library
Added a vendored lib loading routine in bash-it.sh
Added documentation on how to vendor libs in bash-it
Added and fixed plugins using preexec
Added tests for two plugins
Removed the old preexec lib
2021-01-23 18:31:18 +01:00
tiago
e2be8bc2bc trailing and code style 2021-01-23 17:30:20 +00:00
buhl
5ad497924c Add "preexec" from "https://github.com/rcaloras/bash-preexec@0.4.1"
git-vendor-name: preexec
git-vendor-dir: vendor/github.com/rcaloras/bash-preexec
git-vendor-repository: https://github.com/rcaloras/bash-preexec
git-vendor-ref: 0.4.1
2021-01-23 18:28:43 +01:00
buhl
c9a7837b44 Squashed 'vendor/github.com/rcaloras/bash-preexec/' content from commit 7884535
git-subtree-dir: vendor/github.com/rcaloras/bash-preexec
git-subtree-split: 7884535ed423ac27d3b6b473c61b1fe41905aca1
2021-01-23 18:28:43 +01:00
tiago
54bf7f9a59 check if last command successful 2021-01-23 17:10:32 +00:00
tiago
bb6354e205 removed trailing spaces 2021-01-23 14:42:58 +00:00
Noah Gorny
2a2741d761 Merge pull request #1810 from NoahGorny/disable-keep-padding
Disable keep-padding option in shfmt
2021-01-23 09:45:15 +02:00
tiago
c7f6e80ad0 fix modern theme, added virtualenv name 2021-01-22 17:07:16 +00:00
BarbUk
f86d823dc3 Disable SC2207 to keep COMPREPLY simple 2021-01-22 18:41:16 +04:00
Noah Gorny
d2ab59fef8 Disable keep-padding option in shfmt
Has some serious bugs and not really needed
Also fixed all files that need to be changed after this
2021-01-21 22:08:45 +02:00
BarbUk
b92f53ece5 Update atomic theme with correct compgen syntax 2021-01-16 23:21:04 +01:00
BarbUk
ef42c822e6 Update brainy theme with correct compgen syntax 2021-01-16 23:18:58 +01:00
Noah Gorny
79df5ffc3c Merge pull request #1789 from BarbUk/fix/rbenv_version_prompt
Fix rbenv version prompt
2021-01-16 20:18:47 +02:00
Noah Gorny
18781ed397 Merge pull request #1764 from cornfeedhobo/history-plugins
refactor all history modifications into discrete plugins
2021-01-16 19:32:29 +02:00
Noah Gorny
988e966df3 Merge pull request #1773 from tbhaxor/feature/clipboard-copy
added alias for xclip command
2021-01-16 13:27:05 +02:00
BarbUk
814ff562e9 Fix rbenv version prompt 2021-01-16 09:25:12 +01:00
BarbUk
86fd073ee6 Clean brunton 2021-01-16 09:13:23 +01:00
BarbUk
662a5c4ac7 Clean brainy 2021-01-16 09:13:10 +01:00
BarbUk
eadd2685df Clean bobby 2021-01-16 09:12:59 +01:00
BarbUk
8691894175 Clean bira 2021-01-16 09:12:42 +01:00
BarbUk
cfb9a22e70 Clean binaryanomaly 2021-01-16 09:12:20 +01:00
BarbUk
fb0fa7f799 Clean bakke 2021-01-16 09:12:06 +01:00
BarbUk
59fc8c818d Update clean_files.txt 2021-01-16 09:11:26 +01:00
cornfeedhobo
4044f4123c add top-history 2021-01-15 11:57:41 -06:00
cornfeedhobo
61f727fb96 refactor all history modifications into discrete plugins 2021-01-15 11:53:28 -06:00
Noah Gorny
5e667ed476 Merge pull request #1783 from BarbUk/clean/theme_atomic_and_axin
Clean atomic and axin theme
2021-01-14 15:20:38 +02:00
BarbUk
bd6dbd3edf Merge branch 'master' into clean/theme_atomic_and_axin 2021-01-14 13:45:31 +01:00
Noah Gorny
bb35450c17 Merge pull request #1733 from tbhaxor/patch-1
Added git alias to list only conflicted files
2021-01-13 21:32:33 +02:00
Noah Gorny
610980dd23 git: aliases: Move glsu to glsum in ls-files and add glsut 2021-01-13 21:19:55 +02:00
Noah Gorny
a9b0ec7d1d Merge pull request #1785 from marcospereira/lint/themes/base.theme.bash
Add themes/base.theme.bash to clean files
2021-01-13 19:15:09 +02:00
Gurkirat Singh
957cd578f7 Added git alias to list only conflicted files 2021-01-13 19:08:41 +02:00
Noah Gorny
a0ea33d671 Merge pull request #1778 from tbhaxor/bugfix/vue-routes
fixed existing completion and added conditional completion
2021-01-13 19:06:10 +02:00
Noah Gorny
bc32b40088 Merge pull request #1784 from marcospereira/support-sdkman-different-output-formats
Support multiple sdkman output formats
2021-01-13 19:02:35 +02:00
Noah Gorny
70fa3f8d25 aliases: clipboard: Remove command_exists check 2021-01-13 18:43:04 +02:00
Noah Gorny
bac50413f1 Merge pull request #1743 from georgettica/georgettica/sort-git-aliases
refactor(aliases): sort
2021-01-13 18:40:55 +02:00
Noah Gorny
da662d1332 aliases: clipboard: Add shellcheck header 2021-01-13 18:30:32 +02:00
Gurkirat Singh
9f66059f52 aliases: clipboard: Add more aliases for xclip command
Also lint and cleanup the file
2021-01-13 18:29:57 +02:00
Noah Gorny
dd4e410a32 aliases: git: Add shellcheck header 2021-01-13 18:24:53 +02:00
Noah Gorny
8723fc56b2 aliases: git: Sort all commands, even miniscule ones 2021-01-13 18:24:16 +02:00
Ron Green
436381de93 refactor(aliases): sort git aliases file and lint it
- move all comments to the same line so they wont be jumbled
- also add to clean_files.txt
2021-01-13 18:24:13 +02:00
Marcos Pereira
94d261b42d Fix shellcheck warnings for themes/base.theme.bash 2021-01-12 00:55:15 -05:00
Marcos Pereira
5a761b7ae3 Run code fomatter for themes/base.theme.bash 2021-01-11 15:14:49 -05:00
Marcos Pereira
3f29862478 Add themes/base.theme.bash to clean files 2021-01-11 15:12:39 -05:00
Marcos Pereira
08ff08e043 Support multiple sdkman output formats
sdkman has a specific output format for Java candidate since
there are multiple vendors and builds. For example, when running
`sdk list maven`, the format is a simple list like:

    3.6.2
    3.6.1
    3.6.0
    3.5.4
    3.5.3
    3.5.2
    3.5.0
    3.3.9

But for `sbt list java`, the output is a table like:

    ================================================================================
     Vendor        | Use | Version      | Dist    | Status     | Identifier
    --------------------------------------------------------------------------------
     AdoptOpenJDK  |     | 15.0.1.j9    | adpt    |            | 15.0.1.j9-adpt
                   |     | 15.0.1.hs    | adpt    | installed  | 15.0.1.hs-adpt
     ...
     Amazon        |     | 15.0.1       | amzn    |            | 15.0.1-amzn
                   |     | 11.0.9       | amzn    |            | 11.0.9-amzn
     ...
     Azul Zulu     |     | 15.0.1       | zulu    |            | 15.0.1-zulu
                   |     | 15.0.1.fx    | zulu    |            | 15.0.1.fx-zulu
     ...

Therefore, the completion script has to handle both formats.
2021-01-11 11:16:15 -05:00
BarbUk
e574abbbba Clean theme atomic 2021-01-11 11:42:04 +01:00
BarbUk
6495e3479e Clean theme axin 2021-01-11 11:41:44 +01:00
BarbUk
df73085fea Update clean file 2021-01-11 11:41:22 +01:00
Gurkirat Singh
6065d003e8 fixed existing completion and added conditional completion 2021-01-10 00:34:14 +05:30
Noah Gorny
c268cd9abc Merge pull request #1777 from NoahGorny/dnf-aliases-fedora
dnf aliases fedora
2021-01-09 20:31:05 +02:00
Noah Gorny
342ddcfca0 Add dnf.aliases.bash to clean_files.txt 2021-01-09 19:03:44 +02:00
zuck007
73d28f0b27 removing redundant lines 2021-01-09 19:03:17 +02:00
zuck007
f18562279c dnf aliases for fedora_22+ distros 2021-01-09 19:03:17 +02:00
zuck007
2ae03668c4 added dnf aliases for fedora distro 2021-01-09 19:03:17 +02:00
zuck007
91f63c0b68 adding dnf aliases for fedora distro 2021-01-09 19:03:17 +02:00
David Farrell
e932d8371f Add hooks to check .sh and .bash headers - Fixes #1491 (#1765)
* Add hooks to check .sh and .bash headers
* Adds hooks/ to clean_files.txt
2021-01-09 18:02:26 +02:00
Noah Gorny
3fce1ffe8d Merge pull request #1775 from marcospereira/cleanup/sdkman
Add sdkman bash completion to the list of clean files
2021-01-09 00:36:44 +02:00
Marcos Pereira
fe7d3ef177 Format sdkman bash completion with shfmt 2021-01-08 16:42:18 -05:00
Marcos Pereira
56348b1a12 Add sdkman bash completion to clean_files 2021-01-08 16:38:08 -05:00
Noah Gorny
cc3bdc2b57 Merge pull request #1767 from NoahGorny/disable-macos-11
ci: Remove macos-11.0 as it is unreliable
2021-01-08 19:40:41 +02:00
Noah Gorny
d97a36af88 Merge pull request #1697 from NoahGorny/clean-agnoster-theme
clean agnoster theme
2021-01-07 20:21:43 +02:00
Noah Gorny
c5f02b769d Merge pull request #1763 from marcospereira/sdkman-update
Add support to newer versions of sdkman
2021-01-07 19:50:00 +02:00
Noah Gorny
81e3f1482b ci: Remove macos-11.0 as it is unreliable 2021-01-07 19:29:45 +02:00
Noah Gorny
c168122ff5 Add agnoster theme to clean_files.txt 2021-01-07 19:12:34 +02:00
Noah Gorny
f255d03057 shellcheck agnoster theme 2021-01-07 19:11:22 +02:00
Noah Gorny
60da498ed4 shfmt agnoster theme 2021-01-07 19:11:22 +02:00
BarbUk
ae9da3b62b Clean barbuk theme (#1766) 2021-01-07 19:05:00 +02:00
cornfeedhobo
3c00fe6dbb Merge pull request #1759 from cornfeedhobo/add-basher-plugin
add plugin for basher
2021-01-05 09:35:13 -06:00
Marcos Pereira
5ca2c43aed Add support to newer versions of sdkman
Some new commands are available, and also aliases
for commands such as `i` for `install`.
2021-01-04 18:18:13 -05:00
cornfeedhobo
0b6ecf705d add plugin for basher 2021-01-02 23:05:05 -06:00
Noah Gorny
3addebb66b Merge pull request #1760 from cornfeedhobo/editorconfig-fixes
Editorconfig fixes
2021-01-02 00:42:22 +02:00
cornfeedhobo
ded58f25e3 include test/run in editorconfig 2021-01-01 14:25:23 -06:00
cornfeedhobo
b8dda491c7 fix wildcard matches to include path separators 2021-01-01 14:24:34 -06:00
Noah Gorny
13020874a9 Merge pull request #1758 from NoahGorny/update-contributing
Update contributing document
2021-01-01 11:23:04 +02:00
Noah Gorny
3c0235b44b docs: contributing: Remove bullets already covered by our templates 2020-12-29 22:06:22 +02:00
Noah Gorny
aeb0cb7353 docs: contributing: Add section about invoking with command builtin 2020-12-29 22:06:22 +02:00
Noah Gorny
49886620c4 docs: contributing: Mention github actions instead of travis 2020-12-29 22:06:10 +02:00
176 changed files with 7256 additions and 3658 deletions

View File

@@ -9,13 +9,13 @@ charset = utf-8
trim_trailing_whitespace = true trim_trailing_whitespace = true
insert_final_newline = true insert_final_newline = true
[*.{md,rst}] [**.{md,rst}]
trim_trailing_whitespace = false trim_trailing_whitespace = false
[.git*] [.git*]
indent_style = tab indent_style = tab
[*.*sh] [{**.*sh,test/run}]
indent_style = tab indent_style = tab
indent_size = 4 indent_size = 4
@@ -23,7 +23,7 @@ shell_variant = bash
binary_next_line = true # like -bn binary_next_line = true # like -bn
switch_case_indent = true # like -ci switch_case_indent = true # like -ci
space_redirects = true # like -sr space_redirects = true # like -sr
keep_padding = true # like -kp keep_padding = false # like -kp
end_of_line = lf end_of_line = lf
charset = utf-8 charset = utf-8
trim_trailing_whitespace = true trim_trailing_whitespace = true

View File

@@ -11,7 +11,7 @@ jobs:
bats-test: bats-test:
strategy: strategy:
matrix: matrix:
os: [ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, macos-10.15, macos-11.0] os: [ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, macos-10.15]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}

View File

@@ -15,7 +15,7 @@ repos:
- id: mixed-line-ending - id: mixed-line-ending
- id: check-added-large-files - id: check-added-large-files
- repo: https://github.com/jumanjihouse/pre-commit-hooks - repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 2.1.4 rev: 2.1.5
hooks: hooks:
- id: git-check # Configure in .gitattributes - id: git-check # Configure in .gitattributes
- id: shellcheck - id: shellcheck
@@ -28,3 +28,23 @@ repos:
# - id: forbid-crlf # - id: forbid-crlf
- id: remove-crlf - id: remove-crlf
exclude: ".bat$" exclude: ".bat$"
- repo: local
hooks:
- id: dot-sh
name: Check .sh files against bash-it requirements
entry: ./hooks/dot-sh.sh
language: system
files: "\\.sh$"
types: [file]
- id: dot-bash
name: Check .bash files against bash-it requirements
exclude: "test/test_helper.bash"
entry: ./hooks/dot-bash.sh
language: system
files: "\\.bash$"
types: [file]
- id: clean-files-txt
name: Check that clean_files.txt is sorted alphabetically.
entry: ./hooks/check-clean-files-txt.sh
language: system
files: clean_files.txt

View File

@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2020 Bash-it Copyright (c) 2020-2021 Bash-it
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,20 +1,17 @@
# shellcheck shell=bash
cite 'about-alias' cite 'about-alias'
about-alias 'pbcopy and pbpaste shortcuts to linux' about-alias 'xclip shortcuts'
case $OSTYPE in alias pbcopy="xclip -selection clipboard"
linux*) alias pbpaste="xclip -selection clipboard -o"
XCLIP=$(command -v xclip)
[[ $XCLIP ]] && \
alias pbcopy="$XCLIP -selection clipboard" && \
alias pbpaste="$XCLIP -selection clipboard -o"
;;
esac
alias xcpy="xclip -selection clipboard"
alias xpst="xclip -selection clipboard -o"
# to use it just install xclip on your distribution and it would work like: # to use it just install xclip on your distribution and it would work like:
# $ echo "hello" | pbcopy # $ echo "hello" | xcpy
# $ pbpaste # $ xpst
# hello # hello
# very useful for things like: # very useful for things like:
# cat ~/.ssh/id_rsa.pub | pbcopy # cat ~/.ssh/id_rsa.pub | xcpy
# have fun! # have fun!

View File

@@ -0,0 +1,18 @@
# shellcheck shell=bash
cite 'about-alias'
about-alias 'dnf aliases for fedora 22+ distros'
alias dnfl="dnf list" # List packages
alias dnfli="dnf list installed" # List installed packages
alias dnfgl="dnf grouplist" # List package groups
alias dnfmc="dnf makecache" # Generate metadata cache
alias dnfp="dnf info" # Show package information
alias dnfs="dnf search" # Search package
alias dnfu="sudo dnf upgrade" # Upgrade package
alias dnfi="sudo dnf install" # Install package
alias dnfri='sudo dnf reinstall' # Reinstall package
alias dnfgi="sudo dnf groupinstall" # Install package group
alias dnfr="sudo dnf remove" # Remove package
alias dnfgr="sudo dnf groupremove" # Remove package group
alias dnfc="sudo dnf clean all" # Clean cache

View File

@@ -7,3 +7,4 @@ alias dco="docker-compose"
alias dcofresh="docker-compose-fresh" alias dcofresh="docker-compose-fresh"
alias dcol="docker-compose logs -f --tail 100" alias dcol="docker-compose logs -f --tail 100"
alias dcou="docker-compose up" alias dcou="docker-compose up"
alias dcouns="dcou --no-start"

View File

@@ -1,131 +1,188 @@
# shellcheck shell=bash
cite 'about-alias' cite 'about-alias'
about-alias 'common git abbreviations' about-alias 'common git abbreviations'
# Aliases
alias gcl='git clone'
alias ga='git add'
alias grm='git rm'
alias gap='git add -p'
alias gall='git add -A'
alias gf='git fetch --all --prune'
alias gft='git fetch --all --prune --tags'
alias gfv='git fetch --all --prune --verbose'
alias gftv='git fetch --all --prune --tags --verbose'
alias gus='git reset HEAD'
alias gpristine='git reset --hard && git clean -dfx'
alias gclean='git clean -fd'
alias gm="git merge"
alias gmv='git mv'
alias g='git' alias g='git'
alias get='git' alias get='git'
alias gs='git status'
alias gss='git status -s' # add
alias gsu='git submodule update --init --recursive' alias ga='git add'
alias gl='git pull' alias gall='git add -A'
alias gpl='git pull' alias gap='git add -p'
alias glum='git pull upstream master'
alias gpr='git pull --rebase' # branch
alias gpp='git pull && git push' alias gb='git branch'
alias gup='git fetch && git rebase' alias gbD='git branch -D'
alias gp='git push' alias gba='git branch -a'
alias gpd='git push --delete' alias gbd='git branch -d'
alias gpo='git push origin HEAD' alias gbm='git branch -m'
alias gpu='git push --set-upstream' alias gbt='git branch --track'
alias gpuo='git push --set-upstream origin' alias gdel='git branch -D'
alias gpuoc='git push --set-upstream origin $(git symbolic-ref --short HEAD)'
alias gpom='git push origin master' # for-each-ref
alias gr='git remote' alias gbc='git for-each-ref --format="%(authorname) %09 %(if)%(HEAD)%(then)*%(else)%(refname:short)%(end) %09 %(creatordate)" refs/remotes/ --sort=authorname DESC' # FROM https://stackoverflow.com/a/58623139/10362396
alias grv='git remote -v'
alias gra='git remote add' # commit
alias grb='git rebase' alias gc='git commit -v'
alias grm='git rebase master' alias gca='git commit -v -a'
alias grmi='git rebase master -i' alias gcaa='git commit -a --amend -C HEAD' # Add uncommitted and unstaged changes to the last commit
alias gcam='git commit -v -am'
alias gcamd='git commit --amend'
alias gcm='git commit -v -m'
alias gci='git commit --interactive'
alias gcsam='git commit -S -am'
# checkout
alias gcb='git checkout -b'
alias gco='git checkout'
alias gcob='git checkout -b'
alias gcobu='git checkout -b ${USER}/'
alias gcom='git checkout $(get_default_branch)'
alias gcpd='git checkout $(get_default_branch); git pull; git branch -D'
alias gct='git checkout --track'
# clone
alias gcl='git clone'
# clean
alias gclean='git clean -fd'
# cherry-pick
alias gcp='git cherry-pick'
alias gcpx='git cherry-pick -x'
# diff
alias gd='git diff' alias gd='git diff'
alias gds='git diff --staged' alias gds='git diff --staged'
alias gdt='git difftool' alias gdt='git difftool'
alias gdv='git diff -w "$@" | vim -R -'
alias gc='git commit -v' # archive
alias gca='git commit -v -a'
alias gcm='git commit -v -m'
alias gcam="git commit -v -am"
alias gci='git commit --interactive'
alias gcamd='git commit --amend'
alias gb='git branch'
alias gba='git branch -a'
# FROM https://stackoverflow.com/a/58623139/10362396
alias gbc='git for-each-ref --format="%(authorname) %09 %(if)%(HEAD)%(then)*%(else)%(refname:short)%(end) %09 %(creatordate)" refs/remotes/ --sort=authorname DESC'
alias gbt='git branch --track'
alias gbm='git branch -m'
alias gbd='git branch -d'
alias gbD='git branch -D'
alias gcount='git shortlog -sn'
alias gcp='git cherry-pick'
alias gcpx='git cherry-pick -x'
alias gco='git checkout'
alias gcom='git checkout master'
alias gcb='git checkout -b'
alias gcob='git checkout -b'
alias gcobu='git checkout -b ${USER}/'
alias gct='git checkout --track'
alias gcpd='git checkout master; git pull; git branch -D'
alias gexport='git archive --format zip --output' alias gexport='git archive --format zip --output'
alias gdel='git branch -D'
alias gmu='git fetch origin -v; git fetch upstream -v; git merge upstream/master' # fetch
alias gf='git fetch --all --prune'
alias gft='git fetch --all --prune --tags'
alias gftv='git fetch --all --prune --tags --verbose'
alias gfv='git fetch --all --prune --verbose'
alias gmu='git fetch origin -v; git fetch upstream -v; git merge upstream/$(get_default_branch)'
alias gup='git fetch && git rebase'
# log
alias gg='git log --graph --pretty=format:'\''%C(bold)%h%Creset%C(magenta)%d%Creset %s %C(yellow)<%an> %C(cyan)(%cr)%Creset'\'' --abbrev-commit --date=relative'
alias ggf='git log --graph --date=short --pretty=format:'\''%C(auto)%h %Cgreen%an%Creset %Cblue%cd%Creset %C(auto)%d %s'\'''
alias ggs='gg --stat'
alias ggup='git log --branches --not --remotes --no-walk --decorate --oneline' # FROM https://stackoverflow.com/questions/39220870/in-git-list-names-of-branches-with-unpushed-commits
alias gll='git log --graph --pretty=oneline --abbrev-commit' alias gll='git log --graph --pretty=oneline --abbrev-commit'
alias gg="git log --graph --pretty=format:'%C(bold)%h%Creset%C(magenta)%d%Creset %s %C(yellow)<%an> %C(cyan)(%cr)%Creset' --abbrev-commit --date=relative" alias gnew='git log HEAD@{1}..HEAD@{0}' # Show commits since last pull, see http://blogs.atlassian.com/2014/10/advanced-git-aliases/
alias ggf="git log --graph --date=short --pretty=format:'%C(auto)%h %Cgreen%an%Creset %Cblue%cd%Creset %C(auto)%d %s'" alias gwc='git whatchanged'
alias ggs="gg --stat"
alias gsh="git show" # ls-files
alias gsl="git shortlog -sn" alias gu='git ls-files . --exclude-standard --others' # Show untracked files
alias gwc="git whatchanged" alias glsut='gu'
alias gt="git tag" alias glsum='git diff --name-only --diff-filter=U' # Show unmerged (conflicted) files
alias gta="git tag -a"
alias gtd="git tag -d" # gui
alias gtl="git tag -l" alias ggui='git gui'
alias gpatch="git format-patch -1"
# From http://blogs.atlassian.com/2014/10/advanced-git-aliases/ # home
# Show commits since last pull alias ghm='cd "$(git rev-parse --show-toplevel)"' # Git home
alias gnew="git log HEAD@{1}..HEAD@{0}" # appendage to ghm
# Add uncommitted and unstaged changes to the last commit
alias gcaa="git commit -a --amend -C HEAD"
# Rebase with latest remote master
alias gprom="git fetch origin master && git rebase origin/master && git update-ref refs/heads/master origin/master"
alias gpf="git push --force"
alias gpunch="git push --force-with-lease"
alias ggui="git gui"
alias gcsam="git commit -S -am"
# Stash aliases
alias gst="git stash"
alias gstb="git stash branch"
alias gstd="git stash drop"
alias gstl="git stash list"
# Push introduced in git v2.13.2
alias gstpu="git stash push"
alias gstpum="git stash push -m"
# Save deprecated since git v2.16.0
# - aliases now resolve to push
alias gsts="git stash push"
alias gstsm="git stash push -m"
# Alias gstpo added for symmetry with gstpu (push)
# - gstp remains as alias for pop due to long-standing usage
alias gstpo="git stash pop"
alias gstp="git stash pop"
# Switch aliases - Requires git v2.23+
alias gsw="git switch"
alias gswm="git switch master"
alias gswc="git switch --create"
alias gswt="git switch --track"
# Git home
alias ghm='cd "$(git rev-parse --show-toplevel)"'
if ! _command_exists gh; then if ! _command_exists gh; then
alias gh='ghm' alias gh='ghm'
fi fi
# Show untracked files
alias gu='git ls-files . --exclude-standard --others'
# Git SVN # merge
alias gsr='git svn rebase' alias gm='git merge'
# mv
alias gmv='git mv'
# patch
alias gpatch='git format-patch -1'
# push
alias gp='git push'
alias gpd='git push --delete'
alias gpf='git push --force'
alias gpo='git push origin HEAD'
alias gpom='git push origin $(get_default_branch)'
alias gpu='git push --set-upstream'
alias gpunch='git push --force-with-lease'
alias gpuo='git push --set-upstream origin'
alias gpuoc='git push --set-upstream origin $(git symbolic-ref --short HEAD)'
# pull
alias gl='git pull'
alias glum='git pull upstream $(get_default_branch)'
alias gpl='git pull'
alias gpp='git pull && git push'
alias gpr='git pull --rebase'
# remote
alias gr='git remote'
alias gra='git remote add'
alias grv='git remote -v'
# rm
alias grm='git rm'
# rebase
alias grb='git rebase'
alias grbc='git rebase --continue'
alias grm='git rebase $(get_default_branch)'
alias grmi='git rebase $(get_default_branch) -i'
alias gprom='git fetch origin $(get_default_branch) && git rebase origin/$(get_default_branch) && git update-ref refs/heads/$(get_default_branch) origin/$(get_default_branch)' # Rebase with latest remote
# reset
alias gus='git reset HEAD'
alias gpristine='git reset --hard && git clean -dfx'
# status
alias gs='git status'
alias gss='git status -s'
# shortlog
alias gcount='git shortlog -sn'
alias gsl='git shortlog -sn'
# show
alias gsh='git show'
# svn
alias gsd='git svn dcommit' alias gsd='git svn dcommit'
alias gsr='git svn rebase' # Git SVN
# stash
alias gst='git stash'
alias gstb='git stash branch'
alias gstd='git stash drop'
alias gstl='git stash list'
alias gstp='git stash pop' # kept due to long-standing usage
alias gstpo='git stash pop' # recommended for it's symmetry with gstpu (push)
## 'stash push' introduced in git v2.13.2
alias gstpu='git stash push'
alias gstpum='git stash push -m'
## 'stash save' deprecated since git v2.16.0, alias is now push
alias gsts='git stash push'
alias gstsm='git stash push -m'
# submodules
alias gsu='git submodule update --init --recursive'
# switch
# these aliases requires git v2.23+
alias gsw='git switch'
alias gswc='git switch --create'
alias gswm='git switch $(get_default_branch)'
alias gswt='git switch --track'
# tag
alias gt='git tag'
alias gta='git tag -a'
alias gtd='git tag -d'
alias gtl='git tag -l'
case $OSTYPE in case $OSTYPE in
darwin*) darwin*)
@@ -135,3 +192,16 @@ case $OSTYPE in
alias gtls='git tag -l | sort -V' alias gtls='git tag -l | sort -V'
;; ;;
esac esac
# functions
function gdv() {
git diff --ignore-all-space "$@" | vim -R -
}
function get_default_branch() {
if git branch | grep -q main; then
echo main
else
echo master
fi
}

View File

@@ -18,7 +18,7 @@ function _set_pkg_aliases()
alias kcgpan='kubectl get pods --all-namespaces' alias kcgpan='kubectl get pods --all-namespaces'
alias kcgdan='kubectl get deployments --all-namespaces' alias kcgdan='kubectl get deployments --all-namespaces'
# launches a disposable netshoot pod in the k8s cluster # launches a disposable netshoot pod in the k8s cluster
alias kcnetshoot='kubectl run --generator=run-pod/v1 netshoot-$(date +%s) --rm -i --tty --image nicolaka/netshoot -- /bin/bash' alias kcnetshoot='kubectl run netshoot-$(date +%s) --rm -i --tty --image nicolaka/netshoot -- /bin/bash'
fi fi
} }

View File

@@ -22,6 +22,7 @@ alias nud='npm update'
alias nr='npm run' alias nr='npm run'
alias nls='npm list --depth=0 2>/dev/null' alias nls='npm list --depth=0 2>/dev/null'
alias nlsg='npm list -g --depth=0 2>/dev/null' alias nlsg='npm list -g --depth=0 2>/dev/null'
alias nt='npm test'
# npx # npx
alias nx='npx' alias nx='npx'

View File

@@ -3,13 +3,20 @@ about-alias 'systemd service'
case $OSTYPE in case $OSTYPE in
linux*) linux*)
# Improve aliases by bringing the common root `sc|scd` + `sre` for action + `u` for user
alias sc='systemctl' alias sc='systemctl'
alias scr='systemctl daemon-reload'
alias scu='systemctl --user' alias scu='systemctl --user'
alias scur='systemctl --user daemon-reload' alias scdr='systemctl daemon-reload'
alias scdru='systemctl --user daemon-reload'
alias scr='systemctl restart'
alias scru='systemctl --user restart'
alias sce='systemctl stop' alias sce='systemctl stop'
alias scue='systemctl --user stop' alias sceu='systemctl --user stop'
alias scs='systemctl start' alias scs='systemctl start'
alias scus='systemctl --user start' alias scsu='systemctl --user start'
# Keeping previous aliases for a non-breaking change.
alias scue='sceu'
alias scus='scsu'
alias scur='scdru'
;; ;;
esac esac

View File

@@ -7,4 +7,4 @@ alias tf='terraform'
alias tfv='terraform validate' 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 destroy'

View File

@@ -1,3 +1,4 @@
# shellcheck shell=bash
cite 'about-alias' cite 'about-alias'
about-alias 'vim abbreviations' about-alias 'vim abbreviations'

View File

@@ -3,8 +3,7 @@
BASH_IT_LOG_PREFIX="core: main: " BASH_IT_LOG_PREFIX="core: main: "
# Only set $BASH_IT if it's not already set # Only set $BASH_IT if it's not already set
if [ -z "$BASH_IT" ]; if [ -z "$BASH_IT" ]; then
then
# Setting $BASH to maintain backwards compatibility # Setting $BASH to maintain backwards compatibility
export BASH_IT=$BASH export BASH_IT=$BASH
BASH="$(bash -c 'echo $BASH')" BASH="$(bash -c 'echo $BASH')"
@@ -13,8 +12,9 @@ then
fi fi
# Load composure first, so we support function metadata # Load composure first, so we support function metadata
# shellcheck source=./lib/composure.bash # shellcheck disable=SC1090
source "${BASH_IT}/lib/composure.bash" source "${BASH_IT}"/vendor/github.com/erichs/composure/composure.sh
# We need to load logging module first as well in order to be able to log # We need to load logging module first as well in order to be able to log
# shellcheck source=./lib/log.bash # shellcheck source=./lib/log.bash
source "${BASH_IT}/lib/log.bash" source "${BASH_IT}/lib/log.bash"
@@ -23,22 +23,21 @@ source "${BASH_IT}/lib/log.bash"
[ -z "$BASH_IT_OLD_BASH_SETUP" ] || _log_warning "BASH_IT variable not initialized, please upgrade your bash-it version and reinstall it!" [ -z "$BASH_IT_OLD_BASH_SETUP" ] || _log_warning "BASH_IT variable not initialized, please upgrade your bash-it version and reinstall it!"
# For backwards compatibility, look in old BASH_THEME location # For backwards compatibility, look in old BASH_THEME location
if [ -z "$BASH_IT_THEME" ]; if [ -z "$BASH_IT_THEME" ]; then
then
_log_warning "BASH_IT_THEME variable not initialized, please upgrade your bash-it version and reinstall it!" _log_warning "BASH_IT_THEME variable not initialized, please upgrade your bash-it version and reinstall it!"
export BASH_IT_THEME="$BASH_THEME"; export BASH_IT_THEME="$BASH_THEME"
unset BASH_THEME; unset BASH_THEME
fi fi
# support 'plumbing' metadata # support 'plumbing' metadata
cite _about _param _example _group _author _version cite _about _param _example _group _author _version
cite about-alias about-plugin about-completion
# libraries, but skip appearance (themes) for now # libraries, but skip appearance (themes) for now
_log_debug "Loading libraries(except appearance)..." _log_debug "Loading libraries(except appearance)..."
LIB="${BASH_IT}/lib/*.bash" LIB="${BASH_IT}/lib/*.bash"
APPEARANCE_LIB="${BASH_IT}/lib/appearance.bash" APPEARANCE_LIB="${BASH_IT}/lib/appearance.bash"
for _bash_it_config_file in $LIB for _bash_it_config_file in $LIB; do
do
if [ "$_bash_it_config_file" != "$APPEARANCE_LIB" ]; then if [ "$_bash_it_config_file" != "$APPEARANCE_LIB" ]; then
filename=${_bash_it_config_file##*/} filename=${_bash_it_config_file##*/}
filename=${filename%.bash} filename=${filename%.bash}
@@ -49,20 +48,29 @@ do
fi fi
done done
# Load vendors
BASH_IT_LOG_PREFIX="vendor: "
for _bash_it_vendor_init in "${BASH_IT}"/vendor/init.d/*.bash; do
_log_debug "Loading \"$(basename "${_bash_it_vendor_init}" .bash)\"..."
# shellcheck disable=SC1090
source "${_bash_it_vendor_init}"
done
unset _bash_it_vendor_init
BASH_IT_LOG_PREFIX="core: main: "
# Load the global "enabled" directory # Load the global "enabled" directory
# "family" param is empty so that files get sources in glob order # "family" param is empty so that files get sources in glob order
# shellcheck source=./scripts/reloader.bash # shellcheck source=./scripts/reloader.bash
source "${BASH_IT}/scripts/reloader.bash" source "${BASH_IT}/scripts/reloader.bash"
# Load enabled aliases, completion, plugins # Load enabled aliases, completion, plugins
for file_type in "aliases" "plugins" "completion" for file_type in "aliases" "plugins" "completion"; do
do
# shellcheck source=./scripts/reloader.bash # shellcheck source=./scripts/reloader.bash
source "${BASH_IT}/scripts/reloader.bash" "skip" "$file_type" source "${BASH_IT}/scripts/reloader.bash" "skip" "$file_type"
done done
# Load theme, if a theme was set # Load theme, if a theme was set
if [[ ! -z "${BASH_IT_THEME}" ]]; then if [[ -n "${BASH_IT_THEME}" ]]; then
_log_debug "Loading \"${BASH_IT_THEME}\" theme..." _log_debug "Loading \"${BASH_IT_THEME}\" theme..."
# Load colors and helpers first so they can be used in base theme # Load colors and helpers first so they can be used in base theme
BASH_IT_LOG_PREFIX="themes: colors: " BASH_IT_LOG_PREFIX="themes: colors: "
@@ -89,10 +97,8 @@ fi
BASH_IT_LOG_PREFIX="core: main: " BASH_IT_LOG_PREFIX="core: main: "
_log_debug "Loading custom aliases, completion, plugins..." _log_debug "Loading custom aliases, completion, plugins..."
for file_type in "aliases" "completion" "plugins" for file_type in "aliases" "completion" "plugins"; do
do if [ -e "${BASH_IT}/${file_type}/custom.${file_type}.bash" ]; then
if [ -e "${BASH_IT}/${file_type}/custom.${file_type}.bash" ]
then
BASH_IT_LOG_PREFIX="${file_type}: custom: " BASH_IT_LOG_PREFIX="${file_type}: custom: "
_log_debug "Loading component..." _log_debug "Loading component..."
# shellcheck disable=SC1090 # shellcheck disable=SC1090
@@ -104,8 +110,7 @@ done
BASH_IT_LOG_PREFIX="core: main: " BASH_IT_LOG_PREFIX="core: main: "
_log_debug "Loading general custom files..." _log_debug "Loading general custom files..."
CUSTOM="${BASH_IT_CUSTOM:=${BASH_IT}/custom}/*.bash ${BASH_IT_CUSTOM:=${BASH_IT}/custom}/**/*.bash" CUSTOM="${BASH_IT_CUSTOM:=${BASH_IT}/custom}/*.bash ${BASH_IT_CUSTOM:=${BASH_IT}/custom}/**/*.bash"
for _bash_it_config_file in $CUSTOM for _bash_it_config_file in $CUSTOM; do
do
if [ -e "${_bash_it_config_file}" ]; then if [ -e "${_bash_it_config_file}" ]; then
filename=$(basename "${_bash_it_config_file}") filename=$(basename "${_bash_it_config_file}")
filename=${filename%*.bash} filename=${filename%*.bash}
@@ -133,8 +138,7 @@ fi
# Load all the Jekyll stuff # Load all the Jekyll stuff
if [ -e "$HOME/.jekyllconfig" ] if [ -e "$HOME/.jekyllconfig" ]; then
then
# shellcheck disable=SC1090 # shellcheck disable=SC1090
. "$HOME/.jekyllconfig" . "$HOME/.jekyllconfig"
fi fi

View File

@@ -1,7 +1,7 @@
####################################################################### #######################################################################
# Allow-list of files to be lint-checked by CI # Allow-list of files to be lint-checked by CI
# #
# Directory Suport # Directory Support
# Directory references are allowed within the file, ie: # Directory references are allowed within the file, ie:
# #
# themes/powerline # themes/powerline
@@ -16,26 +16,106 @@
# root directories # root directories
# #
docs docs/
hooks/
# root files # root files
# #
.gitattributes .gitattributes
bash_it.sh
clean_files.txt
install.sh
lint_clean_files.sh lint_clean_files.sh
# aliases
#
aliases/available/dnf.aliases.bash
aliases/available/git.aliases.bash
aliases/available/vim.aliases.bash
# completions
#
completion/available/apm.completion.bash
completion/available/awless.completion.bash
completion/available/brew.completion.bash
completion/available/cargo.completion.bash
completion/available/composer.completion.bash
completion/available/conda.completion.bash
completion/available/consul.completion.bash
completion/available/django.completion.bash
completion/available/dmidecode.completion.bash
completion/available/docker-machine.completion.bash
completion/available/docker.completion.bash
completion/available/gcloud.completion.bash
completion/available/gem.completion.bash
completion/available/github-cli.completion.bash
completion/available/go.completion.bash
completion/available/helm.completion.bash
completion/available/jboss5.completion.bash
completion/available/jboss7.completion.bash
completion/available/jungle.completion.bash
completion/available/knife.completion.bash
completion/available/kontena.completion.bash
completion/available/kubectl.completion.bash
completion/available/lerna.completion.bash
completion/available/minikube.completion.bash
completion/available/ngrok.completion.bash
completion/available/notify-send.completion.bash
completion/available/npm.completion.bash
completion/available/packer.completion.bash
completion/available/pip.completion.bash
completion/available/pip3.completion.bash
completion/available/pipenv.completion.bash
completion/available/pipx.completion.bash
completion/available/rustup.completion.bash
completion/available/sdkman.completion.bash
completion/available/vault.completion.bash
completion/available/vuejs.completion.bash
completion/available/wpscan.completion.bash
# plugins
#
plugins/available/alias-completion.plugin.bash
plugins/available/basher.plugin.bash
plugins/available/cmd-returned-notify.plugin.bash
plugins/available/docker-machine.plugin.bash
plugins/available/git.plugin.bash
plugins/available/go.plugin.bash
plugins/available/goenv.plugin.bash
plugins/available/history-search.plugin.bash
plugins/available/history-substring-search.plugin.bash
plugins/available/history.plugin.bash
plugins/available/xterm.plugin.bash
# tests
#
test/plugins/alias-completion.plugin.bats
test/test_helper.bash
# themes # themes
# #
themes/90210 themes/90210
themes/agnoster
themes/atomic
themes/axin
themes/bakke
themes/barbuk
themes/base.theme.bash
themes/binaryanomaly
themes/bira
themes/bobby
themes/bobby-python
themes/brainy
themes/brunton
themes/candy
themes/command_duration.theme.bash
themes/easy
themes/modern
themes/powerline themes/powerline
themes/pure
themes/purity
# completions # vendor init files
# #
completion/available/cargo.completion.bash vendor/.gitattributes
completion/available/knife.completion.bash vendor/init.d
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,77 +1,4 @@
#!/usr/bin/env bash # shellcheck shell=bash
about-completion "apm completion"
# The MIT License (MIT) # shellcheck disable=SC1090
source "${BASH_IT}"/vendor/github.com/vigo/apm-bash-completion/apm
# 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
__apm(){
local cur prev options apm_command
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
__apm_get_command
if [[ $cur = -* ]]; then
options="--color"
if [[ -z $apm_command ]]; then
options="$options --version --help"
fi
if [[ $apm_command && $apm_command = publish ]]; then
options="--tag --rename"
fi
else
if [[ -z $apm_command || $apm_command = help ]]; then
options="help clean config dedupe deinstall delete dev develop docs erase featured home init install link linked links list ln lns login ls open outdated publish rebuild rebuild-module-cache remove rm search show star starred stars test uninstall unlink unpublish unstar update upgrade view"
fi
if [[ $apm_command && $apm_command = publish ]]; then
options="major minor patch build"
fi
if [[ $apm_command && $apm_command = config ]]; then
options="set get delete list edit"
fi
fi
COMPREPLY=($(compgen -W "$options" -- "$cur"))
}
__apm_get_command() {
local i
for ((i=1; i < $COMP_CWORD; ++i)); do
local arg=${COMP_WORDS[$i]}
case $arg in
[^-]*)
apm_command=$arg
return;;
--version)
apm_command=-
return;;
--help)
apm_command=help
return;;
publish)
apm_command=publish
return;;
config)
apm_command=config
return;;
esac
done
}
complete -F __apm -o bashdefault -o default apm

View File

@@ -1 +1,5 @@
[[ -x "$(which awless)" ]] && source <(awless completion bash) # shellcheck shell=bash
if _command_exists awless; then
# shellcheck disable=SC1090
source <(awless completion bash)
fi

View File

@@ -1,4 +1,6 @@
#!/usr/bin/env bash # shellcheck shell=bash
cite "about-completion"
about-completion "brew completion"
# Load late to make sure `system` completion loads first # Load late to make sure `system` completion loads first
# BASH_IT_LOAD_PRIORITY: 375 # BASH_IT_LOAD_PRIORITY: 375
@@ -14,14 +16,17 @@ _command_exists brew || return 0
BREW_PREFIX=${BREW_PREFIX:-$(brew --prefix)} BREW_PREFIX=${BREW_PREFIX:-$(brew --prefix)}
if [[ -r "$BREW_PREFIX"/etc/bash_completion.d/brew ]]; then if [[ -r "$BREW_PREFIX"/etc/bash_completion.d/brew ]]; then
# shellcheck disable=1090
source "$BREW_PREFIX"/etc/bash_completion.d/brew source "$BREW_PREFIX"/etc/bash_completion.d/brew
elif [[ -r "$BREW_PREFIX"/Library/Contributions/brew_bash_completion.sh ]]; then elif [[ -r "$BREW_PREFIX"/Library/Contributions/brew_bash_completion.sh ]]; then
# shellcheck disable=1090
source "$BREW_PREFIX"/Library/Contributions/brew_bash_completion.sh source "$BREW_PREFIX"/Library/Contributions/brew_bash_completion.sh
elif [[ -f "$BREW_PREFIX"/completions/bash/brew ]]; then elif [[ -f "$BREW_PREFIX"/completions/bash/brew ]]; then
# For the git-clone based installation, see here for more info: # For the git-clone based installation, see here for more info:
# https://github.com/Bash-it/bash-it/issues/1458 # https://github.com/Bash-it/bash-it/issues/1458
# https://docs.brew.sh/Shell-Completion # https://docs.brew.sh/Shell-Completion
# shellcheck disable=1090
source "$BREW_PREFIX"/completions/bash/brew source "$BREW_PREFIX"/completions/bash/brew
fi fi

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env bash # shellcheck shell=bash
# cargo (Rust package manager) completion # cargo (Rust package manager) completion
if _binary_exists rustup && _binary_exists cargo; then if _binary_exists rustup && _binary_exists cargo; then

View File

@@ -1,20 +1,14 @@
#!/usr/bin/env bash # shellcheck shell=bash
cite "about-completion"
about-completion "composer completion"
_composer() function __composer_completion() {
{ local cur coms opts com
local cur script coms opts com
COMPREPLY=() COMPREPLY=()
_get_comp_words_by_ref -n : cur words _get_comp_words_by_ref -n : cur words
# for an alias, get the real script behind it
if [[ $(type -t ${words[0]}) == "alias" ]]; then
script=$(alias ${words[0]} | sed -E "s/alias ${words[0]}='(.*)'/\1/")
else
script=${words[0]}
fi
# lookup for command # lookup for command
for word in ${words[@]:1}; do for word in "${words[@]:1}"; do
if [[ $word != -* ]]; then if [[ $word != -* ]]; then
com=$word com=$word
break break
@@ -113,21 +107,23 @@ _composer()
esac esac
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) # shellcheck disable=SC2207
COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
__ltrim_colon_completions "$cur" __ltrim_colon_completions "$cur"
return 0; return 0
fi fi
# completing for a command # completing for a command
if [[ $cur == $com ]]; then if [[ "$cur" == "$com" ]]; then
coms="about archive browse clear-cache config create-project depends diagnose dump-autoload exec global help init install licenses list outdated prohibits remove require run-script search self-update show status suggests update validate" coms="about archive browse clear-cache config create-project depends diagnose dump-autoload exec global help init install licenses list outdated prohibits remove require run-script search self-update show status suggests update validate"
COMPREPLY=($(compgen -W "${coms}" -- ${cur})) # shellcheck disable=SC2207
COMPREPLY=($(compgen -W "${coms}" -- "${cur}"))
__ltrim_colon_completions "$cur" __ltrim_colon_completions "$cur"
return 0 return 0
fi fi
} }
complete -o default -F _composer composer complete -o default -F __composer_completion composer

View File

@@ -1,4 +1,11 @@
#!/usr/bin/env bash # shellcheck shell=bash
which register-python-argcomplete > /dev/null \ cite "about-completion"
&& eval "$(register-python-argcomplete conda)" \ about-completion "conda completion"
|| echo "Please install argcomplete to use conda completion"
if _command_exists conda; then
if _command_exists register-python-argcomplete; then
eval "$(register-python-argcomplete conda)"
else
_log_warning "Argcomplete not found. Please run 'conda install argcomplete'"
fi
fi

View File

@@ -1,10 +1,7 @@
# bash completion support for Hashicorp consul # shellcheck shell=bash
cite "about-completion"
about-completion "Hashicorp consul completion"
CONSUL_BIN=$(command -v consul 2>/dev/null) if _command_exists consul; then
complete -C "$(which consul)" consul
if [[ -x "$CONSUL_BIN" ]]
then
complete -C "$CONSUL_BIN" consul
fi fi
unset CONSUL_BIN

View File

@@ -1,101 +1,4 @@
# ######################################################################### # shellcheck shell=bash
# This bash script adds tab-completion feature to django-admin.py and about-completion "django completion"
# manage.py. # shellcheck disable=SC1090
# source "${BASH_IT}"/vendor/github.com/django/django/extras/django_bash_completion
# Testing it out without installing
# =================================
#
# To test out the completion without "installing" this, just run this file
# directly, like so:
#
# . ~/path/to/django_bash_completion
#
# Note: There's a dot ('.') at the beginning of that command.
#
# After you do that, tab completion will immediately be made available in your
# current Bash shell. But it won't be available next time you log in.
#
# Installing
# ==========
#
# To install this, point to this file from your .bash_profile, like so:
#
# . ~/path/to/django_bash_completion
#
# Do the same in your .bashrc if .bashrc doesn't invoke .bash_profile.
#
# Settings will take effect the next time you log in.
#
# Uninstalling
# ============
#
# 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()
{
COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \
COMP_CWORD=$COMP_CWORD \
DJANGO_AUTO_COMPLETE=1 $1 ) )
}
complete -F _django_completion -o default django-admin.py manage.py django-admin
_python_django_completion()
{
if [[ ${COMP_CWORD} -ge 2 ]]; then
PYTHON_EXE=$( basename -- ${COMP_WORDS[0]} )
echo $PYTHON_EXE | egrep "python([2-9]\.[0-9])?" >/dev/null 2>&1
if [[ $? == 0 ]]; then
PYTHON_SCRIPT=$( basename -- ${COMP_WORDS[1]} )
echo $PYTHON_SCRIPT | egrep "manage\.py|django-admin(\.py)?" >/dev/null 2>&1
if [[ $? == 0 ]]; then
COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]:1}" \
COMP_CWORD=$(( COMP_CWORD-1 )) \
DJANGO_AUTO_COMPLETE=1 ${COMP_WORDS[*]} ) )
fi
fi
fi
}
# Support for multiple interpreters.
unset pythons
if command -v whereis &>/dev/null; then
python_interpreters=$(whereis python | cut -d " " -f 2-)
for python in $python_interpreters; do
pythons="${pythons} $(basename -- $python)"
done
pythons=$(echo $pythons | tr " " "\n" | sort -u | tr "\n" " ")
else
pythons=python
fi
complete -F _python_django_completion -o default $pythons

View File

@@ -0,0 +1,20 @@
# shellcheck shell=bash
function __dmidecode_completion() {
local prev=$(_get_pword)
local curr=$(_get_cword)
case $prev in
-s | --string | -t | --type)
OPTS=$(dmidecode "$prev" 2>&1 | grep -E '^ ' | sed 's/ *//g')
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "$OPTS" -- "$curr"))
;;
dmidecode)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-d --dev-mem -h --help -q --quiet -s --string -t --type -H --handle -u --dump{,-bin} --from-dump --no-sysfs --oem-string -V --version" -- "$curr"))
;;
esac
}
complete -F __dmidecode_completion dmidecode

View File

@@ -1,431 +1,3 @@
# # shellcheck shell=bash
# bash completion file for docker-machine commands _log_warning '"docker-machine" is now deprecated, and as such the bash completion for it is also deprecated.
Please disable this completion.'
# 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:
# - commands and their options
# - machine names
# - filepaths
#
# To enable the completions either:
# - place this file in /etc/bash_completion.d
# or
# - copy this file to e.g. ~/.docker-machine-completion.sh and add the line
# below to your .bashrc after bash completion features are loaded
# . ~/.docker-machine-completion.sh
#
# --- helper functions -------------------------------------------------------
_docker_machine_q() {
docker-machine 2>/dev/null "$@"
}
# suppresses trailing whitespace
_docker_machine_nospace() {
# compopt is not available in ancient bash versions (OSX)
# so only call it if it's available
type compopt &>/dev/null && compopt -o nospace
}
_docker_machine_machines() {
_docker_machine_q ls --format '{{.Name}}' "$@"
}
_docker_machine_drivers() {
local drivers=(
amazonec2
azure
digitalocean
exoscale
generic
google
hyperv
openstack
rackspace
softlayer
virtualbox
vmwarefusion
vmwarevcloudair
vmwarevsphere
)
echo "${drivers[@]}"
}
_docker_machine_value_of_option() {
local pattern="$1"
for (( i=2; i < ${cword}; ++i)); do
if [[ ${words[$i]} =~ ^($pattern)$ ]] ; then
echo ${words[$i + 1]}
break
fi
done
}
# Returns `key` if we are currently completing the value of a map option
# (`key=value`) which matches the glob passed in as an argument.
# This function is needed for key-specific argument completions.
_docker_machine_map_key_of_current_option() {
local glob="$1"
local key glob_pos
if [ "$cur" = "=" ] ; then # key= case
key="$prev"
glob_pos=$((cword - 2))
elif [[ $cur == *=* ]] ; then # key=value case (OSX)
key=${cur%=*}
glob_pos=$((cword - 1))
elif [ "$prev" = "=" ] ; then
key=${words[$cword - 2]} # key=value case
glob_pos=$((cword - 3))
else
return
fi
[ "${words[$glob_pos]}" = "=" ] && ((glob_pos--)) # --option=key=value syntax
[[ ${words[$glob_pos]} == $glob ]] && echo "$key"
}
# Finds the position of the first word that is neither option nor an option's argument.
# If there are options that require arguments, you need to pass a glob describing
# those options, e.g. "--option1|-o|--option2".
# Use this function to restrict completions to exact positions after the options.
_docker_machine_pos_first_nonflag() {
local argument_flags=$1
local counter=$((${subcommand_pos:-${command_pos}} + 1))
while [ "$counter" -le "$cword" ]; do
if [ -n "$argument_flags" ] && eval "case '${words[$counter]}' in $argument_flags) true ;; *) false ;; esac"; then
(( counter++ ))
# eat "=" in case of --option=arg syntax
[ "${words[$counter]}" = "=" ] && (( counter++ ))
else
case "${words[$counter]}" in
-*)
;;
*)
break
;;
esac
fi
# Bash splits words at "=", retaining "=" as a word, examples:
# "--debug=false" => 3 words, "--log-opt syslog-facility=daemon" => 4 words
while [ "${words[$counter + 1]}" = "=" ] ; do
counter=$(( counter + 2))
done
(( counter++ ))
done
echo $counter
}
# --- completion functions ---------------------------------------------------
_docker_machine_active() {
case "${prev}" in
--timeout|-t)
return
;;
esac
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help --timeout -t" -- "${cur}"))
fi
}
_docker_machine_config() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help --swarm" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
_docker_machine_create() {
case "${prev}" in
--driver|-d)
COMPREPLY=($(compgen -W "$(_docker_machine_drivers)" -- "${cur}"))
return
;;
esac
# driver specific options are only included in help output if --driver is given,
# so we have to pass that option when calling docker-machine to harvest options.
local driver="$(_docker_machine_value_of_option '--driver|-d')"
local parsed_options="$(_docker_machine_q create ${driver:+--driver $driver} --help | grep '^ -' | sed 's/^ //; s/[^a-z0-9-].*$//')"
if [[ ${cur} == -* ]]; then
COMPREPLY=($(compgen -W "${parsed_options} -d --help" -- "${cur}"))
fi
}
_docker_machine_env() {
case "${prev}" in
--shell)
COMPREPLY=($(compgen -W "cmd emacs fish powershell tcsh" -- "${cur}"))
return
;;
esac
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help --no-proxy --shell --swarm --unset -u" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
# See docker-machine-wrapper.bash for the use command
_docker_machine_use() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help --swarm --unset" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
_docker_machine_inspect() {
case "${prev}" in
--format|-f)
return
;;
esac
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--format -f --help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
_docker_machine_ip() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
_docker_machine_kill() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
_docker_machine_ls() {
local key=$(_docker_machine_map_key_of_current_option '--filter')
case "$key" in
driver)
COMPREPLY=($(compgen -W "$(_docker_machine_drivers)" -- "${cur##*=}"))
return
;;
state)
COMPREPLY=($(compgen -W "Error Paused Running Saved Starting Stopped Stopping" -- "${cur##*=}"))
return
;;
esac
case "${prev}" in
--filter)
COMPREPLY=($(compgen -W "driver label name state swarm" -S= -- "${cur}"))
_docker_machine_nospace
return
;;
--format|-f|--timeout|-t)
return
;;
esac
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--filter --format -f --help --quiet -q --timeout -t" -- "${cur}"))
fi
}
_docker_machine_mount() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help --unmount -u" -- "${cur}"))
else
local pos=$(_docker_machine_pos_first_nonflag)
if [ "$cword" -eq "$pos" ]; then
# We can't complete remote filesystems. All we can do here is to complete the machine.
COMPREPLY=($(compgen -W "$(_docker_machine_machines --filter state=Running)" -S: -- "${cur}"))
_docker_machine_nospace
elif [ "$cword" -eq "$((pos + 1))" ]; then
_filedir -d
fi
fi
}
_docker_machine_provision() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(_docker_machine_machines --filter state=Running)" -- "${cur}"))
fi
}
_docker_machine_regenerate_certs() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--client-certs --force -f --help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(_docker_machine_machines --filter state=Running)" -- "${cur}"))
fi
}
_docker_machine_restart() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
_docker_machine_rm() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--force -f --help -y" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
_docker_machine_ssh() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
_docker_machine_scp() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--delta -d --help --quiet -q --recursive -r" -- "${cur}"))
else
_filedir
# It would be really nice to ssh to the machine and ls to complete
# remote files.
COMPREPLY=($(compgen -W "$(_docker_machine_machines | sed 's/$/:/')" -- "${cur}") "${COMPREPLY[@]}")
fi
}
_docker_machine_start() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(_docker_machine_machines --filter state=Stopped)" -- "${cur}"))
fi
}
_docker_machine_status() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
_docker_machine_stop() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(_docker_machine_machines --filter state=Running)" -- "${cur}"))
fi
}
_docker_machine_upgrade() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
_docker_machine_url() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
_docker_machine_version() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
_docker_machine_help() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "${commands[*]}" -- "${cur}"))
fi
}
_docker_machine_docker_machine() {
if [[ " ${wants_file[*]} " =~ " ${prev} " ]]; then
_filedir
elif [[ " ${wants_dir[*]} " =~ " ${prev} " ]]; then
_filedir -d
elif [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "${flags[*]} ${wants_dir[*]} ${wants_file[*]}" -- "${cur}"))
else
COMPREPLY=($(compgen -W "${commands[*]}" -- "${cur}"))
fi
}
_docker_machine() {
COMPREPLY=()
local commands=(active config create env inspect ip kill ls mount provision regenerate-certs restart rm ssh scp start status stop upgrade url version help)
local flags=(--debug --native-ssh --github-api-token --bugsnag-api-token --help --version)
local wants_dir=(--storage-path)
local wants_file=(--tls-ca-cert --tls-ca-key --tls-client-cert --tls-client-key)
# Add the use subcommand, if we have an alias loaded
if [[ ${DOCKER_MACHINE_WRAPPED} = true ]]; then
commands=("${commands[@]}" use)
fi
local cur prev words cword
_get_comp_words_by_ref -n : cur prev words cword
local i
local command=docker-machine command_pos=0
for (( i=1; i < ${cword}; ++i)); do
local word=${words[i]}
if [[ " ${wants_file[*]} ${wants_dir[*]} " =~ " ${word} " ]]; then
# skip the next option
(( ++i ))
elif [[ " ${commands[*]} " =~ " ${word} " ]]; then
command=${word}
command_pos=$i
fi
done
local completion_func=_docker_machine_"${command//-/_}"
if declare -F "${completion_func}" > /dev/null; then
${completion_func}
fi
return 0
}
complete -F _docker_machine docker-machine docker-machine.exe

View File

@@ -1,10 +1,12 @@
#!/usr/bin/env bash # shellcheck shell=bash
cite "about-completion"
about-completion "docker completion"
# Make sure docker is installed # Make sure docker is installed
_command_exists docker || return _command_exists docker || return
# Don't handle completion if it's already managed # Don't handle completion if it's already managed
complete -p docker &>/dev/null && return _completion_exists docker && return
_docker_bash_completion_paths=( _docker_bash_completion_paths=(
# MacOS # MacOS
@@ -15,6 +17,7 @@ _docker_bash_completion_paths=(
for fn in "${_docker_bash_completion_paths[@]}"; do for fn in "${_docker_bash_completion_paths[@]}"; do
if [ -r "$fn" ]; then if [ -r "$fn" ]; then
# shellcheck disable=SC1090
source "$fn" source "$fn"
break break
fi fi

View File

@@ -1,2 +1,2 @@
_log_error 'Bash completion for "drush" is now deprecated, as it used code with incompatible license. _log_warning '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.' Please disable this completion and use the instructions from "drush" developers instead.'

View File

@@ -1,9 +1,14 @@
#/usr/bin/env bash # shellcheck shell=bash
# Bash completion for Google Cloud SDK cite "about-completion"
about-completion "Google Cloud SDK completion"
if which gcloud >/dev/null 2>&1; then if _command_exists gcloud; then
# get install path
GOOGLE_SDK_ROOT=${GOOGLE_SDK_ROOT:-$(gcloud info --format="value(installation.sdk_root)")} GOOGLE_SDK_ROOT=${GOOGLE_SDK_ROOT:-$(gcloud info --format="value(installation.sdk_root)")}
for i in $(ls ${GOOGLE_SDK_ROOT}/*.bash.inc); do
source $i # source all the bash completion file that are available
for i in "${GOOGLE_SDK_ROOT}"/*.bash.inc; do
# shellcheck disable=SC1090
source "$i"
done done
fi fi

View File

@@ -1,41 +1,35 @@
#!/usr/bin/env bash # shellcheck shell=bash
# Completion for gem cite "about-completion"
about-completion "gem completion"
_installcomp() { __gem_completion() {
if [ -z "$REMOTE_GEMS" ]
then
REMOTE_GEMS=( $(gem list --remote --no-versions | tr '\n' ' ') )
fi
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "${REMOTE_GEMS[*]}" -- $cur) )
}
_uninstallcomp() {
if [ -z "$LOCAL_GEMS" ]
then
LOCAL_GEMS=( $(gem list --no-versions | sed 's/\*\*\* LOCAL GEMS \*\*\*//' | tr '\n' ' ') )
fi
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "${LOCAL_GEMS[*]}" -- $cur) )
}
_gem() {
local cur=${COMP_WORDS[COMP_CWORD]} local cur=${COMP_WORDS[COMP_CWORD]}
local prev=${COMP_WORDS[COMP_CWORD - 1]} local prev=${COMP_WORDS[COMP_CWORD - 1]}
case $prev in case $prev in
install) install)
_installcomp # list the remote gems and add to completion
if [ -z "$REMOTE_GEMS" ]; then
read -r -a REMOTE_GEMS <<< "$(gem list --remote --no-versions | sed 's/\*\*\* REMOTE GEMS \*\*\*//' | tr '\n' ' ')"
fi
local cur=${COMP_WORDS[COMP_CWORD]}
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "${REMOTE_GEMS[*]}" -- "$cur"))
return 0 return 0
;; ;;
uninstall) uninstall)
_uninstallcomp # list all local installed gems and add to completion
read -r -a LOCAL_GEMS <<< "$(gem list --no-versions | sed 's/\*\*\* LOCAL GEMS \*\*\*//' | tr '\n' ' ')"
local cur=${COMP_WORDS[COMP_CWORD]}
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "${LOCAL_GEMS[*]}" -- "$cur"))
return 0 return 0
;; ;;
esac esac
local commands=(build cert check cleanup contents dependency environment fetch generate_index help install list lock outdated owner pristine push query rdoc search server sources specification stale uninstall unpack update which) local commands=(build cert check cleanup contents dependency environment fetch generate_index help install list lock outdated owner pristine push query rdoc search server sources specification stale uninstall unpack update which)
COMPREPLY=( $(compgen -W "${commands[*]}" -- $cur) ) # shellcheck disable=SC2207
COMPREPLY=($(compgen -W "${commands[*]}" -- "$cur"))
} }
complete -F _gem gem complete -F __gem_completion gem

View File

@@ -1,10 +1,9 @@
#!/usr/bin/env bash # shellcheck shell=bash
cite "about-completion" cite "about-completion"
about-completion "GitHub CLI completion" about-completion "GitHub CLI completion"
if _binary_exists gh; then if _binary_exists gh; then
if _command_exists brew; then # If gh already completed, stop
_log_warning "You don't need github-cli completion enabled if you have system completion enabled" _completion_exists gh && return
fi
eval "$(gh completion --shell=bash)" eval "$(gh completion --shell=bash)"
fi fi

View File

@@ -1,13 +1,15 @@
#!/usr/bin/env bash # shellcheck shell=bash
about-completion "completion for go command using gocomplete"
# bash completion for go tool # bash completion for go tool
# https://github.com/posener/complete # https://github.com/posener/complete
# https://pkg.go.dev/github.com/posener/complete?tab=doc
# Install gocomplete: # Test `go version` because goenv creates shim scripts that will be found in PATH
# go get -u github.com/posener/complete/gocomplete # but do not always resolve to a working install.
# gocomplete -install if _command_exists go && go version &> /dev/null; then
# Same idea here, but no need to test a subcommand
if _command_exists gocomplete && _command_exists go ; then if _command_exists gocomplete && gocomplete &> /dev/null; then
complete -C "${GOBIN}"/gocomplete go # finally, apply completion
complete -C gocomplete go
fi
fi fi

View File

@@ -1,8 +1,7 @@
#!/usr/bin/env bash # shellcheck shell=bash
cite "about-completion"
about-completion "helm (Kubernetes Package Manager) completion"
# helm (Kubernetes Package Manager) completion if _command_exists helm; then
if command -v helm &>/dev/null
then
eval "$(helm completion bash)" eval "$(helm completion bash)"
fi fi

View File

@@ -1,2 +1,2 @@
_log_error 'Bash completion for "homesick" is now deprecated, as it used unlicensed code. _log_warning '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.' Please disable this completion and use the instructions from "homesick" bash completion developers instead.'

View File

@@ -0,0 +1,4 @@
# shellcheck shell=bash
about-completion "jboss5 completion"
# shellcheck disable=SC1090
source "${BASH_IT}"/vendor/github.com/rparree/jboss-bash-completion/jboss5

View File

@@ -1,160 +1,4 @@
# Completions for JBoss Application Server 7 (EAP 6) # shellcheck shell=bash
# VERSION: 0.6 about-completion "jboss7 completion"
# DATE: 2012-10-30 # shellcheck disable=SC1090
# rparree-at-edc4it-dot-com source "${BASH_IT}"/vendor/github.com/rparree/jboss-bash-completion/jboss7
# 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(){
if [[ $COMP_WORDS == *standalone.sh* ]]
then
serverdir="../standalone/configuration/"
else
# assume is domain.sh
serverdir="../domain/configuration/"
fi
for i in ${!COMP_WORDS[*]}
do
if [[ "${COMP_WORDS[i]}" == "-Djboss.server.base.dir" || "${COMP_WORDS[i]}" == "-Djboss.domain.base.dir" ]]; then
serverdir="${COMP_WORDS[i+2]}/configuration"
fi
done
if [ -d "${serverdir}" ]
then
IFS=$'\n' tmp="$(ls "${serverdir}" | grep xml)"
local fls="${tmp[@]// /\ }"
unset IFS
COMPREPLY=( $(compgen -W "${fls} initial boot last v" -- "$cur" ))
fi
}
_bindingAddress(){
# from /etc/bash_completion.d/ssh
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \
"0.0.0.0 $( PATH="$PATH:/sbin" ifconfig -a | \
sed -ne 's/.*addr:\([^[:space:]]*\).*/\1/p' \
-ne 's/.*inet[[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p' )" \
-- "$cur" ) )
}
_jboss(){
local cur prev words cword
COMPREPLY=()
_get_comp_words_by_ref -n = cur prev words cword
case $cur in
-Djboss.socket.binding.port-offset=*)
cur=${cur#*=}
#static list of common bindings sets
local bindings="100 200 300 400 10000 20000 30000 40000"
COMPREPLY=( $(compgen -W "${bindings}" -- ${cur}) )
return 0
;;
-Djboss.default.jgroups.stack=*)
cur=${cur#*=}
#static list of standard JGroups stacks
local stacks="udp udp-async udp-sync tcp tcp-sync"
COMPREPLY=( $(compgen -W "${stacks}" -- ${cur}) )
return 0
;;
-Dorg.jboss.ejb3.remoting.IsLocalInterceptor.passByRef=*|-Dcom.sun.management.jmxremote.authenticate=*|-Dcom.sun.management.jmxremote.ssl=*)
cur=${cur#*=}
local booleans="true false"
COMPREPLY=( $(compgen -W "${booleans}" -- ${cur}) )
return 0
;;
-Djboss.server.base.dir=*|-Djboss.home.dir=*|-Djboss.domain.base.dir=*)
cur=${cur#*=}
_filedir -d
return 0
;;
-Djboss.domain.master.address=*|-Djboss.bind.address*=*)
cur=${cur#*=}
_bindingAddress
return 0
;;
--server-config=*|-c=|--host-config=*)
cur=${cur#*=}
_serverProfiles
return 0
esac
case $prev in
-u)
# a few from RFC 2365 IPv4 Local Scope ()
local addresses="239.255.0.1 239.255.0.2 239.255.0.3"
COMPREPLY=( $(compgen -W "${addresses}" -- ${cur}) )
return 0
;;
-b*)
_bindingAddress
return 0
;;
-c)
_serverProfiles
return 0
;;
*)
;;
esac
# *** from jboss5 ********************
# *** -modulepath -c -m -g -l -d -p -n -B -L -C -Djboss.platform.mbeanserver -Djboss.server.base.directory
# *** -Djboss.Domain -Djboss.modcluster.proxyList -Djboss.jvmRoute -Djboss.default.jgroups.stack -Dorg.jboss.ejb3.remoting.IsLocalInterceptor.passByRef -Djboss.platform.mbeanserver -Dcom.sun.management.jmxremote.port -Dcom.sun.management.jmxremote.ssl
# *************************************
# standard commands for standalone and domain mode
local commandsWithoutEqualSign='-b -bmanagement -bunsecure -bpublic --admin-only -h -help -u -version -V -v'
local commandsWithEqualSign='-P -Djboss.node.name -Djboss.home.dir -Djboss.socket.binding.port-offset -Djboss.bind.address.management -Djboss.bind.address -Djboss.bind.address.unsecure'
if [[ $COMP_WORDS == *standalone.sh* ]]
then
commandsWithoutEqualSign="${commandsWithoutEqualSign} -c"
commandsWithEqualSign="${commandsWithEqualSign} --server-config -Djboss.server.base.dir -c"
else
# assume is domain.sh
commandsWithoutEqualSign="${commandsWithoutEqualSign} --backup --cached-dc"
commandsWithEqualSign="${commandsWithEqualSign} -Djboss.domain.master.address --host-config -Djboss.domain.master.port -Djboss.domain.base.dir "
fi
COMPREPLY=( $( compgen -W "$commandsWithoutEqualSign" -- "$cur" )
$( compgen -W "$commandsWithEqualSign" -S '=' -- "$cur" ) )
return 0
}
complete -o nospace -F _jboss standalone.sh
complete -o nospace -F _jboss domain.sh

View File

@@ -1 +1,7 @@
[[ -x "$(which jungle)" ]] && eval "$(_JUNGLE_COMPLETE=source jungle)" # shellcheck shell=bash
cite "about-completion"
about-completion "jungle(AWS cli tool) completion"
if _command_exists jungle; then
eval "$(_JUNGLE_COMPLETE=source jungle)"
fi

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash # shellcheck shell=bash
# Published originally as public domain code at https://github.com/wk8/knife-bash-autocomplete # Published originally as public domain code at https://github.com/wk8/knife-bash-autocomplete

View File

@@ -1 +1,5 @@
which kontena > /dev/null && . "$( kontena whoami --bash-completion-path )" # shellcheck shell=bash
if _command_exists kontena; then
# shellcheck disable=SC1090
source "$(kontena whoami --bash-completion-path)"
fi

View File

@@ -1,8 +1,7 @@
#!/usr/bin/env bash # shellcheck shell=bash
cite "about-completion"
about-completion "kubectl (Kubernetes CLI) completion"
# kubectl (Kubernetes CLI) completion if _binary_exists kubectl; then
if command -v kubectl &>/dev/null
then
eval "$(kubectl completion bash)" eval "$(kubectl completion bash)"
fi fi

View File

@@ -1,6 +1,8 @@
#!/bin/bash # shellcheck shell=bash
# Lerna autocompletion. cite "about-completion"
function _lerna_completions() { about-completion "lerna(javascript project manager tool) completion"
function __lerna_completion() {
local cur compls local cur compls
# The currently-being-completed word. # The currently-being-completed word.
@@ -14,6 +16,7 @@ function _lerna_completions() {
--version" --version"
# Tell complete what stuff to show. # Tell complete what stuff to show.
# shellcheck disable=2207
COMPREPLY=($(compgen -W "$compls" -- "$cur")) COMPREPLY=($(compgen -W "$compls" -- "$cur"))
} }
complete -o default -F _lerna_completions lerna complete -o default -F __lerna_completion lerna

View File

@@ -1,8 +1,6 @@
#!/usr/bin/env bash # shellcheck shell=bash
# minikube (Local Kubernetes) completion # minikube (Local Kubernetes) completion
if command -v minikube &>/dev/null if _command_exists minikube; then
then
eval "$(minikube completion bash)" eval "$(minikube completion bash)"
fi fi

View File

@@ -0,0 +1,45 @@
# shellcheck shell=bash
__ngrok_completion() {
local prev=$(_get_pword)
local curr=$(_get_cword)
local BASE_NO_CONF="--log --log-format --log-level --help"
local BASE="--config $BASE_NO_CONF"
local DEFAULT="$BASE --authtoken --region"
case $prev in
authtoken)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "$BASE" -- "$curr"))
;;
http)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "$DEFAULT --auth --bind-tls --host-header --hostname --inspect --subdomain" -- "$curr"))
;;
start)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "$DEFAULT --all --none" -- "$curr"))
;;
tcp)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "$DEFAULT --remote-addr" -- "$curr"))
;;
tls)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "$DEFAULT --client-cas --crt --hostname --key --subdomain" -- "$curr"))
;;
update)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "$BASE_NO_CONF --channel" -- "$curr"))
;;
ngrok)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "authtoken credits http start tcp tls update version help" -- "$curr"))
;;
*) ;;
esac
}
complete -F __ngrok_completion ngrok

View File

@@ -0,0 +1,19 @@
# shellcheck shell=bash
function __notify-send_completions() {
local curr=$(_get_cword)
local prev=$(_get_pword)
case $prev in
-u | --urgency)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "low normal critical" -- "$curr"))
;;
*)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-? --help -u --urgency -t --expire-time -a --app-name -i --icon -c --category -h --hint -v --version" -- "$curr"))
;;
esac
}
complete -F __notify-send_completions notify-send

View File

@@ -1,9 +1,7 @@
#!/usr/bin/env bash # shellcheck shell=bash
cite "about-completion"
about-completion "npm (Node Package Manager) completion"
# npm (Node Package Manager) completion if _command_exists npm; then
# https://docs.npmjs.com/cli/completion
if command -v npm &>/dev/null
then
eval "$(npm completion)" eval "$(npm completion)"
fi fi

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash # shellcheck shell=bash
cite "about-completion" cite "about-completion"
about-completion "packer completion" about-completion "packer completion"

View File

@@ -1,10 +1,11 @@
# shellcheck shell=bash
# https://pip.pypa.io/en/stable/user_guide/#command-completion # https://pip.pypa.io/en/stable/user_guide/#command-completion
# Of course, you should first install the pip, say on Debian: # Of course, you should first install pip, say on Debian:
# sudo apt-get install python-pip # sudo apt-get install python-pip
# sudo apt-get install python3-pip
# If the pip package is installed within virtual environments, say, python managed by pyenv, # If the pip package is installed within virtual environments, say, python managed by pyenv,
# you should first initilization the corresponding environment. # you should first initialize the corresponding environment.
# So that the pip/pip3 is in system's path. # So that pip is in the system's path.
if command -v pip >/dev/null; then if _command_exists pip; then
eval "$(pip completion --bash)" eval "$(pip completion --bash)"
fi fi

View File

@@ -1,10 +1,11 @@
# shellcheck shell=bash
# https://pip.pypa.io/en/stable/user_guide/#command-completion # https://pip.pypa.io/en/stable/user_guide/#command-completion
# Of course, you should first install the pip, say on Debian: # Of course, you should first install pip, say on Debian:
# sudo apt-get install python-pip
# sudo apt-get install python3-pip # sudo apt-get install python3-pip
# If the pip package is installed within virtual environments, say, python managed by pyenv, # If the pip package is installed within virtual environments, say, python managed by pyenv,
# you should first initilization the corresponding environment. # you should first initialize the corresponding environment.
# So that the pip/pip3 is in system's path. # So that pip3 is in the system's path.
if command -v pip3 >/dev/null; then if _command_exists pip3; then
eval "$(pip3 completion --bash)" eval "$(pip3 completion --bash)"
fi fi

View File

@@ -1 +1,4 @@
[[ -x "$(which pipenv)" ]] && eval "$(pipenv --completion)" # shellcheck shell=bash
if _command_exists pipenv; then
eval "$(pipenv --completion)"
fi

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash # shellcheck shell=bash
# pipx completion # pipx completion
if _command_exists register-python-argcomplete && _command_exists pipx; then if _command_exists register-python-argcomplete && _command_exists pipx; then

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash # shellcheck shell=bash
# rustup (Rust toolchain installer) completion # rustup (Rust toolchain installer) completion

View File

@@ -1,71 +1,83 @@
_sdkman_complete() # shellcheck shell=bash
{ _sdkman_complete() {
local CANDIDATES local CANDIDATES
local CANDIDATE_VERSIONS local CANDIDATE_VERSIONS
COMPREPLY=() COMPREPLY=()
if [ $COMP_CWORD -eq 1 ]; then if [ "$COMP_CWORD" -eq 1 ]; then
COMPREPLY=( $(compgen -W "install uninstall rm list ls use current outdated version default selfupdate broadcast offline help flush" -- ${COMP_WORDS[COMP_CWORD]}) ) mapfile -t COMPREPLY < <(compgen -W "install uninstall rm list ls use default home env current upgrade ug version broadcast help offline selfupdate update flush" -- "${COMP_WORDS[COMP_CWORD]}")
elif [ $COMP_CWORD -eq 2 ]; then elif [ "$COMP_CWORD" -eq 2 ]; then
case "${COMP_WORDS[COMP_CWORD - 1]}" in case "${COMP_WORDS[COMP_CWORD - 1]}" in
"install" | "uninstall" | "rm" | "list" | "ls" | "use" | "current" | "outdated" ) "install" | "i" | "uninstall" | "rm" | "list" | "ls" | "use" | "u" | "default" | "d" | "home" | "h" | "current" | "c" | "upgrade" | "ug")
CANDIDATES=$(echo "${SDKMAN_CANDIDATES_CSV}" | tr ',' ' ') CANDIDATES=$(echo "${SDKMAN_CANDIDATES_CSV}" | tr ',' ' ')
COMPREPLY=( $(compgen -W "$CANDIDATES" -- ${COMP_WORDS[COMP_CWORD]}) ) mapfile -t COMPREPLY < <(compgen -W "$CANDIDATES" -- "${COMP_WORDS[COMP_CWORD]}")
;;
"env")
mapfile -t COMPREPLY < <(compgen -W "init" -- "${COMP_WORDS[COMP_CWORD]}")
;; ;;
"offline") "offline")
COMPREPLY=( $(compgen -W "enable disable" -- ${COMP_WORDS[COMP_CWORD]}) ) mapfile -t COMPREPLY < <(compgen -W "enable disable" -- "${COMP_WORDS[COMP_CWORD]}")
;; ;;
"selfupdate") "selfupdate")
COMPREPLY=( $(compgen -W "force" -P "[" -S "]" -- ${COMP_WORDS[COMP_CWORD]}) ) mapfile -t COMPREPLY < <(compgen -W "force" -- "${COMP_WORDS[COMP_CWORD]}")
;; ;;
"flush") "flush")
COMPREPLY=( $(compgen -W "candidates broadcast archives temp" -- ${COMP_WORDS[COMP_CWORD]}) ) mapfile -t COMPREPLY < <(compgen -W "archives tmp broadcast version" -- "${COMP_WORDS[COMP_CWORD]}")
;;
*)
;; ;;
*) ;;
esac esac
elif [ $COMP_CWORD -eq 3 ]; then elif [ "$COMP_CWORD" -eq 3 ]; then
case "${COMP_WORDS[COMP_CWORD - 2]}" in case "${COMP_WORDS[COMP_CWORD - 2]}" in
"uninstall" | "rm" | "use" | "default" ) "uninstall" | "rm" | "use" | "u" | "default" | "d" | "home" | "h")
_sdkman_candidate_versions ${COMP_WORDS[COMP_CWORD-1]} _sdkman_candidate_local_versions "${COMP_WORDS[COMP_CWORD - 1]}"
COMPREPLY=( $(compgen -W "$CANDIDATE_VERSIONS" -- ${COMP_WORDS[COMP_CWORD]}) ) mapfile -t COMPREPLY < <(compgen -W "$CANDIDATE_VERSIONS" -- "${COMP_WORDS[COMP_CWORD]}")
;; ;;
"install") "install" | "i")
_sdkman_candidate_not_installed_versions ${COMP_WORDS[COMP_CWORD-1]} _sdkman_candidate_all_versions "${COMP_WORDS[COMP_CWORD - 1]}"
COMPREPLY=( $(compgen -W "$CANDIDATE_VERSIONS" -- ${COMP_WORDS[COMP_CWORD]}) ) mapfile -t COMPREPLY < <(compgen -W "$CANDIDATE_VERSIONS" -- "${COMP_WORDS[COMP_CWORD]}")
;;
*)
;; ;;
*) ;;
esac esac
fi fi
return 0 return 0
} }
_sdkman_candidate_versions(){ _sdkman_candidate_local_versions() {
CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions $1) CANDIDATE_VERSIONS=$(__sdkman_cleanup_local_versions "$1")
if [ "$SDKMAN_OFFLINE_MODE" = "true" ]; then
CANDIDATE_VERSIONS=$CANDIDATE_LOCAL_VERSIONS
else
CANDIDATE_ONLINE_VERSIONS="$(curl -s "${SDKMAN_SERVICE}/candidates/$1" | tr ',' ' ')"
CANDIDATE_VERSIONS="$(echo $CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS |sort | uniq ) "
fi
} }
_sdkman_candidate_not_installed_versions(){ _sdkman_candidate_all_versions() {
CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions $1)
if [ "$SDKMAN_OFFLINE_MODE" = "false" ]; then candidate="$1"
CANDIDATE_ONLINE_VERSIONS="$(__sdkman_list_versions $1 | grep " " | grep "\." | cut -c 6-)" CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions "$candidate")
CANDIDATE_VERSIONS="$(echo $CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS | tr ' ' '\n' | sort | uniq -u) " if [ "$SDKMAN_OFFLINE_MODE" = "true" ]; then
CANDIDATE_VERSIONS=$CANDIDATE_LOCAL_VERSIONS
else
# sdkman has a specific output format for Java candidate since
# there are multiple vendors and builds.
if [ "$candidate" = "java" ]; then
CANDIDATE_ONLINE_VERSIONS="$(__sdkman_list_versions "$candidate" | grep " " | grep "\." | cut -c 62-)"
else
CANDIDATE_ONLINE_VERSIONS="$(__sdkman_list_versions "$candidate" | grep " " | grep "\." | cut -c 6-)"
fi fi
# the last grep is used to filter out sdkman flags, such as:
# "+" - local version
# "*" - installed
# ">" - currently in use
CANDIDATE_VERSIONS="$(echo "$CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS" | tr ' ' '\n' | grep -v -e '^[[:space:]|\*|\>|\+]*$' | sort | uniq -u) "
fi
} }
__sdkman_cleanup_local_versions() { __sdkman_cleanup_local_versions() {
__sdkman_build_version_csv $1 | tr ',' ' ' __sdkman_build_version_csv "$1" | tr ',' ' '
} }

View File

@@ -1,2 +1,2 @@
_log_error 'Bash completion for "todo.txt-cli" is now deprecated, as it used code with incompatible license. _log_warning '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.' Please disable this completion and use the instructions from "todo.txt-cli" developers instead.'

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash # shellcheck shell=bash
cite "about-completion" cite "about-completion"
about-completion "vault completion" about-completion "vault completion"

View File

@@ -1,2 +1,2 @@
_log_error 'Bash completion for "virsh" is now deprecated, as it used code with incompatible license. _log_warning 'Bash completion for "virsh" is now deprecated, as it used code with incompatible license.
Please disable this completion and use the instructions from "virsh" developers instead.' Please disable this completion and use the instructions from "virsh" developers instead.'

View File

@@ -1,15 +1,59 @@
#!/usr/bin/bash # shellcheck shell=bash
if command -v vue > /dev/null; then
__vuejs_completion() { __vuejs_completion() {
local OPTS=("--version --help create add invoke inspect serve build ui init config upgrade info") local prev=$(_get_pword)
COMPREPLY=() local curr=$(_get_cword)
for _opt_ in ${OPTS[@]}; do
if [[ "$_opt_" == "$2"* ]]; then case $prev in
COMPREPLY+=("$_opt_") create)
fi # shellcheck disable=SC2207
done COMPREPLY=($(compgen -W "-p -d -i -m -r -g -n -f -c -x -b -h --help --preset --default --inilinePreset --packageManager --registry --git --no-git --force --merge --clone --proxy --bare --skipGetStarted" -- "$curr"))
;;
add | invoke)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "--registry -h --help" -- "$curr"))
;;
inspect)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-v --help --verbose --mode --rule --plugin --plugins --rules" -- "$curr"))
;;
serve)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-o -h --help --open -c --copy -p --port" -- "$curr"))
;;
build)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-t --target -n --name -d --dest -h --help" -- "$curr"))
;;
ui)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-H --host -p --port -D --dev --quiet --headless -h --help" -- "$curr"))
;;
init)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-c --clone --offline -h --help" -- "$curr"))
;;
config)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-g --get -s --set -d --delete -e --edit --json -h --help" -- "$curr"))
;;
outdated)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "--next -h --help" -- "$curr"))
;;
upgrade)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-t --to -f --from -r --registry --all --next -h --help" -- "$curr"))
;;
migrate)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-f --from -h --help" -- "$curr"))
;;
*)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-h --help -v --version create add invoke inspect serve build ui init config outdated upgrade migrate info" -- "$curr"))
;;
esac
} }
complete -F __vuejs_completion vue complete -F __vuejs_completion vue
fi

View File

@@ -1,10 +1,10 @@
#!/usr/bin/bash # shellcheck shell=bash
if command -v wpscan > /dev/null; then if command -v wpscan > /dev/null; then
__wpscan_completion() { __wpscan_completion() {
local OPTS=("--help --hh --version --url --ignore-main-redirect --verbose --output --format --detection-mode --scope --headers --user-agent --vhost --random-user-agent --user-agents-list --http-auth --max-threads --throttle --request-timeout --connect-timeout --disable-tlc-checks --proxy --proxy-auth --cookie-string --cookie-jar --cache-ttl --clear-cache --server --cache-dir --update --no-update --wp-content-dir --wp-plugins-dir --wp-version-detection --main-theme-detection --enumerate --exclude-content-based --plugins-list --plugins-detection --plugins-version-all --plugins-version-detection --themes-list --themes-detection --themes-version-all --themes-version-detection --timthumbs-list --timthumbs-detection --config-backups-list --config-backups-detection --db-exports-list --db-exports-detection --medias-detection --users-list --users-detection --passwords --usernames --multicall-max-passwords --password-attack --stealthy") local OPTS=("--help --hh --version --url --ignore-main-redirect --verbose --output --format --detection-mode --scope --headers --user-agent --vhost --random-user-agent --user-agents-list --http-auth --max-threads --throttle --request-timeout --connect-timeout --disable-tlc-checks --proxy --proxy-auth --cookie-string --cookie-jar --cache-ttl --clear-cache --server --cache-dir --update --no-update --wp-content-dir --wp-plugins-dir --wp-version-detection --main-theme-detection --enumerate --exclude-content-based --plugins-list --plugins-detection --plugins-version-all --plugins-version-detection --themes-list --themes-detection --themes-version-all --themes-version-detection --timthumbs-list --timthumbs-detection --config-backups-list --config-backups-detection --db-exports-list --db-exports-detection --medias-detection --users-list --users-detection --passwords --usernames --multicall-max-passwords --password-attack --stealthy")
COMPREPLY=() COMPREPLY=()
for _opt_ in ${OPTS[@]}; do for _opt_ in "${OPTS[@]}"; do
if [[ "$_opt_" == "$2"* ]]; then if [[ "$_opt_" == "$2"* ]]; then
COMPREPLY+=("$_opt_") COMPREPLY+=("$_opt_")
fi fi

View File

@@ -1,7 +1,10 @@
# Bash-it ![logo](https://github.com/Bash-it/media/raw/master/media/Bash-it.png)
![Build Status](https://github.com/Bash-it/bash-it/workflows/CI/badge.svg?branch=master) ![Build Status](https://github.com/Bash-it/bash-it/workflows/CI/badge.svg?branch=master)
![Docs Status](https://readthedocs.org/projects/bash-it/badge/) ![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) ![License](https://img.shields.io/github/license/Bash-it/bash-it)
![shell](https://img.shields.io/badge/Shell-Bash-blue)
[![Join the chat at https://web.libera.chat/?channel=#bash-it](https://img.shields.io/badge/chat-on%20Libera.Chat-brightgreen.svg)](https://web.libera.chat/?channel=#bash-it)
**Bash-it** is a collection of community Bash commands and scripts for Bash 3.2+. **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:) (And a shameless ripoff of [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) :smiley:)
@@ -39,7 +42,8 @@ Stop polluting your `~/bin` directory and your `.bashrc` file, fork/clone Bash-i
``git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it`` ``git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it``
2) Run ``~/.bash_it/install.sh`` 2) Run ``~/.bash_it/install.sh``
Thats it! :smiley: That's it! :smiley:
You can check out more components of Bash-it, and customize it to your desire. 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/). For more information, see detailed instructions [here](https://bash-it.readthedocs.io/en/latest/installation/).
@@ -53,6 +57,8 @@ please feel free to read through this page if you're interested in how Bash-it l
## Contributors ## Contributors
* [List of contributors][contribute] [List of contributors](https://github.com/Bash-it/bash-it/contributors)
[contribute]: https://github.com/Bash-it/bash-it/contributors ## License
Bash-it is licensed under the [MIT License](https://github.com/Bash-it/bash-it/blob/master/LICENSE).

View File

@@ -8,3 +8,16 @@ your Bash profile when you make changes.
Additionally, if you export ``BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE`` as a non-null value, 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. Bash-it will automatically reload itself after activating or deactivating plugins, aliases, or completions.
.. warning::
When changing theme, do not use ``bash-it reload``. Instead, use :ref:`restart`.
.. _restart:
Bash-it restart
^^^^^^^^^^^^^^^
Similar to :ref:`reload`, ``bash-it restart`` can be used to restart your shell.
Instead of reloading your Bash profile, this command re-runs Bash (using exec).
This is stronger than simple reload, and is similar to the effect of closing and reopening your terminal.

View File

@@ -10,11 +10,6 @@ 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. * 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... Don't be afraid, most things aren't that complex...
@@ -42,6 +37,8 @@ Code Style
* 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. * 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. * 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>`_. 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>`_.
* Prefer to invoke commands directly using the ``command`` shell builtin. This way, your code
will always execute the command you wanted and not an alias/function that overrides the name of the command. (For example, use ``command rm`` instead of ``rm``)
* When creating new functions, please use a dash ("-") to separate the words of the function's name, e.g. ``my-new-function``. * 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``. 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``. * Internal functions that aren't to be used by the end user should start with an underscore, e.g. ``_my-new-internal-function``.
@@ -59,8 +56,8 @@ 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. 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. 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. Any code pushed to GitHub as part of a Pull Request will automatically trigger a continuous integration build on `GitHub Actions <https://github.com/Bash-it/bash-it/actions>`_\ , 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. The Pull Request will then show the result of the CI 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. 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. Adding new functionality or changing existing functionality is a good opportunity to increase Bash-it's test coverage.

View File

@@ -37,8 +37,12 @@ General Load Order
The main ``bash_it.sh`` script loads the frameworks individual components in the following 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?)
* ``vendor/github.com/erichs/composure/composure.sh``
* ``lib/log.bash``
* ``vendor/init.d/*.bash``
* Files in ``lib`` with the exception of ``appearance.bash`` - this means that ``log.bash`` is loaded again here (possible improvement?)
* Enabled ``aliases`` * Enabled ``aliases``
* Enabled ``plugins`` * Enabled ``plugins``
* Enabled ``completions`` * Enabled ``completions``
@@ -78,6 +82,65 @@ Having the order based on a numeric priority in a common directory allows for mo
These items are subject to change. When making changes to the internal functionality, this page needs to be updated as well. These items are subject to change. When making changes to the internal functionality, this page needs to be updated as well.
Working with vendored libs
--------------------------
Vendored libs are external libraries, meaning source code not maintained by Bash-it
developers.
They are ``git subtrees`` curated in the ``vendor/`` folder. To ease the work with git
vendored libs as subtrees we use the `git-vendor <https://github.com/Tyrben/git-vendor>`_ tool.
The `original repo <https://github.com/brettlangdon/git-vendor>`_ for git vendor is
unmaintained so for now we are recommending Tyrben's fork.
For more information on ``git vendor`` there are a short `usage description <https://github.com/Tyrben/git-vendor#usage>`_
in the repositories ``README`` file and a website for the original repository has a `manual page <https://brettlangdon.github.io/git-vendor/>`_ which is also included in both
repositories.
To support a flexible loading of external libraries, a file unique to the vendored
library must be placed in ``vendor/init.d/`` with the ``.bash`` extension.
Rebasing a feature branch with an added/updated vendored library
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If your feature branch with a newly added/updated vendored lib has fallen behind master
you might need to rebase it before creating a PR. However rebasing with dangling
subtree commits can cause problems.
The following rebase strategy will pause the rebase at the point where you added a
subtree and let you add it again before continuing the rebasing.
::
[feature/branch] $ git rebase --rebase-merges --strategy subtree master
fatal: refusing to merge unrelated histories
Could not apply 0d6a56b... Add-preexec-from-https-github-com-rcaloras-bash-preexec-0-4-1- # Add "preexec" from "https://github.com/rcaloras/bash-preexec@0.4.1"
[feature/branch] $ git vendor add preexec https://github.com/rcaloras/bash-preexec 0.4.1
...
[feature/branch] $ git rebase --continue
If rebasing makes you a little uneasy (as it probably should). You can always test in
another branch.
::
[feater/branch] $ git checkout -b feature/branch-test-rebase
[feater/branch-test-rebase] $ git rebase --rebase-merges --strategy subtree master
...
Afterwards you can make sure the rebase was successful by running ``git vendor list``
to see if your library is still recognized as a vendored lib
::
[feature/branch] $ git vendor list
preexec@0.4.1:
name: preexec
dir: vendor/github.com/rcaloras/bash-preexec
repo: https://github.com/rcaloras/bash-preexec
ref: 0.4.1
commit: 8fe585c5cf377a3830b895fe26e694b020d8db1a
[feature/branch] $
Plugin Disable Callbacks Plugin Disable Callbacks
------------------------ ------------------------

14
docs/themes-list/easy.rst Normal file
View File

@@ -0,0 +1,14 @@
.. _easy:
Easy Theme
==========
A simple theme
Examples
--------
.. code-block:: bash
user@hostname ~/.bash_it
[ master ✓ ]

View File

@@ -187,6 +187,22 @@ Doubletime Multiline Python Only
:alt: :alt:
----
Easy
^^^^
.. image:: https://bash-it.github.io/bash-it/docs/images/easy-black.jpg
:target: https://bash-it.github.io/bash-it/docs/images/easy-black.jpg
:alt:
.. image:: https://bash-it.github.io/bash-it/docs/images/easy-white.jpg
:target: https://bash-it.github.io/bash-it/docs/images/easy-white.jpg
:alt:
---- ----
Envy Envy

View File

@@ -70,10 +70,13 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o
* ``battery`` - Battery information (you'll need to enable the ``battery`` plugin) * ``battery`` - Battery information (you'll need to enable the ``battery`` plugin)
* ``clock`` - Current time in ``HH:MM:SS`` format * ``clock`` - Current time in ``HH:MM:SS`` format
* ``cwd`` - Current working directory including full folder hierarchy (c.f. ``wd``\ ) * ``cwd`` - Current working directory including full folder hierarchy (c.f. ``wd``\ )
* ``duration`` - Duration of the last command. See :ref:`Command duration <command_duration>` for details.
* ``gcloud`` - Current gcloud active account
* ``hostname`` - Host name of machine * ``hostname`` - Host name of machine
* ``in_toolbox`` - Show identifier if running inside a `toolbox <https://github.com/containers/toolbox>`_ * ``in_toolbox`` - Show identifier if running inside a `toolbox <https://github.com/containers/toolbox>`_
* ``in_vim`` - Show identifier if running in ``:terminal`` from vim * ``in_vim`` - Show identifier if running in ``:terminal`` from vim
* ``k8s_context`` - Show current kubernetes context * ``k8s_context`` - Show current kubernetes context
* ``k8s_namespace`` - Show current kubernetes namespace
* ``last_status`` - Exit status of last run command * ``last_status`` - Exit status of last run command
* ``python_venv`` - Python virtual environment information (\ ``virtualenv``\ , ``venv`` * ``python_venv`` - Python virtual environment information (\ ``virtualenv``\ , ``venv``
and ``conda`` supported) and ``conda`` supported)

39
hooks/check-clean-files-txt.sh Executable file
View File

@@ -0,0 +1,39 @@
#!/usr/bin/env bash
file=$1
# Should only be run on clean_files.txt
if [ "$file" != "clean_files.txt" ]; then
echo "Please run this script on clean_files.txt only!"
exit 1
fi
function compare_lines() {
prev=""
while read -r line; do
# Skip unimportant lines
[[ $line =~ "#" ]] && continue
[[ $line == "" ]] && continue
# Actual check
if [[ $prev > $line ]]; then
echo "$line should be before $prev"
exit 1
fi
prev=$line
done <<< "$1"
}
# We compare using the legacy way
shopt -s compat31
# Test root files
compare_lines "$(grep -v "/" "$file")"
# Test root directory
compare_lines "$(grep "/$" "$file")"
# Test non root directories
compare_lines "$(grep "/." "$file")"
shopt -u compat31
# Yay, all good!
exit 0

21
hooks/dot-bash.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
exit_code=0
for file in "$@"; do
# Confirm file is not executable
#
if [[ -x "${file}" ]]; then
echo "Bash include file \`${file}\` should not be executable"
exit_code=1
fi
# Confirm expected schellcheck header
#
LINE1="$(head -n 1 "${file}")"
if [[ "${LINE1}" != "# shellcheck shell=bash" ]]; then
echo "Bash include file \`${file}\` has bad/missing shellcheck header"
exit_code=1
fi
done
exit $exit_code

21
hooks/dot-sh.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
exit_code=0
for file in "$@"; do
# Confirm file is executable
#
if [[ ! -x "${file}" ]]; then
echo "Bash file \`${file}\` is not executable"
exit_code=1
fi
# Confirm expected #! header
#
LINE1="$(head -n 1 "${file}")"
if [[ "${LINE1}" != "#!/usr/bin/env bash" ]]; then
echo "Bash file \`${file}\` has bad/missing #! header"
exit_code=1
fi
done
exit $exit_code

View File

@@ -2,20 +2,21 @@
# bash-it installer # bash-it installer
# Show how to use this installer # Show how to use this installer
function show_usage() { function _bash-it_show_usage() {
echo -e "\n$0 : Install bash-it" echo -e "\n$0 : Install bash-it"
echo -e "Usage:\n$0 [arguments] \n" echo -e "Usage:\n$0 [arguments] \n"
echo "Arguments:" echo "Arguments:"
echo "--help (-h): Display this help message" echo "--help (-h): Display this help message"
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" echo "--append-to-config (-a): Keep existing config file and append bash-it templates at the end"
exit 0; echo "--overwrite-backup (-f): Overwrite existing backup"
exit 0
} }
# enable a thing # enable a thing
function load_one() { function _bash-it_load_one() {
file_type=$1 file_type=$1
file_to_enable=$2 file_to_enable=$2
mkdir -p "$BASH_IT/${file_type}/enabled" mkdir -p "$BASH_IT/${file_type}/enabled"
@@ -29,21 +30,19 @@ function load_one() {
} }
# Interactively enable several things # Interactively enable several things
function load_some() { function _bash-it_load_some() {
file_type=$1 file_type=$1
single_type=$(echo "$file_type" | sed -e "s/aliases$/alias/g" | sed -e "s/plugins$/plugin/g") single_type=$(echo "$file_type" | sed -e "s/aliases$/alias/g" | sed -e "s/plugins$/plugin/g")
enable_func="_enable-$single_type" enable_func="_enable-$single_type"
[ -d "$BASH_IT/$file_type/enabled" ] || mkdir "$BASH_IT/$file_type/enabled" [ -d "$BASH_IT/$file_type/enabled" ] || mkdir "$BASH_IT/$file_type/enabled"
for path in "$BASH_IT/${file_type}/available/"[^_]* for path in "$BASH_IT/${file_type}/available/"[^_]*; do
do
file_name=$(basename "$path") file_name=$(basename "$path")
while true while true; do
do
just_the_name="${file_name%%.*}" just_the_name="${file_name%%.*}"
read -e -n 1 -p "Would you like to enable the $just_the_name $file_type? [y/N] " RESP read -r -e -n 1 -p "Would you like to enable the $just_the_name $file_type? [y/N] " RESP
case $RESP in case $RESP in
[yY]) [yY])
$enable_func $just_the_name $enable_func "$just_the_name"
break break
;; ;;
[nN] | "") [nN] | "")
@@ -58,26 +57,89 @@ function load_some() {
} }
# Back up existing profile # Back up existing profile
function backup() { function _bash-it_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 # Back up existing profile and create new one for bash-it
function backup_new() { function _bash-it_backup_new() {
backup _bash-it_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 # Back up existing profile and append bash-it templates at the end
function backup_append() { function _bash-it_backup_append() {
backup _bash-it_backup
(sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" | tail -n +2) >> "$HOME/$CONFIG_FILE" (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" echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m"
} }
function _bash-it_check_for_backup() {
if ! [[ -e "$HOME/$BACKUP_FILE" ]]; then
return
fi
echo -e "\033[0;33mBackup file already exists. Make sure to backup your .bashrc before running this installation.\033[0m" >&2
if ! [[ $overwrite_backup ]]; then
while ! [[ $silent ]]; do
read -e -n 1 -r -p "Would you like to overwrite the existing backup? This will delete your existing backup file ($HOME/$BACKUP_FILE) [y/N] " RESP
case $RESP in
[yY])
overwrite_backup=true
break
;;
[nN] | "")
break
;;
*)
echo -e "\033[91mPlease choose y or n.\033[m"
;;
esac
done
fi
if ! [[ $overwrite_backup ]]; then
echo -e "\033[91mInstallation aborted. Please come back soon!\033[m"
if [[ $silent ]]; then
echo -e "\033[91mUse \"-f\" flag to force overwrite of backup.\033[m"
fi
exit 1
else
echo -e "\033[0;32mOverwriting backup...\033[m"
fi
}
function _bash-it_modify_config_files() {
_bash-it_check_for_backup
if ! [[ $silent ]]; then
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
case $choice in
[yY])
append_to_config=true
break
;;
[nN] | "")
break
;;
*)
echo -e "\033[91mPlease choose y or n.\033[m"
;;
esac
done
fi
if [[ $append_to_config ]]; then
# backup/append
_bash-it_backup_append
else
# backup/new by default
_bash-it_backup_new
fi
}
for param in "$@"; do for param in "$@"; do
shift shift
case "$param" in case "$param" in
@@ -86,32 +148,40 @@ for param in "$@"; do
"--interactive") set -- "$@" "-i" ;; "--interactive") set -- "$@" "-i" ;;
"--no-modify-config") set -- "$@" "-n" ;; "--no-modify-config") set -- "$@" "-n" ;;
"--append-to-config") set -- "$@" "-a" ;; "--append-to-config") set -- "$@" "-a" ;;
*) set -- "$@" "$param" "--overwrite-backup") set -- "$@" "-f" ;;
*) set -- "$@" "$param" ;;
esac esac
done done
OPTIND=1 OPTIND=1
while getopts "hsina" opt while getopts "hsinaf" opt; do
do
case "$opt" in case "$opt" in
"h") show_usage; exit 0 ;; "h")
_bash-it_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 ;; "a") append_to_config=true ;;
"?") show_usage >&2; exit 1 ;; "f") overwrite_backup=true ;;
"?")
_bash-it_show_usage >&2
exit 1
;;
esac esac
done done
shift $(expr $OPTIND - 1)
shift $((OPTIND - 1))
if [[ $silent ]] && [[ $interactive ]]; then if [[ $silent ]] && [[ $interactive ]]; then
echo -e "\033[91mOptions --silent and --interactive are mutually exclusive. Please choose one or the other.\033[m" echo -e "\033[91mOptions --silent and --interactive are mutually exclusive. Please choose one or the other.\033[m"
exit 1; exit 1
fi fi
if [[ $no_modify_config ]] && [[ $append_to_config ]]; then 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" echo -e "\033[91mOptions --no-modify-config and --append-to-config are mutually exclusive. Please choose one or the other.\033[m"
exit 1; exit 1
fi fi
BASH_IT="$(cd "$(dirname "$0")" && pwd)" BASH_IT="$(cd "$(dirname "$0")" && pwd)"
@@ -127,64 +197,25 @@ esac
BACKUP_FILE=$CONFIG_FILE.bak BACKUP_FILE=$CONFIG_FILE.bak
echo "Installing bash-it" echo "Installing bash-it"
if ! [[ $silent ]] && ! [[ $no_modify_config ]]; then if ! [[ $no_modify_config ]]; then
if [ -e "$HOME/$BACKUP_FILE" ]; then _bash-it_modify_config_files
echo -e "\033[0;33mBackup file already exists. Make sure to backup your .bashrc before running this installation.\033[0m" >&2
while ! [ $silent ]; do
read -e -n 1 -r -p "Would you like to overwrite the existing backup? This will delete your existing backup file ($HOME/$BACKUP_FILE) [y/N] " RESP
case $RESP in
[yY])
break
;;
[nN]|"")
echo -e "\033[91mInstallation aborted. Please come back soon!\033[m"
exit 1
;;
*)
echo -e "\033[91mPlease choose y or n.\033[m"
;;
esac
done
fi
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
case $choice in
[yY])
backup_append
break
;;
[nN]|"")
backup_new
break
;;
*)
echo -e "\033[91mPlease choose y or n.\033[m"
;;
esac
done
elif [[ $append_to_config ]]; then
# backup/append
backup_append
elif [[ $silent ]] && ! [[ $no_modify_config ]]; then
# backup/new by default
backup_new
fi fi
# Disable auto-reload in case its enabled # Disable auto-reload in case its enabled
export BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE='' export BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE=''
# Load dependencies for enabling components # Load dependencies for enabling components
source "$BASH_IT/lib/composure.bash" # shellcheck disable=SC1090
source "${BASH_IT}"/vendor/github.com/erichs/composure/composure.sh
# shellcheck source=./lib/utilities.bash
source "$BASH_IT/lib/utilities.bash" source "$BASH_IT/lib/utilities.bash"
cite _about _param _example _group _author _version cite _about _param _example _group _author _version
# shellcheck source=./lib/helpers.bash
source "$BASH_IT/lib/helpers.bash" source "$BASH_IT/lib/helpers.bash"
if [[ $interactive ]] && ! [[ $silent ]] ; if [[ $interactive ]] && ! [[ $silent ]]; then
then for type in "aliases" "plugins" "completion"; do
for type in "aliases" "plugins" "completion"
do
echo -e "\033[0;32mEnabling $type\033[0m" echo -e "\033[0;32mEnabling $type\033[0m"
load_some $type _bash-it_load_some $type
done done
else else
echo "" echo ""
@@ -198,6 +229,7 @@ fi
echo "" echo ""
echo -e "\033[0;32mInstallation finished successfully! Enjoy bash-it!\033[0m" echo -e "\033[0;32mInstallation finished successfully! Enjoy bash-it!\033[0m"
# shellcheck disable=SC2086
echo -e "\033[0;32mTo start using it, open a new tab or 'source "$HOME/$CONFIG_FILE"'.\033[0m" echo -e "\033[0;32mTo start using it, open a new tab or 'source "$HOME/$CONFIG_FILE"'.\033[0m"
echo "" echo ""
echo "To show the available aliases/completions/plugins, type one of the following:" echo "To show the available aliases/completions/plugins, type one of the following:"

View File

@@ -1,380 +0,0 @@
# composure - by erichs
# light-hearted functions for intuitive shell programming
# install: source this script in your ~/.profile or ~/.${SHELL}rc script
# latest source available at http://git.io/composure
# known to work on bash, zsh, and ksh93
# 'plumbing' functions
composure_keywords ()
{
echo "about author example group param version"
}
letterpress ()
{
typeset rightcol="$1" leftcol="${2:- }"
if [ -z "$rightcol" ]; then
return
fi
printf "%-20s%s\n" "$leftcol" "$rightcol"
}
transcribe ()
{
typeset func=$1
typeset file=$2
typeset operation="$3"
if git --version >/dev/null 2>&1; then
if [ -d ~/.composure ]; then
(
cd ~/.composure
if git rev-parse 2>/dev/null; then
if [ ! -f $file ]; then
printf "%s\n" "Oops! Couldn't find $file to version it for you..."
return
fi
cp $file ~/.composure/$func.inc
git add --all .
git commit -m "$operation $func"
fi
)
else
if [ "$USE_COMPOSURE_REPO" = "0" ]; then
return # if you say so...
fi
printf "%s\n" "I see you don't have a ~/.composure repo..."
typeset input
typeset valid=0
while [ $valid != 1 ]; do
printf "\n%s" 'would you like to create one? y/n: '
read input
case $input in
y|yes|Y|Yes|YES)
(
echo 'creating git repository for your functions...'
mkdir ~/.composure
cd ~/.composure
git init
echo "composure stores your function definitions here" > README.txt
git add README.txt
git commit -m 'initial commit'
)
# if at first you don't succeed...
transcribe "$func" "$file" "$operation"
valid=1
;;
n|no|N|No|NO)
printf "%s\n" "ok. add 'export USE_COMPOSURE_REPO=0' to your startup script to disable this message."
valid=1
;;
*)
printf "%s\n" "sorry, didn't get that..."
;;
esac
done
fi
fi
}
typeset_functions ()
{
# unfortunately, there does not seem to be a easy, portable way to list just the
# names of the defined shell functions...
# first, determine our shell:
typeset shell
if [ -n "$SHELL" ]; then
shell=$(basename $SHELL) # we assume this is set correctly!
else
# we'll have to try harder
# here's a hack I modified from a StackOverflow post:
# we loop over the ps listing for the current process ($$), and print the last column (CMD)
# stripping any leading hyphens bash sometimes throws in there
typeset x ans
typeset this=$(for x in $(ps -p $$); do ans=$x; done; printf "%s\n" $ans | sed 's/^-*//')
typeset shell=$(basename $this) # e.g. /bin/bash => bash
fi
case "$shell" in
bash)
typeset -F | awk '{print $3}'
;;
*)
# trim everything following '()' in ksh
typeset +f | sed 's/().*$//'
;;
esac
}
# bootstrap metadata keywords for porcelain functions
for f in $(composure_keywords)
do
eval "$f() { :; }"
done
unset f
# 'porcelain' functions
cite ()
{
about creates one or more meta keywords for use in your functions
param one or more keywords
example '$ cite url username'
example '$ url http://somewhere.com'
example '$ username alice'
group composure
# this is the storage half of the 'metadata' system:
# we create dynamic metadata keywords with function wrappers around
# the NOP command, ':'
# anything following a keyword will get parsed as a positional
# parameter, but stay resident in the ENV. As opposed to shell
# comments, '#', which do not get parsed and are not available
# at runtime.
# a BIG caveat--your metadata must be roughly parsable: do not use
# contractions, and consider single or double quoting if it contains
# non-alphanumeric characters
if [ -z "$1" ]; then
printf '%s\n' 'missing parameter(s)'
reference cite
return
fi
typeset keyword
for keyword in $*; do
eval "$keyword() { :; }"
done
}
draft ()
{
about wraps command from history into a new function, default is last command
param 1: name to give function
param 2: optional history line number
example '$ ls'
example '$ draft list'
example '$ draft newfunc 1120 # wraps command at history line 1120 in newfunc()'
group composure
typeset func=$1
typeset num=$2
typeset cmd
if [ -z "$func" ]; then
printf '%s\n' 'missing parameter(s)'
reference draft
return
fi
# aliases bind tighter than function names, disallow them
if [ -n "$(LANG=C type -t $func 2>/dev/null | grep 'alias')" ]; then
printf '%s\n' "sorry, $(type -a $func). please choose another name."
return
fi
if [ -z "$num" ]; then
# parse last command from fc output
# some versions of 'fix command, fc' need corrective lenses...
typeset myopic=$(fc -ln -1 | grep draft)
typeset lines=1
if [ -n "$myopic" ]; then
lines=2
fi
cmd=$(fc -ln -$lines | head -1 | sed 's/^[[:blank:]]*//')
else
# parse command from history line number
cmd=$(eval "history | grep '^[[:blank:]]*$num' | head -1" | sed 's/^[[:blank:][:digit:]]*//')
fi
eval "$func() { $cmd; }"
typeset file=$(mktemp -t draft.XXXX)
typeset -f $func > $file
transcribe $func $file draft
rm $file 2>/dev/null
}
glossary ()
{
about displays help summary for all functions, or summary for a group of functions
param 1: optional, group name
example '$ glossary'
example '$ glossary misc'
group composure
typeset targetgroup=${1:-}
for func in $(typeset_functions); do
if [ -n "$targetgroup" ]; then
typeset group="$(typeset -f $func | metafor group)"
if [ "$group" != "$targetgroup" ]; then
continue # skip non-matching groups, if specified
fi
fi
typeset about="$(typeset -f $func | metafor about)"
letterpress "$about" $func
done
}
metafor ()
{
about prints function metadata associated with keyword
param 1: meta keyword
example '$ typeset -f glossary | metafor example'
group composure
typeset keyword=$1
if [ -z "$keyword" ]; then
printf '%s\n' 'missing parameter(s)'
reference metafor
return
fi
# this sed-fu is the retrieval half of the 'metadata' system:
# 'grep' for the metadata keyword, and then parse/filter the matching line
# grep keyword # strip trailing '|"|; # ignore thru keyword and leading '|"
sed -n "/$keyword / s/['\";]*$//;s/^[ ]*$keyword ['\"]*\([^([].*\)*$/\1/p"
}
reference ()
{
about displays apidoc help for a specific function
param 1: function name
example '$ reference revise'
group composure
typeset func=$1
if [ -z "$func" ]; then
printf '%s\n' 'missing parameter(s)'
reference reference
return
fi
typeset line
typeset about="$(typeset -f $func | metafor about)"
letterpress "$about" $func
typeset author="$(typeset -f $func | metafor author)"
if [ -n "$author" ]; then
letterpress "$author" 'author:'
fi
typeset version="$(typeset -f $func | metafor version)"
if [ -n "$version" ]; then
letterpress "$version" 'version:'
fi
if [ -n "$(typeset -f $func | metafor param)" ]; then
printf "parameters:\n"
typeset -f $func | metafor param | while read line
do
letterpress "$line"
done
fi
if [ -n "$(typeset -f $func | metafor example)" ]; then
printf "examples:\n"
typeset -f $func | metafor example | while read line
do
letterpress "$line"
done
fi
}
revise ()
{
about loads function into editor for revision
param 1: name of function
example '$ revise myfunction'
group composure
typeset func=$1
typeset temp=$(mktemp -t revise.XXXX)
if [ -z "$func" ]; then
printf '%s\n' 'missing parameter(s)'
reference revise
return
fi
# populate tempfile...
if [ -f ~/.composure/$func.inc ]; then
# ...with contents of latest git revision...
cat ~/.composure/$func.inc >> $temp
else
# ...or from ENV if not previously versioned
typeset -f $func >> $temp
fi
if [ -z "$EDITOR" ]
then
typeset EDITOR=vi
fi
$EDITOR $temp
. $temp # source edited file
transcribe $func $temp revise
rm $temp
}
write ()
{
about writes one or more composed function definitions to stdout
param one or more function names
example '$ write finddown foo'
example '$ write finddown'
group composure
if [ -z "$1" ]; then
printf '%s\n' 'missing parameter(s)'
reference write
return
fi
# bootstrap metadata
cat <<END
for f in $(composure_keywords)
do
eval "\$f() { :; }"
done
unset f
END
# include cite() to enable custom keywords
typeset -f cite $*
}
: <<EOF
License: The MIT License
Copyright © 2012 Erich Smith
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.
EOF

View File

@@ -37,6 +37,17 @@ function _binary_exists ()
type -P "$1" &> /dev/null || (_log_warning "$msg" && return 1) ; type -P "$1" &> /dev/null || (_log_warning "$msg" && return 1) ;
} }
function _completion_exists ()
{
_about 'checks for existence of a completion'
_param '1: command to check'
_param '2: (optional) log message to include when completion is found'
_example '$ _completion_exists gh && echo exists'
_group 'lib'
local msg="${2:-Completion for '$1' already exists!}"
complete -p "$1" &> /dev/null && _log_warning "$msg" ;
}
function _make_reload_alias() { function _make_reload_alias() {
echo "source \${BASH_IT}/scripts/reloader.bash ${1} ${2}" echo "source \${BASH_IT}/scripts/reloader.bash ${1} ${2}"
} }
@@ -192,7 +203,7 @@ _bash-it_pull_and_update_inner() {
_bash-it-migrate _bash-it-migrate
echo "" echo ""
echo "All done, enjoy!" echo "All done, enjoy!"
bash-it reload bash-it restart
else else
echo "Error updating Bash-it, please, check if your Bash-it installation folder (${BASH_IT}) is clean." echo "Error updating Bash-it, please, check if your Bash-it installation folder (${BASH_IT}) is clean."
fi fi
@@ -213,6 +224,9 @@ _bash-it-update-() {
cd "${BASH_IT}" || return cd "${BASH_IT}" || return
DIFF=$(git diff --name-status)
[ -n "$DIFF" ] && echo -e "Local changes detected in bash-it directory. Clean '$BASH_IT' directory to proceed.\n$DIFF" && return 1
if [ -z "$BASH_IT_REMOTE" ]; then if [ -z "$BASH_IT_REMOTE" ]; then
BASH_IT_REMOTE="origin" BASH_IT_REMOTE="origin"
fi fi
@@ -731,14 +745,14 @@ _help-plugins()
printf '%s' 'please wait, building help...' printf '%s' 'please wait, building help...'
typeset grouplist=$(mktemp -t grouplist.XXXXXX) typeset grouplist=$(mktemp -t grouplist.XXXXXX)
typeset func typeset func
for func in $(typeset_functions) for func in $(_typeset_functions)
do do
typeset group="$(typeset -f $func | metafor group)" typeset group="$(typeset -f $func | metafor group)"
if [ -z "$group" ]; then if [ -z "$group" ]; then
group='misc' group='misc'
fi fi
typeset about="$(typeset -f $func | metafor about)" typeset about="$(typeset -f $func | metafor about)"
letterpress "$about" $func >> $grouplist.$group _letterpress "$about" $func >> $grouplist.$group
echo $grouplist.$group >> $grouplist echo $grouplist.$group >> $grouplist
done done
# clear progress message # clear progress message
@@ -777,7 +791,7 @@ all_groups ()
typeset func typeset func
typeset file=$(mktemp -t composure.XXXX) typeset file=$(mktemp -t composure.XXXX)
for func in $(typeset_functions) for func in $(_typeset_functions)
do do
typeset -f $func | metafor group >> $file typeset -f $func | metafor group >> $file
done done

View File

@@ -1,12 +0,0 @@
#!/usr/bin/env bash
# Bash History Handling
shopt -s histappend # append to bash_history if Terminal.app quits
export HISTCONTROL=${HISTCONTROL:-ignorespace:erasedups} # erase duplicates; alternative option: export HISTCONTROL=ignoredups
export HISTSIZE=${HISTSIZE:-5000} # resize history size
export AUTOFEATURE=${AUTOFEATURE:-true autotest} # Cucumber / Autotest integration
function rh {
history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
}

View File

@@ -1,199 +0,0 @@
#!/usr/bin/env bash
# http://www.twistedmatrix.com/users/glyph/preexec.bash.txt
# preexec.bash -- Bash support for ZSH-like 'preexec' and 'precmd' functions.
# The 'preexec' function is executed before each interactive command is
# executed, with the interactive command as its argument. The 'precmd'
# function is executed before each prompt is displayed.
# To use, in order:
# 1. source this file
# 2. define 'preexec' and/or 'precmd' functions (AFTER sourcing this file),
# 3. as near as possible to the end of your shell setup, run 'preexec_install'
# to kick everything off.
# Note: this module requires 2 bash features which you must not otherwise be
# using: the "DEBUG" trap, and the "PROMPT_COMMAND" variable. preexec_install
# will override these and if you override one or the other this _will_ break.
# This is known to support bash3, as well as *mostly* support bash2.05b. It
# has been tested with the default shells on MacOS X 10.4 "Tiger", Ubuntu 5.10
# "Breezy Badger", Ubuntu 6.06 "Dapper Drake", and Ubuntu 6.10 "Edgy Eft".
# Copy screen-run variables from the remote host, if they're available.
if [[ "$SCREEN_RUN_HOST" == "" ]]
then
SCREEN_RUN_HOST="$LC_SCREEN_RUN_HOST"
SCREEN_RUN_USER="$LC_SCREEN_RUN_USER"
fi
# This variable describes whether we are currently in "interactive mode";
# i.e. whether this shell has just executed a prompt and is waiting for user
# input. It documents whether the current command invoked by the trace hook is
# run interactively by the user; it's set immediately after the prompt hook,
# and unset as soon as the trace hook is run.
preexec_interactive_mode=""
# Default do-nothing implementation of preexec.
function preexec () {
true
}
# Default do-nothing implementation of precmd.
function precmd () {
true
}
# This function is installed as the PROMPT_COMMAND; it is invoked before each
# interactive prompt display. It sets a variable to indicate that the prompt
# was just displayed, to allow the DEBUG trap, below, to know that the next
# command is likely interactive.
function preexec_invoke_cmd () {
precmd
preexec_interactive_mode="yes"
}
# This function is installed as the DEBUG trap. It is invoked before each
# interactive prompt display. Its purpose is to inspect the current
# environment to attempt to detect if the current command is being invoked
# interactively, and invoke 'preexec' if so.
function preexec_invoke_exec () {
if [[ -n "$COMP_LINE" ]]
then
# We're in the middle of a completer. This obviously can't be
# an interactively issued command.
return
fi
if [[ -z "$preexec_interactive_mode" ]]
then
# We're doing something related to displaying the prompt. Let the
# prompt set the title instead of me.
return
else
# If we're in a subshell, then the prompt won't be re-displayed to put
# us back into interactive mode, so let's not set the variable back.
# In other words, if you have a subshell like
# (sleep 1; sleep 2)
# You want to see the 'sleep 2' as a set_command_title as well.
if [[ 0 -eq "$BASH_SUBSHELL" ]]
then
preexec_interactive_mode=""
fi
fi
if [[ "preexec_invoke_cmd" == "$BASH_COMMAND" ]]
then
# Sadly, there's no cleaner way to detect two prompts being displayed
# one after another. This makes it important that PROMPT_COMMAND
# remain set _exactly_ as below in preexec_install. Let's switch back
# out of interactive mode and not trace any of the commands run in
# precmd.
# Given their buggy interaction between BASH_COMMAND and debug traps,
# versions of bash prior to 3.1 can't detect this at all.
preexec_interactive_mode=""
return
fi
# In more recent versions of bash, this could be set via the "BASH_COMMAND"
# variable, but using history here is better in some ways: for example, "ps
# auxf | less" will show up with both sides of the pipe if we use history,
# but only as "ps auxf" if not.
local this_command=`history 1 | sed -e "s/^[ ]*[0-9]*[ ]*//g"`;
# If none of the previous checks have earlied out of this function, then
# the command is in fact interactive and we should invoke the user's
# preexec hook with the running command as an argument.
preexec "$this_command"
}
# Execute this to set up preexec and precmd execution.
function preexec_install () {
# *BOTH* of these options need to be set for the DEBUG trap to be invoked
# in ( ) subshells. This smells like a bug in bash to me. The null stderr
# redirections are to quiet errors on bash2.05 (i.e. OSX's default shell)
# where the options can't be set, and it's impossible to inherit the trap
# into subshells.
set -o functrace > /dev/null 2>&1
shopt -s extdebug > /dev/null 2>&1
# Finally, install the actual traps.
if [[ ! -z "${PROMPT_COMMAND// }" ]]; then
PROMPT_COMMAND="${PROMPT_COMMAND}"$'\n'"preexec_invoke_cmd"
else
PROMPT_COMMAND="preexec_invoke_cmd"
fi
trap 'preexec_invoke_exec' DEBUG
}
# Since this is the reason that 99% of everybody is going to bother with a
# pre-exec hook anyway, we'll include it in this module.
# Change the title of the xterm.
function preexec_xterm_title () {
local title="$1"
echo -ne "\033]0;$title\007" > /dev/stderr
}
function preexec_screen_title () {
local title="$1"
echo -ne "\033k$1\033\\" > /dev/stderr
}
# Abbreviate the "user@host" string as much as possible to preserve space in
# screen titles. Elide the host if the host is the same, elide the user if the
# user is the same.
function preexec_screen_user_at_host () {
local RESULT=""
if [[ "$SCREEN_RUN_HOST" == "$SCREEN_HOST" ]]
then
return
else
if [[ "$SCREEN_RUN_USER" == "$USER" ]]
then
echo -n "@${SCREEN_HOST}"
else
echo -n "${USER}@${SCREEN_HOST}"
fi
fi
}
function preexec_xterm_title_install () {
# These functions are defined here because they only make sense with the
# preexec_install below.
function precmd () {
preexec_xterm_title "${TERM} - ${USER}@${SCREEN_HOST} `dirs -0` $PROMPTCHAR"
if [[ "${TERM}" == screen ]]
then
preexec_screen_title "`preexec_screen_user_at_host`${PROMPTCHAR}"
fi
}
function preexec () {
preexec_xterm_title "${TERM} - $1 {`dirs -0`} (${USER}@${SCREEN_HOST})"
if [[ "${TERM}" == screen ]]
then
local cutit="$1"
local cmdtitle=`echo "$cutit" | cut -d " " -f 1`
if [[ "$cmdtitle" == "exec" ]]
then
local cmdtitle=`echo "$cutit" | cut -d " " -f 2`
fi
if [[ "$cmdtitle" == "screen" ]]
then
# Since stacked screens are quite common, it would be nice to
# just display them as '$$'.
local cmdtitle="${PROMPTCHAR}"
else
local cmdtitle=":$cmdtitle"
fi
preexec_screen_title "`preexec_screen_user_at_host`${PROMPTCHAR}$cmdtitle"
fi
}
preexec_install
}

View File

@@ -1,3 +1,4 @@
# shellcheck shell=bash
# Load after the other completions to understand what needs to be completed # Load after the other completions to understand what needs to be completed
# BASH_IT_LOAD_PRIORITY: 365 # BASH_IT_LOAD_PRIORITY: 365
@@ -29,12 +30,18 @@ function alias_completion {
((${#completions[@]} == 0)) && return 0 ((${#completions[@]} == 0)) && return 0
# create temporary file for wrapper functions and completions # create temporary file for wrapper functions and completions
local tmp_file; tmp_file="$(mktemp -t "${namespace}-${RANDOM}XXXXXX")" || return 1 local tmp_file
tmp_file="$(mktemp -t "${namespace}-${RANDOM}XXXXXX")" || return 1
local completion_loader; completion_loader="$(complete -p -D 2>/dev/null | sed -Ene 's/.* -F ([^ ]*).*/\1/p')" local completion_loader
completion_loader="$(complete -p -D 2> /dev/null | sed -Ene 's/.* -F ([^ ]*).*/\1/p')"
# read in "<alias> '<aliased command>' '<command args>'" lines from defined aliases # read in "<alias> '<aliased command>' '<command args>'" lines from defined aliases
local line; while read line; do local line
# shellcheck disable=SC2162
# some aliases do have backslashes that needs to be interpreted
while read line; do
eval "local alias_tokens; alias_tokens=($line)" 2> /dev/null || continue # some alias arg patterns cause an eval parse error eval "local alias_tokens; alias_tokens=($line)" 2> /dev/null || continue # some alias arg patterns cause an eval parse error
local alias_name="${alias_tokens[0]}" alias_cmd="${alias_tokens[1]}" alias_args="${alias_tokens[2]# }" local alias_name="${alias_tokens[0]}" alias_cmd="${alias_tokens[1]}" alias_args="${alias_tokens[2]# }"
@@ -45,13 +52,13 @@ function alias_completion {
read -a alias_arg_words <<< "$alias_args" read -a alias_arg_words <<< "$alias_args"
# skip alias if there is no completion function triggered by the aliased command # skip alias if there is no completion function triggered by the aliased command
if [[ ! " ${completions[*]} " =~ " $alias_cmd " ]]; then if ! _bash-it-array-contains-element "$alias_cmd" "${completions[@]}"; then
if [[ -n "$completion_loader" ]]; then if [[ -n "$completion_loader" ]]; then
# force loading of completions for the aliased command # force loading of completions for the aliased command
eval "$completion_loader $alias_cmd" eval "$completion_loader $alias_cmd"
# 124 means completion loader was successful # 124 means completion loader was successful
[[ $? -eq 124 ]] || continue [[ $? -eq 124 ]] || continue
completions+=($alias_cmd) completions+=("$alias_cmd")
else else
continue continue
fi fi
@@ -60,9 +67,10 @@ function alias_completion {
# create a wrapper inserting the alias arguments if any # create a wrapper inserting the alias arguments if any
if [[ -n $alias_args ]]; then if [[ -n $alias_args ]]; then
local compl_func="${new_completion/#* -F /}"; compl_func="${compl_func%% *}" local compl_func="${new_completion/#* -F /}"
compl_func="${compl_func%% *}"
# avoid recursive call loops by ignoring our own functions # avoid recursive call loops by ignoring our own functions
if [[ "${compl_func#_$namespace::}" == $compl_func ]]; then if [[ "${compl_func#_$namespace::}" == "$compl_func" ]]; then
local compl_wrapper="_${namespace}::${alias_name}" local compl_wrapper="_${namespace}::${alias_name}"
echo "function $compl_wrapper { echo "function $compl_wrapper {
local compl_word=\$2 local compl_word=\$2
@@ -91,5 +99,8 @@ 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")
# shellcheck source=/dev/null
source "$tmp_file" && command rm -f "$tmp_file" source "$tmp_file" && command rm -f "$tmp_file"
}; alias_completion }
alias_completion

View File

@@ -0,0 +1,16 @@
# shellcheck shell=bash
cite about-plugin
about-plugin 'initializes basher, the shell package manager'
# https://github.com/basherpm/basher
if ! _command_exists basher; then
if [[ -x "$HOME/.basher/bin/basher" ]]; then
pathmunge "$HOME/.basher/bin"
else
_log_warning 'basher not found'
return 0
fi
fi
eval "$(basher init - bash)"

View File

@@ -0,0 +1,16 @@
# shellcheck shell=bash
cite about-plugin
about-plugin 'Alert (BEL) when process ends after a threshold of seconds'
precmd_return_notification() {
export LAST_COMMAND_DURATION=$(($(date +%s) - ${LAST_COMMAND_TIME:=$(date +%s)}))
[[ ${LAST_COMMAND_DURATION} -gt ${NOTIFY_IF_COMMAND_RETURNS_AFTER:-5} ]] && echo -e "\a"
export LAST_COMMAND_TIME=
}
preexec_return_notification() {
[ -z "${LAST_COMMAND_TIME}" ] && export LAST_COMMAND_TIME=$(date +%s)
}
precmd_functions+=(precmd_return_notification)
preexec_functions+=(preexec_return_notification)

View File

@@ -1,13 +1,5 @@
# shellcheck shell=bash
cite about-plugin cite about-plugin
about-plugin 'Helpers to get Docker setup correctly for docker-machine' about-plugin 'Helpers to get Docker setup correctly for docker-machine'
_log_warning '"docker-machine" is now deprecated, and as such the plugin for it is also deprecated.
[ -z ${BASH_IT_DOCKER_MACHINE+x} ] && BASH_IT_DOCKER_MACHINE='dev' Please disable this plugin.'
# Note, this might need to be different if you use a machine other than 'dev'
if [[ `uname -s` == "Darwin" ]]; then
# check if dev machine is running
docker-machine ls | grep --quiet "$BASH_IT_DOCKER_MACHINE.*Running"
if [[ "$?" = "0" ]]; then
eval "$(docker-machine env $BASH_IT_DOCKER_MACHINE)"
fi
fi

View File

@@ -37,7 +37,7 @@ End-Of-Usage
local -r filename=$(basename -- $1) local -r filename=$(basename -- $1)
local -r filedirname=$(dirname -- $1) local -r filedirname=$(dirname -- $1)
local targetdirname=$(sed 's/\(\.tar\.bz2$\|\.tbz$\|\.tbz2$\|\.tar\.gz$\|\.tgz$\|\.tar$\|\.tar\.xz$\|\.txz$\|\.tar\.Z$\|\.7z$\)//g' <<< $filename) local targetdirname=$(sed 's/\(\.tar\.bz2$\|\.tbz$\|\.tbz2$\|\.tar\.gz$\|\.tgz$\|\.tar$\|\.tar\.xz$\|\.txz$\|\.tar\.Z$\|\.7z$\|\.nupkg$\|\.zip$\|\.war$\|\.jar$\)//g' <<< $filename)
if [ "$filename" = "$targetdirname" ]; then if [ "$filename" = "$targetdirname" ]; then
# archive type either not supported or it doesn't need dir creation # archive type either not supported or it doesn't need dir creation
targetdirname="" targetdirname=""
@@ -61,9 +61,9 @@ End-Of-Usage
*.rpm) rpm2cpio "$1" | cpio -idm${verbose} ;; *.rpm) rpm2cpio "$1" | cpio -idm${verbose} ;;
*.tar) tar "x${verbose}f" "$1" -C "$filedirname/$targetdirname" ;; *.tar) tar "x${verbose}f" "$1" -C "$filedirname/$targetdirname" ;;
*.xz) xz --decompress "$1" ;; *.xz) xz --decompress "$1" ;;
*.zip|*.war|*.jar) unzip "$1" ;; *.zip|*.war|*.jar|*.nupkg) unzip "$1" -d "$filedirname/$targetdirname" ;;
*.Z) uncompress "$1" ;; *.Z) uncompress "$1" ;;
*.7z) 7za x "$1" ;; *.7z) 7za x -o"$filedirname/$targetdirname" "$1" ;;
*) echo "'$1' cannot be extracted via extract" >&2;; *) echo "'$1' cannot be extracted via extract" >&2;;
esac esac
fi fi

View File

@@ -1,12 +1,13 @@
# shellcheck shell=bash
cite about-plugin cite about-plugin
about-plugin 'git helper functions' about-plugin 'git helper functions'
function git_remote { function git_remote {
about 'adds remote $GIT_HOSTING:$1 to current repo' about "adds remote $GIT_HOSTING:$1 to current repo"
group 'git' group "git"
echo "Running: git remote add origin ${GIT_HOSTING}:$1.git" echo "Running: git remote add origin ${GIT_HOSTING}:$1.git"
git remote add origin $GIT_HOSTING:$1.git git remote add origin "$GIT_HOSTING:$1".git
} }
function git_first_push { function git_first_push {
@@ -23,15 +24,15 @@ function git_pub() {
BRANCH=$(git rev-parse --abbrev-ref HEAD) BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "Publishing ${BRANCH} to remote origin" echo "Publishing ${BRANCH} to remote origin"
git push -u origin $BRANCH git push -u origin "$BRANCH"
} }
function git_revert() { function git_revert() {
about 'applies changes to HEAD that revert all changes after this commit' about 'applies changes to HEAD that revert all changes after this commit'
group 'git' group 'git'
git reset $1 git reset "$1"
git reset --soft HEAD@{1} git reset --soft "HEAD@{1}"
git commit -m "Revert to ${1}" git commit -m "Revert to ${1}"
git reset --hard git reset --hard
} }
@@ -48,7 +49,7 @@ function git_rollback() {
} }
function commit_exists() { function commit_exists() {
git rev-list --quiet $1 git rev-list --quiet "$1"
status=$? status=$?
if [ $status -ne 0 ]; then if [ $status -ne 0 ]; then
echo "Commit ${1} does not exist" echo "Commit ${1} does not exist"
@@ -57,38 +58,39 @@ function git_rollback() {
} }
function keep_changes() { function keep_changes() {
while true while true; do
do # shellcheck disable=SC2162
read -p "Do you want to keep all changes from rolled back revisions in your working tree? [Y/N]" RESP read -p "Do you want to keep all changes from rolled back revisions in your working tree? [Y/N]" RESP
case $RESP case $RESP in
in
[yY]) [yY])
echo "Rolling back to commit ${1} with unstaged changes" echo "Rolling back to commit ${1} with unstaged changes"
git reset $1 git reset "$1"
break break
;; ;;
[nN]) [nN])
echo "Rolling back to commit ${1} with a clean working tree" echo "Rolling back to commit ${1} with a clean working tree"
git reset --hard $1 git reset --hard "$1"
break break
;; ;;
*) *)
echo "Please enter Y or N" echo "Please enter Y or N"
;;
esac esac
done done
} }
if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]; then if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]; then
is_clean is_clean
commit_exists $1 commit_exists "$1"
while true while true; do
do # shellcheck disable=SC2162
read -p "WARNING: This will change your history and move the current HEAD back to commit ${1}, continue? [Y/N]" RESP read -p "WARNING: This will change your history and move the current HEAD back to commit ${1}, continue? [Y/N]" RESP
case $RESP case $RESP in
in
[yY]) [yY])
keep_changes $1 keep_changes "$1"
break break
;; ;;
[nN]) [nN])
@@ -96,6 +98,7 @@ function git_rollback() {
;; ;;
*) *)
echo "Please enter Y or N" echo "Please enter Y or N"
;;
esac esac
done done
else else
@@ -131,8 +134,8 @@ function git_info() {
# print all remotes and thier details # print all remotes and thier details
for remote in $(git remote show); do for remote in $(git remote show); do
echo $remote: echo "$remote":
git remote show $remote git remote show "$remote"
echo echo
done done
@@ -180,18 +183,21 @@ if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]; then
LOGOPTS="$LOGOPTS -C --find-copies-harder" LOGOPTS="$LOGOPTS -C --find-copies-harder"
shift shift
fi fi
for a in $AUTHORS for a in $AUTHORS; do
do
echo '-------------------' echo '-------------------'
echo "Statistics for: $a" echo "Statistics for: $a"
echo -n "Number of files changed: " echo -n "Number of files changed: "
git log $LOGOPTS --all --numstat --format="%n" --author=$a | cut -f3 | sort -iu | wc -l # shellcheck disable=SC2086
git log $LOGOPTS --all --numstat --format="%n" --author="$a" | cut -f3 | sort -iu | wc -l
echo -n "Number of lines added: " echo -n "Number of lines added: "
git log $LOGOPTS --all --numstat --format="%n" --author=$a | cut -f1 | awk '{s+=$1} END {print s}' # shellcheck disable=SC2086
git log $LOGOPTS --all --numstat --format="%n" --author="$a" | cut -f1 | awk '{s+=$1} END {print s}'
echo -n "Number of lines deleted: " echo -n "Number of lines deleted: "
git log $LOGOPTS --all --numstat --format="%n" --author=$a | cut -f2 | awk '{s+=$1} END {print s}' # shellcheck disable=SC2086
git log $LOGOPTS --all --numstat --format="%n" --author="$a" | cut -f2 | awk '{s+=$1} END {print s}'
echo -n "Number of merges: " echo -n "Number of merges: "
git log $LOGOPTS --all --merges --author=$a | grep -c '^commit' # shellcheck disable=SC2086
git log $LOGOPTS --all --merges --author="$a" | grep -c '^commit'
done done
else else
echo "you're currently not in a git repository" echo "you're currently not in a git repository"
@@ -212,7 +218,7 @@ function gittowork() {
echo "$result" echo "$result"
else else
if [[ -f .gitignore ]]; then if [[ -f .gitignore ]]; then
result=`echo "$result" | grep -v "# Created by http://www.gitignore.io"` result=$(echo "$result" | grep -v "# Created by http://www.gitignore.io")
echo ".gitignore already exists, appending..." echo ".gitignore already exists, appending..."
echo "$result" >> .gitignore echo "$result" >> .gitignore
else else
@@ -237,24 +243,21 @@ function gitignore-reload() {
err=0 err=0
# Disallow unstaged changes in the working tree # Disallow unstaged changes in the working tree
if ! git diff-files --quiet --ignore-submodules -- if ! git diff-files --quiet --ignore-submodules --; then
then
echo >&2 "ERROR: Cannot reload .gitignore: Your index contains unstaged changes." echo >&2 "ERROR: Cannot reload .gitignore: Your index contains unstaged changes."
git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2 git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2
err=1 err=1
fi fi
# Disallow uncommited changes in the index # Disallow uncommited changes in the index
if ! git diff-index --cached --quiet HEAD --ignore-submodules if ! git diff-index --cached --quiet HEAD --ignore-submodules; then
then
echo >&2 "ERROR: Cannot reload .gitignore: Your index contains uncommited changes." echo >&2 "ERROR: Cannot reload .gitignore: Your index contains uncommited changes."
git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2 git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2
err=1 err=1
fi fi
# Prompt user to commit or stash changes and exit # Prompt user to commit or stash changes and exit
if [ $err = 1 ] if [ $err = 1 ]; then
then
echo >&2 "Please commit or stash them." echo >&2 "Please commit or stash them."
fi fi
@@ -273,3 +276,42 @@ function gitignore-reload() {
echo >&2 "Files readded. Commit your new changes now." echo >&2 "Files readded. Commit your new changes now."
fi fi
} }
function git-changelog() {
# ---------------------------------------------------------------
# ORIGINAL ANSWER: https://stackoverflow.com/a/2979587/10362396 |
# ---------------------------------------------------------------
about 'Creates the git changelog from one point to another by date'
group 'git'
example '$ git-changelog origin/master...origin/release [md|txt]'
if [[ "$1" != *"..."* ]]; then
echo "Please include the valid 'diff' to make changelog"
return 1
fi
local NEXT=$(date +%F)
if [[ "$2" == "md" ]]; then
echo "# CHANGELOG $1"
# shellcheck disable=SC2162
git log "$1" --no-merges --format="%cd" --date=short | sort -u -r | while read DATE; do
echo
echo "### $DATE"
git log --no-merges --format=" * (%h) %s by [%an](mailto:%ae)" --since="$DATE 00:00:00" --until="$DATE 24:00:00"
NEXT=$DATE
done
else
echo "CHANGELOG $1"
echo ----------------------
# shellcheck disable=SC2162
git log "$1" --no-merges --format="%cd" --date=short | sort -u -r | while read DATE; do
echo
echo [$DATE]
git log --no-merges --format=" * (%h) %s by %an <%ae>" --since="$DATE 00:00:00" --until="$DATE 24:00:00"
NEXT=$DATE
done
fi
}

41
plugins/available/go.plugin.bash Executable file → Normal file
View File

@@ -1,19 +1,36 @@
#!/usr/bin/env bash # shellcheck shell=bash
cite about-plugin cite about-plugin
about-plugin 'go environment variables & path configuration' about-plugin 'go environment variables & path configuration'
command -v go &>/dev/null || return # Load after basher and goenv
# BASH_IT_LOAD_PRIORITY: 270
function _go_pathmunge_wrap() { # Test `go version` because goenv creates shim scripts that will be found in PATH
IFS=':' local -a 'a=($1)' # but do not always resolve to a working install.
local i=${#a[@]} { _command_exists go && go version &> /dev/null; } || return 0
while [ $i -gt 0 ] ; do
i=$(( i - 1 ))
pathmunge "${a[i]}/bin"
done
}
export GOROOT="${GOROOT:-$(go env GOROOT)}" export GOROOT="${GOROOT:-$(go env GOROOT)}"
export GOPATH="${GOPATH:-$(go env GOPATH)}" export GOPATH="${GOPATH:-$(go env GOPATH)}"
_go_pathmunge_wrap "${GOPATH}:${GOROOT}"
# $GOPATH/bin is the default location for binaries. Because GOPATH accepts a list of paths and each
# might be managed differently, we add each path's /bin folder to PATH using pathmunge,
# while preserving ordering.
# e.g. GOPATH=foo:bar -> PATH=foo/bin:bar/bin
_bash-it-gopath-pathmunge() {
_about 'Ensures paths in GOPATH are added to PATH using pathmunge, with /bin appended'
_group 'go'
if [[ -z $GOPATH ]]; then
echo 'GOPATH empty' >&2
return 1
fi
local paths i
IFS=: read -r -a paths <<< "$GOPATH"
i=${#paths[@]}
while [[ $i -gt 0 ]]; do
i=$((i - 1))
if [[ -n "${paths[i]}" ]]; then
pathmunge "${paths[i]}/bin"
fi
done
}
_bash-it-gopath-pathmunge

View File

@@ -1,20 +1,42 @@
# shellcheck shell=bash
cite about-plugin cite about-plugin
about-plugin 'load goenv, if you are using it' about-plugin 'load goenv, if you are using it'
# https://github.com/syndbg/goenv
# Load after basher
# BASH_IT_LOAD_PRIORITY: 260
# Don't modify the environment if we can't find the tool: # Don't modify the environment if we can't find the tool:
# - Check if in $PATH already # - Check if in $PATH already
# - Check if installed manually to $GOENV_ROOT # - Check if installed manually to $GOENV_ROOT
# - Check if installed manually to $HOME # - Check if installed manually to $HOME
_command_exists goenv || _command_exists goenv \
[[ -n "$GOENV_ROOT" && -x "$GOENV_ROOT/bin/goenv" ]] || || [[ -n "$GOENV_ROOT" && -x "$GOENV_ROOT/bin/goenv" ]] \
[[ -x "$HOME/.goenv/bin/goenv" ]] || || [[ -x "$HOME/.goenv/bin/goenv" ]] \
return || return 0
# Set GOENV_ROOT, if not already set # Set GOENV_ROOT, if not already set
export GOENV_ROOT="${GOENV_ROOT:-$HOME/.goenv}" export GOENV_ROOT="${GOENV_ROOT:-$HOME/.goenv}"
# Add GOENV_ROOT/bin to PATH, if that's where it's installed # Add GOENV_ROOT/bin to PATH, if that's where it's installed
! _command_exists goenv && [[ -x "$GOENV_ROOT/bin/goenv" ]] && pathmunge "$GOENV_ROOT/bin" if ! _command_exists goenv && [[ -x "$GOENV_ROOT/bin/goenv" ]]; then
pathmunge "$GOENV_ROOT/bin"
fi
# Initialize goenv # Initialize goenv
eval "$(goenv init - bash)" eval "$(goenv init - bash)"
# If moving to a directory with a goenv version set, reload the shell
# to ensure the shell environment matches expectations.
_bash-it-goenv-preexec() {
export GOENV_OLD_VERSION="$(goenv version-name)"
}
_bash-it-goenv-precmd() {
if [[ -n $GOENV_OLD_VERSION ]] && [[ "$GOENV_OLD_VERSION" != "$(goenv version-name)" ]]; then
exec env -u PATH -u GOROOT -u GOPATH -u GOENV_OLD_VERSION "${0/-/}" --login
fi
unset GOENV_OLD_VERSION
}
preexec_functions+=(_bash-it-goenv-preexec)
precmd_functions+=(_bash-it-goenv-precmd)

View File

@@ -0,0 +1,10 @@
# shellcheck shell=bash
cite about-plugin
about-plugin 'search history using the prefix already entered'
# enter a few characters and press UpArrow/DownArrow
# to search backwards/forwards through the history
if [[ ${SHELLOPTS} =~ (vi|emacs) ]]; then
bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'
fi

View File

@@ -0,0 +1,10 @@
# shellcheck shell=bash
cite about-plugin
about-plugin 'search history using the substring already entered'
# enter a few characters and press UpArrow/DownArrow
# to search backwards/forwards through the history
if [[ ${SHELLOPTS} =~ (vi|emacs) ]]; then
bind '"\e[A":history-substring-search-backward'
bind '"\e[B":history-substring-search-forward'
fi

View File

@@ -1,9 +1,39 @@
# shellcheck shell=bash
cite about-plugin cite about-plugin
about-plugin 'history manipulation' about-plugin 'improve history handling with sane defaults'
# enter a few characters and press UpArrow/DownArrow
# to search backwards/forwards through the history # append to bash_history if Terminal.app quits
if [[ ${SHELLOPTS} =~ (vi|emacs) ]] shopt -s histappend
then
bind '"":history-search-backward' # erase duplicates; alternative option: export HISTCONTROL=ignoredups
bind '"":history-search-forward' export HISTCONTROL=${HISTCONTROL:-ignorespace:erasedups}
# resize history to 100x the default (500)
export HISTSIZE=${HISTSIZE:-50000}
top-history() {
about 'print the name and count of the most commonly run tools'
if [[ -n $HISTTIMEFORMAT ]]; then
# To parse history we need a predictable format, which HISTTIMEFORMAT
# gets in the way of. So we unset it and set a trap to guarantee the
# user's environment returns to normal even if the pipeline below fails.
# shellcheck disable=SC2064
trap "export HISTTIMEFORMAT='$HISTTIMEFORMAT'" RETURN
unset HISTTIMEFORMAT
fi fi
history \
| awk '{
a[$2]++
}END{
for(i in a)
printf("%s\t%s\n", a[i], i)
}' \
| sort --reverse --numeric-sort \
| head \
| column \
--table \
--table-columns 'Command Count,Command Name' \
--output-separator ' | '
}

View File

@@ -1,15 +1,15 @@
# shellcheck shell=bash
cite about-plugin cite about-plugin
about-plugin 'automatically set your xterm title with host and location info' about-plugin 'automatically set your xterm title with host and location info'
_short-dirname() { _short-dirname() {
local dir_name=`dirs +0` local dir_name=$(dirs +0)
[ "$SHORT_TERM_LINE" = true ] && [ ${#dir_name} -gt 8 ] && echo ${dir_name##*/} || echo $dir_name [ "$SHORT_TERM_LINE" = true ] && [ "${#dir_name}" -gt 8 ] && echo "${dir_name##*/}" || echo "${dir_name}"
} }
_short-command() { _short-command() {
local input_command="$@" local input_command="$*"
[ "$SHORT_TERM_LINE" = true ] && [ ${#input_command} -gt 8 ] && echo ${input_command%% *} || echo $input_command [ "$SHORT_TERM_LINE" = true ] && [ "${#input_command}" -gt 8 ] && echo "${input_command%% *}" || echo "${input_command}"
} }
set_xterm_title() { set_xterm_title() {
@@ -17,14 +17,17 @@ set_xterm_title () {
echo -ne "\033]0;$title\007" echo -ne "\033]0;$title\007"
} }
precmd () { precmd_xterm_title() {
set_xterm_title "${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}} `_short-dirname` $PROMPTCHAR" set_xterm_title "${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}} $(_short-dirname) $PROMPT_CHAR"
} }
preexec () { preexec_xterm_title() {
set_xterm_title "`_short-command $1` {`_short-dirname`} (${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}})" set_xterm_title "$(_short-command "${1}") {$(_short-dirname)} (${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}})"
} }
case "$TERM" in case "$TERM" in
xterm*|rxvt*) preexec_install;; xterm* | rxvt*)
precmd_functions+=(precmd_xterm_title)
preexec_functions+=(preexec_xterm_title)
;;
esac esac

View File

@@ -1,6 +1,5 @@
#!/bin/bash #!/bin/bash
BASH_IT_LOG_PREFIX="core: reloader: " BASH_IT_LOG_PREFIX="core: reloader: "
pushd "${BASH_IT}" >/dev/null || exit 1
function _set-prefix-based-on-path() function _set-prefix-based-on-path()
{ {
@@ -9,7 +8,7 @@ function _set-prefix-based-on-path()
BASH_IT_LOG_PREFIX="$extension: $filename: " BASH_IT_LOG_PREFIX="$extension: $filename: "
} }
if [ "$1" != "skip" ] && [ -d "./enabled" ]; then if [[ "$1" != "skip" ]] && [[ -d "$BASH_IT/enabled" ]]; then
_bash_it_config_type="" _bash_it_config_type=""
case $1 in case $1 in
@@ -20,7 +19,7 @@ if [ "$1" != "skip" ] && [ -d "./enabled" ]; then
_log_debug "Loading all enabled components..." ;; _log_debug "Loading all enabled components..." ;;
esac esac
for _bash_it_config_file in $(sort <(compgen -G "./enabled/*${_bash_it_config_type}.bash")); do for _bash_it_config_file in $(sort <(compgen -G "$BASH_IT/enabled/*${_bash_it_config_type}.bash")); do
if [ -e "${_bash_it_config_file}" ]; then if [ -e "${_bash_it_config_file}" ]; then
_set-prefix-based-on-path "${_bash_it_config_file}" _set-prefix-based-on-path "${_bash_it_config_file}"
_log_debug "Loading component..." _log_debug "Loading component..."
@@ -32,12 +31,12 @@ if [ "$1" != "skip" ] && [ -d "./enabled" ]; then
done done
fi fi
if [ -n "${2}" ] && [ -d "${2}/enabled" ]; then if [[ -n "${2}" ]] && [[ -d "$BASH_IT/${2}/enabled" ]]; then
case $2 in case $2 in
aliases|completion|plugins) aliases|completion|plugins)
_log_warning "Using legacy enabling for $2, please update your bash-it version and migrate" _log_warning "Using legacy enabling for $2, please update your bash-it version and migrate"
for _bash_it_config_file in $(sort <(compgen -G "./${2}/enabled/*.bash")); do for _bash_it_config_file in $(sort <(compgen -G "$BASH_IT/${2}/enabled/*.bash")); do
if [ -e "$_bash_it_config_file" ]; then if [[ -e "$_bash_it_config_file" ]]; then
_set-prefix-based-on-path "${_bash_it_config_file}" _set-prefix-based-on-path "${_bash_it_config_file}"
_log_debug "Loading component..." _log_debug "Loading component..."
# shellcheck source=/dev/null # shellcheck source=/dev/null
@@ -51,4 +50,3 @@ fi
unset _bash_it_config_file unset _bash_it_config_file
unset _bash_it_config_type unset _bash_it_config_type
popd >/dev/null || exit 1

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bats #!/usr/bin/env bats
load ../test_helper load ../test_helper
load ../../lib/composure load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
function local_setup { function local_setup {
setup_test_fixture setup_test_fixture

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bats #!/usr/bin/env bats
load ../test_helper load ../test_helper
load ../../lib/composure load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
load ../../completion/available/bash-it.completion load ../../completion/available/bash-it.completion
function local_setup { function local_setup {

0
test/fixtures/plugin/xterm/files/arg0 vendored Normal file
View File

0
test/fixtures/plugin/xterm/files/arg1 vendored Normal file
View File

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bats #!/usr/bin/env bats
load ../test_helper load ../test_helper
load ../../lib/composure load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
# Determine which config file to use based on OS. # Determine which config file to use based on OS.
case $OSTYPE in case $OSTYPE in

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bats #!/usr/bin/env bats
load ../test_helper load ../test_helper
load ../../lib/composure load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
# Determine which config file to use based on OS. # Determine which config file to use based on OS.
case $OSTYPE in case $OSTYPE in

View File

@@ -1,9 +1,9 @@
#!/usr/bin/env bats #!/usr/bin/env bats
load ../test_helper load ../test_helper
load ../../lib/composure load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
@test "lib composure: composure_keywords()" { @test "lib composure: _composure_keywords()" {
run composure_keywords run _composure_keywords
assert_output "about author example group param version" assert_output "about author example group param version"
} }

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bats #!/usr/bin/env bats
load ../test_helper load ../test_helper
load ../../lib/composure load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
load ../../lib/log load ../../lib/log
load ../../lib/utilities load ../../lib/utilities
load ../../lib/search load ../../lib/search
@@ -69,6 +69,11 @@ function local_setup {
assert_line -n 0 "" assert_line -n 0 ""
} }
@test "helpers: bash-it help plugins" {
run bash-it help plugins
assert_line -n 1 "base:"
}
@test "helpers: bash-it help list aliases without any aliases enabled" { @test "helpers: bash-it help list aliases without any aliases enabled" {
run _help-list-aliases "$BASH_IT/aliases/available/ag.aliases.bash" run _help-list-aliases "$BASH_IT/aliases/available/ag.aliases.bash"
assert_line -n 0 "ag:" assert_line -n 0 "ag:"

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bats #!/usr/bin/env bats
load ../test_helper load ../test_helper
load ../../lib/composure load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
load ../../lib/appearance load ../../lib/appearance
load ../../plugins/available/base.plugin load ../../plugins/available/base.plugin

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bats #!/usr/bin/env bats
load ../test_helper load ../test_helper
load ../../lib/composure load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
load ../../lib/log load ../../lib/log
load ../../lib/helpers load ../../lib/helpers
load ../../lib/utilities load ../../lib/utilities

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bats #!/usr/bin/env bats
load ../test_helper load ../test_helper
load ../../lib/composure load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
load ../../lib/helpers load ../../lib/helpers
load ../../lib/utilities load ../../lib/utilities
load ../../lib/search load ../../lib/search

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bats #!/usr/bin/env bats
load ../test_helper load ../test_helper
load ../../lib/composure load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
load ../../lib/log load ../../lib/log
load ../../lib/helpers load ../../lib/helpers

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bats #!/usr/bin/env bats
load ../test_helper load ../test_helper
load ../../lib/composure load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
load ../../plugins/available/base.plugin load ../../plugins/available/base.plugin
@test 'plugins base: ips()' { @test 'plugins base: ips()' {

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bats #!/usr/bin/env bats
load ../test_helper load ../test_helper
load ../../lib/composure load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
cite _about _param _example _group _author _version cite _about _param _example _group _author _version

View File

@@ -0,0 +1,47 @@
#!/usr/bin/env bats
load ../test_helper
load ../../lib/helpers
load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
load ../../plugins/available/cmd-returned-notify.plugin
@test "plugins cmd-returned-notify: notify after elapsed time" {
export NOTIFY_IF_COMMAND_RETURNS_AFTER=0
export LAST_COMMAND_TIME=$(date +%s)
sleep 1
run precmd_return_notification
assert_success
assert_output $'\a'
}
@test "plugins cmd-returned-notify: do not notify before elapsed time" {
export NOTIFY_IF_COMMAND_RETURNS_AFTER=10
export LAST_COMMAND_TIME=$(date +%s)
sleep 1
run precmd_return_notification
assert_success
assert_output $''
}
@test "plugins cmd-returned-notify: preexec no output" {
export LAST_COMMAND_TIME=
run preexec_return_notification
assert_success
assert_output ""
}
@test "plugins cmd-returned-notify: preexec no output env set" {
export LAST_COMMAND_TIME=$(date +%s)
run preexec_return_notification
assert_failure
assert_output ""
}
@test "plugins cmd-returned-notify: preexec set LAST_COMMAND_TIME" {
export LAST_COMMAND_TIME=
assert_equal "${LAST_COMMAND_TIME}" ""
NOW=$(date +%s)
preexec_return_notification
assert_equal "${LAST_COMMAND_TIME}" "${NOW}"
}

View File

@@ -2,59 +2,53 @@
load ../test_helper load ../test_helper
load ../../lib/helpers load ../../lib/helpers
load ../../lib/composure load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
@test 'ensure _go_pathmunge_wrap is defined' { @test 'ensure _bash-it-gopath-pathmunge is defined' {
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found' { [[ $CI ]] || _command_exists go; } || skip 'golang not found'
load ../../plugins/available/go.plugin load ../../plugins/available/go.plugin
run type -t _go_pathmunge_wrap run type -t _bash-it-gopath-pathmunge
assert_line 'function' assert_line 'function'
} }
@test 'plugins go: single entry in GOPATH' { @test 'plugins go: single entry in GOPATH' {
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found' { [[ $CI ]] || _command_exists go; } || skip 'golang not found'
export GOPATH="/foo" export GOPATH="/foo"
export GOROOT="/baz"
load ../../plugins/available/go.plugin load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo/bin:/baz/bin" assert_equal "$(cut -d':' -f1 <<<$PATH)" "/foo/bin"
} }
@test 'plugins go: single entry in GOPATH, with space' { @test 'plugins go: single entry in GOPATH, with space' {
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found' { [[ $CI ]] || _command_exists go; } || skip 'golang not found'
export GOPATH="/foo bar" export GOPATH="/foo bar"
export GOROOT="/baz"
load ../../plugins/available/go.plugin load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo bar/bin:/baz/bin" assert_equal "$(cut -d':' -f1 <<<$PATH)" "/foo bar/bin"
} }
@test 'plugins go: single entry in GOPATH, with escaped space' { @test 'plugins go: single entry in GOPATH, with escaped space' {
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found' { [[ $CI ]] || _command_exists go; } || skip 'golang not found'
export GOPATH="/foo\ bar" export GOPATH="/foo\ bar"
export GOROOT="/baz"
load ../../plugins/available/go.plugin load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo\ bar/bin:/baz/bin" assert_equal "$(cut -d':' -f1 <<<$PATH)" "/foo\ bar/bin"
} }
@test 'plugins go: multiple entries in GOPATH' { @test 'plugins go: multiple entries in GOPATH' {
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found' { [[ $CI ]] || _command_exists go; } || skip 'golang not found'
export GOPATH="/foo:/bar" export GOPATH="/foo:/bar"
export GOROOT="/baz"
load ../../plugins/available/go.plugin load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1,2,3 <<<$PATH)" "/foo/bin:/bar/bin:/baz/bin" assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo/bin:/bar/bin"
} }
@test 'plugins go: multiple entries in GOPATH, with space' { @test 'plugins go: multiple entries in GOPATH, with space' {
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found' { [[ $CI ]] || _command_exists go; } || skip 'golang not found'
export GOPATH="/foo:/foo bar" export GOPATH="/foo:/foo bar"
export GOROOT="/baz"
load ../../plugins/available/go.plugin load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1,2,3 <<<$PATH)" "/foo/bin:/foo bar/bin:/baz/bin" assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo/bin:/foo bar/bin"
} }
@test 'plugins go: multiple entries in GOPATH, with escaped space' { @test 'plugins go: multiple entries in GOPATH, with escaped space' {
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found' { [[ $CI ]] || _command_exists go; } || skip 'golang not found'
export GOPATH="/foo:/foo\ bar" export GOPATH="/foo:/foo\ bar"
export GOROOT="/baz"
load ../../plugins/available/go.plugin load ../../plugins/available/go.plugin
assert_equal "$(cut -d':' -f1,2,3 <<<$PATH)" "/foo/bin:/foo\ bar/bin:/baz/bin" assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo/bin:/foo\ bar/bin"
} }

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