-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
12 changed files
with
252 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ The main ``bash_it.sh`` script loads the frameworks individual components in the | |
|
||
|
||
* ``lib/composure.bash`` | ||
* ``vendor/init.d/*.bash`` | ||
* Files in ``lib`` with the exception of ``appearance.bash`` - this means that ``composure.bash`` is loaded again here (possible improvement?) | ||
* Enabled ``aliases`` | ||
* Enabled ``plugins`` | ||
|
@@ -78,6 +79,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. | ||
|
||
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/[email protected]" | ||
[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 | ||
[email protected]: | ||
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 | ||
------------------------ | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,33 @@ | ||
# shellcheck shell=bash | ||
cite about-plugin | ||
about-plugin 'automatically set your xterm title with host and location info' | ||
|
||
|
||
_short-dirname () { | ||
local dir_name=`dirs +0` | ||
[ "$SHORT_TERM_LINE" = true ] && [ ${#dir_name} -gt 8 ] && echo ${dir_name##*/} || echo $dir_name | ||
_short-dirname() { | ||
local dir_name=$(dirs +0) | ||
[ "$SHORT_TERM_LINE" = true ] && [ "${#dir_name}" -gt 8 ] && echo "${dir_name##*/}" || echo "${dir_name}" | ||
} | ||
|
||
_short-command () { | ||
local input_command="$@" | ||
[ "$SHORT_TERM_LINE" = true ] && [ ${#input_command} -gt 8 ] && echo ${input_command%% *} || echo $input_command | ||
_short-command() { | ||
local input_command="$*" | ||
[ "$SHORT_TERM_LINE" = true ] && [ "${#input_command}" -gt 8 ] && echo "${input_command%% *}" || echo "${input_command}" | ||
} | ||
|
||
set_xterm_title () { | ||
local title="$1" | ||
echo -ne "\033]0;$title\007" | ||
set_xterm_title() { | ||
local title="$1" | ||
echo -ne "\033]0;$title\007" | ||
} | ||
|
||
precmd () { | ||
set_xterm_title "${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}} `_short-dirname` $PROMPTCHAR" | ||
precmd_xterm_title() { | ||
set_xterm_title "${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}} $(_short-dirname) $PROMPT_CHAR" | ||
} | ||
|
||
preexec () { | ||
set_xterm_title "`_short-command $1` {`_short-dirname`} (${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}})" | ||
preexec_xterm_title() { | ||
set_xterm_title "$(_short-command "${1}") {$(_short-dirname)} (${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}})" | ||
} | ||
|
||
case "$TERM" in | ||
xterm*|rxvt*) preexec_install;; | ||
xterm* | rxvt*) | ||
precmd_functions+=(precmd_xterm_title) | ||
preexec_functions+=(preexec_xterm_title) | ||
;; | ||
esac |
Empty file.
Empty file.
Oops, something went wrong.