Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
fzf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
fzf
Commits
486b87d8
Commit
486b87d8
authored
9 years ago
by
Junegunn Choi
Browse files
Options
Downloads
Patches
Plain Diff
[bash-completion] Retain original completion options (#288)
parent
b3010a46
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
shell/completion.bash
+26
-10
26 additions, 10 deletions
shell/completion.bash
with
26 additions
and
10 deletions
shell/completion.bash
+
26
−
10
View file @
486b87d8
...
...
@@ -11,8 +11,8 @@
# - $FZF_COMPLETION_OPTS (default: empty)
_fzf_orig_completion_filter
()
{
sed
's/.*-F *\([^ ]*\).* \([^ ]*\)$/export _fzf_orig_completion_\
2=\1
;/'
|
sed
's/[^a-z0-9_= ;]/_/g
'
sed
's/
^\(
.*-F
\)
*\([^ ]*\).* \([^ ]*\)$/export _fzf_orig_completion_\
3="\1 %s \3 #\2"
;/'
|
awk
-F
=
'{gsub(/[^a-z0-9_= ;]/, "_", $1); print $1"="$2}
'
}
_fzf_opts_completion
()
{
...
...
@@ -77,12 +77,12 @@ _fzf_opts_completion() {
}
_fzf_handle_dynamic_completion
()
{
local
cmd orig ret orig_cmd
local
cmd
orig_var
orig ret orig_cmd
cmd
=
"
$1
"
shift
orig_cmd
=
"
$1
"
orig
=
$(
eval
"echo
\$
_fzf_orig_completion_
$cmd
"
)
orig_var
=
"_fzf_orig_completion_
$cmd
"
orig
=
"
${
!orig_var##*#
}
"
if
[
-n
"
$orig
"
]
&&
type
"
$orig
"
>
/dev/null 2>&1
;
then
$orig
"
$@
"
elif
[
-n
"
$_fzf_completion_loader
"
]
;
then
...
...
@@ -252,32 +252,48 @@ a_cmds="
x_cmds
=
"kill ssh telnet unset unalias export"
# Preserve existing completion
if
[
"
$_fzf_completion_loaded
"
!=
'0.
9.12
'
]
;
then
if
[
"
$_fzf_completion_loaded
"
!=
'0.
10.8
'
]
;
then
# Really wish I could use associative array but OSX comes with bash 3.2 :(
eval
$(
complete
|
\g
rep
'\-F'
|
\g
rep
-v
_fzf_ |
\g
rep
-E
" (
$(
echo
$d_cmds
$f_cmds
$a_cmds
$x_cmds
|
sed
's/ /|/g'
|
sed
's/+/\\+/g'
)
)$"
| _fzf_orig_completion_filter
)
export
_fzf_completion_loaded
=
0.
9.12
export
_fzf_completion_loaded
=
0.
10.8
fi
if
type
_completion_loader
>
/dev/null 2>&1
;
then
_fzf_completion_loader
=
1
fi
_fzf_defc
()
{
local
cmd func opts orig_var orig
cmd
=
"
$1
"
func
=
"
$2
"
opts
=
"
$3
"
orig_var
=
"_fzf_orig_completion_
$cmd
"
orig
=
"
${
!orig_var
}
"
if
[
-n
"
$orig
"
]
;
then
eval
"
$(
printf
"
$orig
"
"
$func
"
)
"
else
complete
-F
"
$func
"
$opts
"
$cmd
"
fi
}
# Directory
for
cmd
in
$d_cmds
;
do
complete
-F
_fzf_dir_completion
-o
nospace
-o
plusdirs
$cmd
_fzf_defc
"
$cmd
"
_fzf_dir_completion
"
-o nospace -o plusdirs
"
done
# File
for
cmd
in
$f_cmds
;
do
complete
-F
_fzf_file_completion
-o
default
-o
bashdefault
$cmd
_fzf_defc
"
$cmd
"
_fzf_file_completion
"
-o default -o bashdefault
"
done
# Anything
for
cmd
in
$a_cmds
;
do
complete
-F
_fzf_path_completion
-o
default
-o
bashdefault
$cmd
_fzf_defc
"
$cmd
"
_fzf_path_completion
"
-o default -o bashdefault
"
done
unset
_fzf_defc
# Kill completion
complete
-F
_fzf_complete_kill
-o
nospace
-o
default
-o
bashdefault
kill
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment