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
7d15071c
Commit
7d15071c
authored
10 years ago
by
Junegunn Choi
Browse files
Options
Downloads
Patches
Plain Diff
Fish shell support - installer / key bindings (#33)
parent
89eb1575
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
+29
-6
29 additions, 6 deletions
README.md
install
+99
-10
99 additions, 10 deletions
install
with
128 additions
and
16 deletions
README.md
+
29
−
6
View file @
7d15071c
...
...
@@ -35,13 +35,13 @@ curl -L https://github.com/junegunn/fzf/archive/master.tar.gz |
The script will setup:
-
`fzf`
executable
-
Key bindings (
`CTRL-T`
,
`CTRL-R`
, and
`ALT-C`
)
for bash and z
sh
-
Fuzzy auto-completion
for
bash
-
`fzf`
function (bash, zsh, fish)
-
Key bindings (
`CTRL-T`
,
`CTRL-R`
, and
`ALT-C`
)
(bash, zsh, fi
sh
)
-
Fuzzy auto-completion
(
bash
)
If you don't use
bash or zsh
, you have to manually place
fzf executable in a
directory included in
`$PATH`
. Key bindings and
auto-completion will not be
available in that case.
If you don't use
any of the aforementioned shells
, you have to manually place
fzf executable in a
directory included in
`$PATH`
. Key bindings and
auto-completion will not be
available in that case.
### Install as Vim plugin
...
...
@@ -458,6 +458,29 @@ export FZF_DEFAULT_COMMAND='ag -l -g ""'
fzf
```
### Fish shell
It's
[
a known bug of fish
](
https://github.com/fish-shell/fish-shell/issues/1362
)
that it doesn't allow reading from STDIN in command substitution, which means
simple
`vim (fzf)`
won't work as expected. The workaround is to store the result
of fzf to a temporary file.
```
sh
function
vimf
if
fzf
>
$TMPDIR
/fzf.result
vim
(
cat
$TMPDIR
/fzf.result
)
end
end
function
fe
set
tmp
$TMPDIR
/fzf.result
fzf
--query
=
"
$argv
[1]"
--select-1
--exit-0
>
$tmp
if
[
(
cat
$tmp
|
wc
-l
)
-gt
0
]
vim
(
cat
$tmp
)
end
end
```
### Windows
fzf works on
[
Cygwin
](
http://www.cygwin.com/
)
and
...
...
This diff is collapsed.
Click to expand it.
install
+
99
−
10
View file @
7d15071c
...
...
@@ -230,29 +230,118 @@ EOFZF
echo
"OK"
done
echo
for
shell
in
bash zsh
;
do
rc
=
~/.
${
shell
}
rc
src
=
"source ~/.fzf.
${
shell
}
"
# fish
has_fish
=
0
if
[
-n
"
$(
which fish
)
"
]
;
then
has_fish
=
1
echo
-n
"Generate ~/.config/fish/functions/fzf.fish ... "
mkdir
-p
~/.config/fish/functions
cat
>
~/.config/fish/functions/fzf.fish
<<
EOFZF
function fzf
$fzf_cmd
\$
argv
end
EOFZF
echo
"ok"
if
[
$key_bindings
-eq
0
]
;
then
echo
-n
"Generate ~/.config/fish/functions/fzf_key_bindings.fish ... "
cat
>
~/.config/fish/functions/fzf_key_bindings.fish
<<
"
EOFZF
"
function fzf_key_bindings
function __fzf_select
find * -path '*/
\.
*' -prune
\
-o -type f -print
\
-o -type d -print
\
-o -type l -print 2> /dev/null | fzf -m | while read item
echo -n (echo -n "
$item
" | sed 's/ /
\\\\
/g')' '
end
echo
end
echo
"Update
$rc
:"
echo
" -
$src
"
line
=
$(
grep
-nF
"
$src
"
$rc
|
sed
's/:.*//'
)
function __fzf_ctrl_t
if [ -n "
$TMUX_PANE
" -a "
$FZF_TMUX
" != "0" ]
tmux split-window (__fzf_tmux_height) "fish -c 'fzf_key_bindings; __fzf_ctrl_t_tmux
\\
$TMUX_PANE
'"
else
__fzf_select >
$TMPDIR
/fzf.result
and commandline -i (cat
$TMPDIR
/fzf.result)
end
end
function __fzf_ctrl_t_tmux
__fzf_select >
$TMPDIR
/fzf.result
and tmux send-keys -t
$argv
[1] (cat
$TMPDIR
/fzf.result)
end
function __fzf_ctrl_r
if history | fzf +s +m >
$TMPDIR
/fzf.result
commandline (cat
$TMPDIR
/fzf.result)
else
commandline -f repaint
end
end
function __fzf_alt_c
find * -path '*/
\.
*' -prune -o -type d -print 2> /dev/null | fzf +m >
$TMPDIR
/fzf.result
if [ (cat
$TMPDIR
/fzf.result | wc -l) -gt 0 ]
cd (cat
$TMPDIR
/fzf.result)
end
commandline -f repaint
end
function __fzf_tmux_height
if set -q FZF_TMUX_HEIGHT
set height
$FZF_TMUX_HEIGHT
else
set height 40%
end
if echo
$height
| grep -q -E '%
$'
echo "-p "(echo
$height
| sed 's/%
$/
/')
else
echo "-l
$height
"
end
set -e height
end
bind
\c
t '__fzf_ctrl_t'
bind
\c
r '__fzf_ctrl_r'
bind
\e
c '__fzf_alt_c'
end
EOFZF
echo
"ok"
fi
fi
append_line
()
{
echo
"Update
$2
:"
echo
" -
$1
"
[
-f
"
$2
"
]
||
touch
"
$2
"
line
=
$(
grep
-nF
"
$1
"
"
$2
"
|
sed
's/:.*//'
)
if
[
-n
"
$line
"
]
;
then
echo
" - Already exists (line #
$line
)"
else
echo
$src
>>
$rc
echo
"
$1
"
>>
"
$2
"
echo
" - Added"
fi
echo
}
echo
for
shell
in
bash zsh
;
do
append_line
"source ~/.fzf.
${
shell
}
"
~/.
${
shell
}
rc
done
if
[
$key_bindings
-eq
0
-a
$has_fish
-eq
1
]
;
then
bind_file
=
~/.config/fish/functions/fish_user_key_bindings.fish
append_line
"fzf_key_bindings"
"
$bind_file
"
fi
cat
<<
EOF
Finished. Re
load
your
.bashrc or .zshrc
.
Finished. Re
start
your
shell or reload config file
.
source ~/.bashrc # bash
source ~/.zshrc # zsh
EOF
[
$has_fish
-eq
1
]
&&
echo
" fzf_key_bindings # fish"
;
cat
<<
EOF
To uninstall fzf, simply remove the added line.
To uninstall fzf, simply remove the added line
s
.
For more information, see: https://github.com/junegunn/fzf
EOF
...
...
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