-
-
Notifications
You must be signed in to change notification settings - Fork 682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib/bourne-shell.sh: Don't force-load bash-completion #572
Open
ifireball
wants to merge
6
commits into
ohmybash:master
Choose a base branch
from
ifireball:no-force-compl
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ebb8c36
lib/bourne-shell: Do not load bash-completion
ifireball 4f4c84c
feat(bashrc): enable "completions/system" by default
akinomyoga 3a03814
style(completions/system): adjust coding styles
akinomyoga 8ed02a8
refactor(rsync): normalize detection of macOS
akinomyoga fcce66a
fix(completions/system): load bash-completion only once
akinomyoga d291140
feat(completions/system): integrate bash-completion loader in lib/bou…
akinomyoga File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,44 @@ | ||
#! bash oh-my-bash.module | ||
|
||
# Loads the system's Bash completion modules. | ||
# If Homebrew is installed (OS X), its Bash completion modules are loaded. | ||
# Loads one of the system's Bash-completion modules. | ||
|
||
if [ -f /etc/bash_completion ]; then | ||
. /etc/bash_completion | ||
fi | ||
|
||
# Some distribution makes use of a profile.d script to import completion. | ||
if [ -f /etc/profile.d/bash_completion.sh ]; then | ||
. /etc/profile.d/bash_completion.sh | ||
fi | ||
# If bash-completion is already enabled (by e.g. /etc/bash.bashrc sourced from | ||
# /etc/profile or directly executed by Bash), we skip loading bash-completion. | ||
[[ ${BASH_COMPLETION_VERSINFO-} ]] && return 0 | ||
|
||
# We skip loading bash-completion in the POSIX mode. Older versions of | ||
# bash-completion do not work in the POSIX mode. | ||
shopt -oq posix && return 0 | ||
|
||
if [ $(uname) = "Darwin" ] && _omb_util_command_exists brew; then | ||
# If Homebrew is installed (OS X), its Bash completion module is loaded. | ||
if is_os darwin && _omb_util_command_exists brew; then | ||
BREW_PREFIX=$(brew --prefix) | ||
|
||
if [ -f "$BREW_PREFIX"/etc/bash_completion ]; then | ||
. "$BREW_PREFIX"/etc/bash_completion | ||
# homebrew/versions/bash-completion2 (required for projects.completion.bash) | ||
# is installed to this path | ||
if [[ -f "$BREW_PREFIX"/share/bash-completion/bash_completion ]]; then | ||
source "$BREW_PREFIX"/share/bash-completion/bash_completion | ||
return "$?" | ||
fi | ||
|
||
# homebrew/versions/bash-completion2 (required for projects.completion.bash) is installed to this path | ||
if [ -f "$BREW_PREFIX"/share/bash-completion/bash_completion ]; then | ||
. "$BREW_PREFIX"/share/bash-completion/bash_completion | ||
if [[ -f "$BREW_PREFIX"/etc/bash_completion ]]; then | ||
source "$BREW_PREFIX"/etc/bash_completion | ||
return "$?" | ||
fi | ||
fi | ||
|
||
if [[ -f /usr/share/bash-completion/bash_completion ]]; then | ||
# bash-completion v2 is installed at this location | ||
source /usr/share/bash-completion/bash_completion | ||
return "$?" | ||
elif [[ -f /etc/bash_completion ]]; then | ||
# bash-completion v1 is installed at this location | ||
source /etc/bash_completion | ||
return "$?" | ||
fi | ||
|
||
if [[ -f /etc/profile.d/bash_completion.sh ]]; then | ||
# Some distribution makes use of a profile.d script to import completion. | ||
source /etc/profile.d/bash_completion.sh | ||
return "$?" | ||
fi |
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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One request I would make here is the ability to set a
BASH_COMPLETION_DIR
, and check it as a potential location.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if that is useful. If you know the location of bash_completion and needs to specify it explicitly, how is it different from
source '<path to bash_completion>/bash_completion'
? A plugin that allows users to writeBASH_COMPLETION_DIR='<path to bash_completion>' plugins+=(system)
instead of
doesn't seem useful. It actually complicates the configuration.
Also, the plugin name
system
implies loadingbash-completion
in a system package. Allowing the configuration for an arbitrary location ofbash-completion
doesn't match the plugin's name. If the configuration would be added, the plugin name should also be changed.In addition,
BASH_COMPLETION_*
is a kind of variable namespace used bybash-completion
[1,2], so we should avoid defining a variable of the formBASH_COMPLETION_*
outsidebash-completion
. It might conflict in the future. We should useOMB_COMPLETION_SYSTEM_BASH_COMPLETION_DIR
or something.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't think of just sourcing the file directly. Good call