forked from brianthelion/plugnparse
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Qhughes/tabcomplete #4
Open
quincy2112
wants to merge
3
commits into
dev
Choose a base branch
from
qhughes/tabcomplete
base: dev
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
3 commits
Select commit
Hold shift + click to select a range
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 |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# Copyright 2012-2019, Andrey Kislyuk and argcomplete contributors. | ||
# Licensed under the Apache License. See https://github.com/kislyuk/argcomplete for more info. | ||
|
||
# Copy of __expand_tilde_by_ref from bash-completion | ||
__python_argcomplete_expand_tilde_by_ref () { | ||
if [ "${!1:0:1}" = "~" ]; then | ||
if [ "${!1}" != "${!1//\/}" ]; then | ||
eval $1="${!1/%\/*}"/'${!1#*/}'; | ||
else | ||
eval $1="${!1}"; | ||
fi; | ||
fi | ||
} | ||
|
||
# Run something, muting output or redirecting it to the debug stream | ||
# depending on the value of _ARC_DEBUG. | ||
# If ARGCOMPLETE_USE_TEMPFILES is set, use tempfiles for IPC. | ||
__python_argcomplete_run() { | ||
if [[ -z "$ARGCOMPLETE_USE_TEMPFILES" ]]; then | ||
__python_argcomplete_run_inner "$@" | ||
return | ||
fi | ||
local tmpfile="$(mktemp)" | ||
_ARGCOMPLETE_STDOUT_FILENAME="$tmpfile" __python_argcomplete_run_inner "$@" | ||
local code=$? | ||
cat "$tmpfile" | ||
rm "$tmpfile" | ||
return $code | ||
} | ||
|
||
__python_argcomplete_run_inner() { | ||
if [[ -z "$_ARC_DEBUG" ]]; then | ||
"$@" 8>&1 9>&2 1>/dev/null 2>&1 | ||
else | ||
"$@" 8>&1 9>&2 1>&9 2>&1 | ||
fi | ||
} | ||
|
||
# Scan the beginning of an executable file ($1) for a regexp ($2). By default, | ||
# scan for the magic string indicating that the executable supports the | ||
# argcomplete completion protocol. By default, scan the first kilobyte; | ||
# if $3 is set to -n, scan until the first line break up to a kilobyte. | ||
__python_argcomplete_scan_head() { | ||
read -s -r ${3:--N} 1024 < "$1" | ||
[[ "$REPLY" =~ ${2:-PYTHON_ARGCOMPLETE_OK} ]] | ||
} | ||
|
||
__python_argcomplete_scan_head_noerr() { | ||
__python_argcomplete_scan_head "$@" 2>/dev/null | ||
} | ||
|
||
_python_argcomplete_global() { | ||
local executable=$1 | ||
__python_argcomplete_expand_tilde_by_ref executable | ||
|
||
local ARGCOMPLETE=0 | ||
if [[ "$executable" == python* ]] || [[ "$executable" == pypy* ]]; then | ||
if [[ "${COMP_WORDS[1]}" == -m ]]; then | ||
if __python_argcomplete_run "$executable" -m argcomplete._check_module "${COMP_WORDS[2]}"; then | ||
ARGCOMPLETE=3 | ||
else | ||
return | ||
fi | ||
elif [[ -f "${COMP_WORDS[1]}" ]] && __python_argcomplete_scan_head_noerr "${COMP_WORDS[1]}"; then | ||
local ARGCOMPLETE=2 | ||
else | ||
return | ||
fi | ||
elif type -P "$executable" >/dev/null 2>&1; then | ||
local SCRIPT_NAME=$(type -P "$executable") | ||
if (type -t pyenv && [[ "$SCRIPT_NAME" = $(pyenv root)/shims/* ]]) >/dev/null 2>&1; then | ||
local SCRIPT_NAME=$(pyenv which "$executable") | ||
fi | ||
if __python_argcomplete_scan_head_noerr "$SCRIPT_NAME"; then | ||
local ARGCOMPLETE=1 | ||
elif __python_argcomplete_scan_head_noerr "$SCRIPT_NAME" '^#!(.*)$' -n && [[ "${BASH_REMATCH[1]}" =~ ^.*(python|pypy)[0-9\.]*$ ]]; then | ||
local interpreter="$BASH_REMATCH" | ||
if (__python_argcomplete_scan_head_noerr "$SCRIPT_NAME" "(PBR Generated)|(EASY-INSTALL-(SCRIPT|ENTRY-SCRIPT|DEV-SCRIPT))" \ | ||
&& "$interpreter" "$(type -P python-argcomplete-check-easy-install-script)" "$SCRIPT_NAME") >/dev/null 2>&1; then | ||
local ARGCOMPLETE=1 | ||
elif __python_argcomplete_run "$interpreter" -m argcomplete._check_console_script "$SCRIPT_NAME"; then | ||
local ARGCOMPLETE=1 | ||
fi | ||
fi | ||
fi | ||
|
||
if [[ $ARGCOMPLETE != 0 ]]; then | ||
local IFS=$(echo -e '\v') | ||
COMPREPLY=( $(_ARGCOMPLETE_IFS="$IFS" \ | ||
COMP_LINE="$COMP_LINE" \ | ||
COMP_POINT="$COMP_POINT" \ | ||
COMP_TYPE="$COMP_TYPE" \ | ||
_ARGCOMPLETE_COMP_WORDBREAKS="$COMP_WORDBREAKS" \ | ||
_ARGCOMPLETE=$ARGCOMPLETE \ | ||
_ARGCOMPLETE_SUPPRESS_SPACE=1 \ | ||
__python_argcomplete_run "$executable" "${COMP_WORDS[@]:1:ARGCOMPLETE-1}") ) | ||
if [[ $? != 0 ]]; then | ||
unset COMPREPLY | ||
elif [[ "$COMPREPLY" =~ [=/:]$ ]]; then | ||
compopt -o nospace | ||
fi | ||
else | ||
type -t _completion_loader | grep -q 'function' && _completion_loader "$@" | ||
fi | ||
} | ||
complete -o default -o bashdefault -D -F _python_argcomplete_global |
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
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.
@brianthelion are there consequences for our license in pulling this file in?