[shell] Add FZF_CTRL_T_COMMAND for CTRL-T
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Close #40
authored by Junegunn Choi · committed by Junegunn Choi · parent 14e3b84 · Browse files · 5 files·+35 added−9 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+35 added−9 removed
- tests:+21 added−0 removed
- other:+14 added−9 removed
Provenance
- Commit
938151a- Tree
6ffbb24- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
14e3b84
5 files changed+35 added−9 removed
modified:shell/key-bindings.bash+4 added-3 removed
1234456778910111211 unmodified lines2425262727282930313258 unmodified lines# Key bindings# ------------__fzf_select__() { command find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \ local cmd="${FZF_CTRL_T_COMMAND:-"command \\find -L . \\( -path '*/\\.*' -o -fstype 'dev' -o -fstype 'proc' \\) -prune \ -o -type f -print \ -o -type d -print \ -o -type l -print 2> /dev/null | sed 1d | cut -b3- | fzf -m | while read item; do -o -type l -print 2> /dev/null | sed 1d | cut -b3-"}" eval "$cmd" | fzf -m | while read item; do printf '%q ' "$item" done echo}11 unmodified lines height="-p ${height%\%}" else height="-l $height" fi tmux split-window $height "cd $(printf %q "$PWD");bash -c 'source ~/.fzf.bash; tmux send-keys -t $TMUX_PANE \"\$(__fzf_select__)\"'" tmux split-window $height "cd $(printf %q "$PWD"); FZF_CTRL_T_COMMAND=$(printf %q "$FZF_CTRL_T_COMMAND") bash -c 'source ~/.fzf.bash; tmux send-keys -t $TMUX_PANE \"\$(__fzf_select__)\"'"}
__fzf_cd__() { local dir58 unmodified linesmodified:shell/key-bindings.fish+4 added-2 removed
12 unmodified lines13 end14 end15 16 function __fzf_ctrl_t17- command find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \17+ set -q FZF_CTRL_T_COMMAND; or set -l FZF_CTRL_T_COMMAND "18+ command find -L . \\( -path '*/\\.*' -o -fstype 'dev' -o -fstype 'proc' \\) -prune \19 -o -type f -print \20 -o -type d -print \20- -o -type l -print 2> /dev/null | sed 1d | cut -b3- | eval (__fzfcmd) -m > $TMPDIR/fzf.result21+ -o -type l -print 2> /dev/null | sed 1d | cut -b3-"22+ eval $FZF_CTRL_T_COMMAND | eval (__fzfcmd) -m > $TMPDIR/fzf.result23 and commandline -i (cat $TMPDIR/fzf.result | __fzf_escape)24 commandline -f repaint25 rm -f $TMPDIR/fzf.result26 end43 unmodified linesmodified:shell/key-bindings.zsh+3 added-2 removed
2 unmodified lines345677891010111213141537 unmodified lines2 unmodified linesif [[ $- =~ i ]]; then
# CTRL-T - Paste the selected file path(s) into the command line__fsel() { command find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \ local cmd="${FZF_CTRL_T_COMMAND:-"command \\find -L . \\( -path '*/\\.*' -o -fstype 'dev' -o -fstype 'proc' \\) -prune \ -o -type f -print \ -o -type d -print \ -o -type l -print 2> /dev/null | sed 1d | cut -b3- | $(__fzfcmd) -m | while read item; do -o -type l -print 2> /dev/null | sed 1d | cut -b3-"}" eval "$cmd" | $(__fzfcmd) -m | while read item; do printf '%q ' "$item" done echo}37 unmodified linesmodified:test/test_go.rb+21 added
146 unmodified lines147 end148 149 def setup150 ENV.delete 'FZF_DEFAULT_OPTS'151+ ENV.delete 'FZF_CTRL_T_COMMAND'152 ENV.delete 'FZF_DEFAULT_COMMAND'153 end154 155 def readonce495 unmodified lines651 def teardown652 @tmux.kill653 end654 655+ def set_var name, val656+ tmux.prepare657+ tmux.send_keys "export #{name}='#{val}'", :Enter658+ tmux.prepare659+ end660+661 def test_ctrl_t662 tmux.prepare663 tmux.send_keys 'C-t', pane: 0664 lines = tmux.until(1) { |lines| lines.item_count > 1 }11 unmodified lines676 tmux.until(0) { |lines| lines[-1].include? expected }677 tmux.send_keys 'C-c', 'C-d'678 end679 680+ def test_ctrl_t_command681+ set_var "FZF_CTRL_T_COMMAND", "seq 100"682+ tmux.send_keys 'C-t', pane: 0683+ lines = tmux.until(1) { |lines| lines.item_count == 100 }684+ tmux.send_keys :BTab, :BTab, :BTab, :Enter, pane: 1685+ tmux.until(0) { |lines| lines[-1].include? '1 2 3' }686+ end687+688 def test_alt_c689 tmux.prepare690 tmux.send_keys :Escape, :c, pane: 0691 lines = tmux.until(1) { |lines| lines.item_count > 0 && lines[-3][2..-1] }164 unmodified lines856 tmux.send_keys 'function fish_prompt; end; clear', :Enter857 tmux.until { |lines| lines.empty? }858 end859 860+ def set_var name, val861+ tmux.prepare862+ tmux.send_keys "set -l #{name} '#{val}'", :Enter863+ tmux.prepare864+ end865+866 def setup867 super868 @tmux = Tmux.new :fish869 end2 unmodified linesmodified:README.md+3 added-2 removed
145 unmodified lines146 147 The install script will setup the following key bindings for bash, zsh, and148 fish.149 150-- `CTRL-T` - Paste the selected file path(s) into the command line151-- `CTRL-R` - Paste the selected command from history into the command line150+- `CTRL-T` - Paste the selected files and directories onto the command line151+ - Set `FZF_CTRL_T_COMMAND` to override the default command152+- `CTRL-R` - Paste the selected command from history onto the command line153 - Sort is disabled by default to respect chronological ordering154 - Press `CTRL-R` again to toggle sort155 - `ALT-C` - cd into the selected directory156 285 unmodified lines