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
f660ad35
Commit
f660ad35
authored
11 years ago
by
Junegunn Choi
Browse files
Options
Downloads
Patches
Plain Diff
Improve bash completion: `[DIRECTORY/][FUZZY_PATTERN]**<TAB>`
parent
c61738ae
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+17
-11
17 additions, 11 deletions
README.md
fzf-completion.bash
+21
-15
21 additions, 15 deletions
fzf-completion.bash
with
38 additions
and
26 deletions
README.md
+
17
−
11
View file @
f660ad35
...
...
@@ -73,12 +73,13 @@ Usage
```
usage: fzf [options]
-m, --multi Enable multi-select
-x, --extended Extended-search mode
-s, --sort=MAX Maximum number of matched items to sort. Default: 1000
+s, --no-sort Do not sort the result. Keep the sequence unchanged.
+i Case-sensitive match
+c, --no-color Disable colors
-m, --multi Enable multi-select
-x, --extended Extended-search mode
-q, --query=STR Initial query
-s, --sort=MAX Maximum number of matched items to sort. Default: 1000
+s, --no-sort Do not sort the result. Keep the sequence unchanged.
+i Case-sensitive match
+c, --no-color Disable colors
```
fzf will launch curses-based finder, read the list from STDIN, and write the
...
...
@@ -266,8 +267,10 @@ over time*
### bash
fuzzy-finder-completion can be triggered if you type in a directory name
followed by the trigger sequence which is by default
`**`
.
Fuzzy completion can be triggered if the word before the cursor ends
with the trigger sequence which is by default
`**`
.
-
`COMMAND [DIRECTORY/][FUZZY_PATTERN]**<TAB>`
#### Examples
...
...
@@ -277,7 +280,10 @@ followed by the trigger sequence which is by default `**`.
vim
**
<TAB>
# Files under parent directory
vim ..
**
<TAB>
vim ../
**
<TAB>
# Files under parent directory that match `fzf`
vim ../fzf
**
<TAB>
# Files under your home directory
vim ~/
**
<TAB>
...
...
@@ -286,8 +292,8 @@ vim ~/**<TAB>
# Directories under current directory (single-selection)
cd
**
<TAB>
# Directories under
parent directory
cd
../
**
<TAB>
# Directories under
~/github that match `fzf`
cd
~/github/fzf
**
<TAB>
```
#### Settings
...
...
This diff is collapsed.
Click to expand it.
fzf-completion.bash
+
21
−
15
View file @
f660ad35
...
...
@@ -31,31 +31,37 @@ _fzf_opts_completion() {
}
_fzf_generic_completion
()
{
local
cur prev opts base matches
local
cur prev opts base
dir
leftover
matches
COMPREPLY
=()
FZF_COMPLETION_TRIGGER
=
${
FZF_COMPLETION_TRIGGER
:-
**
}
cur
=
"
${
COMP_WORDS
[COMP_CWORD]
}
"
prev
=
"
${
COMP_WORDS
[COMP_CWORD-1]
}
"
if
[[
${
cur
}
==
*
"
$FZF_COMPLETION_TRIGGER
"
]]
;
then
base
=
${
cur
:0:
${#
cur
}
-
${#
FZF_COMPLETION_TRIGGER
}}
base
=
${
base
%/
}
eval
base
=
$base
find_opts
=
"-name .git -prune -o -name .svn -prune -o"
if
[
-z
"
$base
"
-o
-d
"
$base
"
]
;
then
matches
=
$(
find
${
base
:-
*
}
$1
2> /dev/null | fzf
$FZF_COMPLETION_OPTS
$2
|
while
read
item
;
do
if
[[
${
item
}
=
~
\
]]
;
then
echo
-n
"
\"
$item
\"
"
else
echo
-n
"
$item
"
dir
=
"
$base
"
while
[
1
]
;
do
if
[
-z
"
$dir
"
-o
-d
"
$dir
"
]
;
then
leftover
=
${
base
/#
"
$dir
"
}
leftover
=
${
leftover
/#\/
}
[
"
$dir
"
=
'.'
]
&&
dir
=
''
matches
=
$(
find
"
$dir
"
*
$1
2> /dev/null | fzf
$FZF_COMPLETION_OPTS
$2
-q
"
$leftover
"
|
while
read
item
;
do
if
[[
${
item
}
=
~
\
]]
;
then
echo
-n
"
\"
$item
\"
"
else
echo
-n
"
$item
"
fi
done
)
matches
=
${
matches
%
}
if
[
-n
"
$matches
"
]
;
then
COMPREPLY
=(
"
$matches
"
)
return
0
fi
done
)
matches
=
${
matches
%
}
if
[
-n
"
$matches
"
]
;
then
COMPREPLY
=(
"
$matches
"
)
return
0
return
1
fi
fi
dir
=
$(
dirname
"
$dir
"
)
done
fi
}
...
...
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