Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cupric
Fzf
Commits
c39c039e
Unverified
Commit
c39c039e
authored
9 years ago
by
Junegunn Choi
Browse files
Options
Download
Email Patches
Plain Diff
[shell] Add $FZF_CTRL_T_OPTS and $FZF_ALT_C_OPTS
Close #596
parent
07f176f4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+3
-0
README.md
shell/key-bindings.bash
+3
-3
shell/key-bindings.bash
shell/key-bindings.fish
+2
-2
shell/key-bindings.fish
shell/key-bindings.zsh
+2
-2
shell/key-bindings.zsh
with
10 additions
and
7 deletions
+10
-7
README.md
+
3
-
0
View file @
c39c039e
...
...
@@ -178,11 +178,14 @@ fish.
-
`CTRL-T`
- Paste the selected files and directories onto the command line
-
Set
`FZF_CTRL_T_COMMAND`
to override the default command
-
Set
`FZF_CTRL_T_OPTS`
to pass additional options
-
`CTRL-R`
- Paste the selected command from history onto the command line
-
Sort is disabled by default to respect chronological ordering
-
Press
`CTRL-R`
again to toggle sort
-
Set
`FZF_CTRL_R_OPTS`
to pass additional options
-
`ALT-C`
- cd into the selected directory
-
Set
`FZF_ALT_C_COMMAND`
to override the default command
-
Set
`FZF_ALT_C_OPTS`
to pass additional options
If you're on a tmux session, fzf will start in a split pane. You may disable
this tmux integration by setting
`FZF_TMUX`
to 0, or change the height of the
...
...
This diff is collapsed.
Click to expand it.
shell/key-bindings.bash
+
3
-
3
View file @
c39c039e
...
...
@@ -5,7 +5,7 @@ __fzf_select__() {
-o -type f -print
\
-o -type d -print
\
-o -type l -print 2> /dev/null | sed 1d | cut -b3-"
}
"
eval
"
$cmd
"
| fzf
-m
|
while
read
-r
item
;
do
eval
"
$cmd
| fzf -m
$FZF_CTRL_T_OPTS
"
|
while
read
-r
item
;
do
printf
'%q '
"
$item
"
done
echo
...
...
@@ -26,7 +26,7 @@ __fzf_select_tmux__() {
height
=
"-l
$height
"
fi
tmux split-window
$height
"cd
$(
printf
%q
"
$PWD
"
)
; FZF_DEFAULT_OPTS=
$(
printf
%q
"
$FZF_DEFAULT_OPTS
"
)
PATH=
$(
printf
%q
"
$PATH
"
)
FZF_CTRL_T_COMMAND=
$(
printf
%q
"
$FZF_CTRL_T_COMMAND
"
)
bash -c 'source
\"
${
BASH_SOURCE
[0]
}
\"
; tmux send-keys -t
$TMUX_PANE
\"\$
(__fzf_select__)
\"
'"
tmux split-window
$height
"cd
$(
printf
%q
"
$PWD
"
)
; FZF_DEFAULT_OPTS=
$(
printf
%q
"
$FZF_DEFAULT_OPTS
"
)
PATH=
$(
printf
%q
"
$PATH
"
)
FZF_CTRL_T_COMMAND=
$(
printf
%q
"
$FZF_CTRL_T_COMMAND
"
)
FZF_CTRL_T_OPTS=
$(
printf
%q
"
$FZF_CTRL_T_OPTS
"
)
bash -c 'source
\"
${
BASH_SOURCE
[0]
}
\"
; tmux send-keys -t
$TMUX_PANE
\"\$
(__fzf_select__)
\"
'"
}
fzf-file-widget
()
{
...
...
@@ -43,7 +43,7 @@ __fzf_cd__() {
local
cmd
dir
cmd
=
"
${
FZF_ALT_C_COMMAND
:-
"command find -L .
\\
( -path '*/
\\
.*' -o -fstype 'dev' -o -fstype 'proc'
\\
) -prune
\
-o -type d -print 2> /dev/null | sed 1d | cut -b3-"
}
"
dir
=
$(
eval
"
$cmd
"
|
$(
__fzfcmd
)
+m
)
&&
printf
'cd %q'
"
$dir
"
dir
=
$(
eval
"
$cmd
|
$(
__fzfcmd
)
+m
$FZF_ALT_C_OPTS
"
)
&&
printf
'cd %q'
"
$dir
"
}
__fzf_history__
()
(
...
...
This diff is collapsed.
Click to expand it.
shell/key-bindings.fish
+
2
-
2
View file @
c39c039e
...
...
@@ -19,7 +19,7 @@ function fzf_key_bindings
-o -type f -print \
-o -type d -print \
-o -type l -print 2> /dev/null | sed 1d | cut -b3-"
eval "$FZF_CTRL_T_COMMAND | "(__fzfcmd)" -m > $TMPDIR/fzf.result"
eval "$FZF_CTRL_T_COMMAND | "(__fzfcmd)" -m
$FZF_CTRL_T_OPTS
> $TMPDIR/fzf.result"
and for i in (seq 20); commandline -i (cat $TMPDIR/fzf.result | __fzf_escape) 2> /dev/null; and break; sleep 0.1; end
commandline -f repaint
rm -f $TMPDIR/fzf.result
...
...
@@ -37,7 +37,7 @@ function fzf_key_bindings
command find -L . \\( -path '*/\\.*' -o -fstype 'dev' -o -fstype 'proc' \\) -prune \
-o -type d -print 2> /dev/null | sed 1d | cut -b3-"
# Fish hangs if the command before pipe redirects (2> /dev/null)
eval "$FZF_ALT_C_COMMAND | "(__fzfcmd)" +m > $TMPDIR/fzf.result"
eval "$FZF_ALT_C_COMMAND | "(__fzfcmd)" +m
$FZF_ALT_C_OPTS
> $TMPDIR/fzf.result"
[ (cat $TMPDIR/fzf.result | wc -l) -gt 0 ]
and cd (cat $TMPDIR/fzf.result)
commandline -f repaint
...
...
This diff is collapsed.
Click to expand it.
shell/key-bindings.zsh
+
2
-
2
View file @
c39c039e
...
...
@@ -8,7 +8,7 @@ __fsel() {
-o -type f -print
\
-o -type d -print
\
-o -type l -print 2> /dev/null | sed 1d | cut -b3-"
}
"
eval
"
$cmd
"
|
$(
__fzfcmd
)
-m
|
while
read
item
;
do
eval
"
$cmd
|
$(
__fzfcmd
)
-m
$FZF_CTRL_T_OPTS
"
|
while
read
item
;
do
echo
-n
"
${
(q)item
}
"
done
echo
...
...
@@ -29,7 +29,7 @@ bindkey '^T' fzf-file-widget
fzf-cd-widget
()
{
local
cmd
=
"
${
FZF_ALT_C_COMMAND
:-
"command find -L .
\\
( -path '*/
\\
.*' -o -fstype 'dev' -o -fstype 'proc'
\\
) -prune
\
-o -type d -print 2> /dev/null | sed 1d | cut -b3-"
}
"
cd
"
${
$(
eval
"
$cmd
"
|
$(
__fzfcmd
)
+m
)
:-
.
}
"
cd
"
${
$(
eval
"
$cmd
|
$(
__fzfcmd
)
+m
$FZF_ALT_C_OPTS
"
)
:-
.
}
"
zle reset-prompt
}
zle
-N
fzf-cd-widget
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets