[bash] Put C-t items at point in vi mode (#1876)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Be consistent with emacs mode and put the items at the point vs. the end of the command line.
authored by Jack Bates · committed by GitHub · parent 9897ee9 · Browse files · 3 files·+31 added−52 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+31 added−52 removed
- tests:+4 added−4 removed
- other:+27 added−48 removed
Provenance
- Commit
9c293bb- Tree
c93e417- Author
Jack Bates <jack@nottheoilrig.com>- Committer
GitHub <noreply@github.com>- Parent
9897ee9
3 files changed+31 added−52 removed
modified:shell/key-bindings.bash+9 added-25 removed
82 unmodified lines838485868788899091929394878889909697989991101102103104105106107108109929394951121139697989911611710010110210382 unmodified lines
# ALT-C - cd into the selected directorybind -m emacs-standard '"\ec": " \C-e\C-u`__fzf_cd__`\e\C-e\er\C-m"'
# We'd usually use "\e" to enter vi-movement-mode so we can do our magic,# but this incurs a very noticeable delay of a half second or so,# because many other commands start with "\e".# Instead, we bind an unused key, "\C-x\C-a",# to also enter vi-movement-mode,# and then use that thereafter.# (We imagine that "\C-x\C-a" is relatively unlikely to be in use.)bind -m vi-insert '"\C-x\C-a": vi-movement-mode'bind -m vi-command '"\C-z": emacs-editing-mode'bind -m vi-insert '"\C-z": emacs-editing-mode'bind -m emacs-standard '"\C-z": vi-editing-mode'
bind -m vi-insert '"\C-x\C-e": shell-expand-line'bind -m vi-insert '"\C-x\C-r": redraw-current-line'bind -m vi-insert '"\C-x^": history-expand-line'
# CTRL-T - Paste the selected file path into the command line# - FIXME: Selected items are attached to the end regardless of cursor positionif [ $BASH_VERSINFO -gt 3 ]; then bind -m vi-insert -x '"\C-t": "fzf-file-widget"'elif __fzf_use_tmux__; then bind -m vi-insert '"\C-t": "\C-x\C-a$a \C-x\C-addi`__fzf_select_tmux__`\C-x\C-e\C-x\C-a0P$xa"'else bind -m vi-insert '"\C-t": "\C-x\C-a$a \C-x\C-addi`__fzf_select__`\C-x\C-e\C-x\C-a0Px$a \C-x\C-r\C-x\C-axa "'fibind -m vi-command '"\C-t": "i\C-t"'bind -m vi-command '"\C-t": "\C-z\C-t\C-z"'bind -m vi-insert '"\C-t": "\C-z\C-t\C-z"'
# CTRL-R - Paste the selected command from history into the command linebind -m vi-insert '"\C-r": "\C-x\C-addi`__fzf_history__`\C-x\C-e\C-x\C-r\C-x^\C-x\C-a$a"'bind -m vi-command '"\C-r": "i\C-r"'bind -m vi-command '"\C-r": "\C-z\C-r\C-z"'bind -m vi-insert '"\C-r": "\C-z\C-r\C-z"'
# ALT-C - cd into the selected directorybind -m vi-insert '"\ec": "\C-x\C-addi`__fzf_cd__`\C-x\C-e\C-x\C-r\C-m"'bind -m vi-command '"\ec": "ddi`__fzf_cd__`\C-x\C-e\C-x\C-r\C-m"'bind -m vi-command '"\ec": "\C-z\ec\C-z"'bind -m vi-insert '"\ec": "\C-z\ec\C-z"'
fimodified:test/test_go.rb+4 added-4 removed
113 unmodified lines114 end115 end116 117 def paste(str)118- `tmux setb '#{str.gsub("'", "'\\''")}' \\; pasteb -t #{win} \\; send-keys -t #{win} Enter`118+ system('tmux', 'setb', str, ';', 'pasteb', '-t', win, ';', 'send-keys', '-t', win, 'Enter')119 end120 121 def capture(pane = 0)122 File.unlink TEMPNAME while File.exist? TEMPNAME367 unmodified lines490 end491 end492 493 def test_query_unicode494- tmux.paste "(echo abc; echo 가나다) | #{fzf :query, '가다'}"494+ tmux.paste "(echo abc; echo $'\\352\\260\\200\\353\\202\\230\\353\\213\\244') | #{fzf :query, "$'\\352\\260\\200\\353\\213\\244'"}"495 tmux.until { |lines| lines[-2].include? '1/2' }496 tmux.send_keys :Enter497 assert_equal ['가나다'], readonce.split($INPUT_RECORD_SEPARATOR)498 end1274 unmodified lines1773 tmux.send_keys :Tab1774 tmux.until { |lines| lines.select_count == 2 }1775 1776 tmux.send_keys :Enter1777- tmux.until { |lines| lines.any_include?(/echo.*fzf-unicode.*1.*fzf-unicode.*2/) }1777+ tmux.until { |lines| lines.join.match(/echo.*fzf-unicode.*1.*fzf-unicode.*2/) }1778 tmux.send_keys :Enter1779 tmux.until { |lines| lines.any_include?(/^fzf-unicode.*1.*fzf-unicode.*2/) }1780 end1781 208 unmodified lines1990 end1991 1992 def test_file_completion_unicode1993 FileUtils.mkdir_p '/tmp/fzf-test'1994- tmux.paste 'cd /tmp/fzf-test; echo -n test3 > "fzf-unicode 테스트1"; echo -n test4 > "fzf-unicode 테스트2"'1994+ tmux.paste "cd /tmp/fzf-test; echo -n test3 > $'fzf-unicode \\355\\205\\214\\354\\212\\244\\355\\212\\2701'; echo -n test4 > $'fzf-unicode \\355\\205\\214\\354\\212\\244\\355\\212\\2702'"1995 tmux.prepare1996 tmux.send_keys 'cat fzf-unicode**', :Tab1997 tmux.until { |lines| lines.match_count == 2 }1998 88 unmodified linesmodified:.travis.yml+18 added-23 removed
1223456785679910111213141516171819202122232425262710111213141516171819202122language: godist: xenialenv: GO111MODULE=onos: - linux - osxdist: bionic # For fish >= 2.3.0 string builtinaddons: apt: sources: - sourceline: "ppa:pi-rho/dev" - sourceline: "ppa:fish-shell/release-2" packages: - tmux - zsh - fish
env: - GO111MODULE=on
jobs: include: - stage: unittest go: "1.13.x" script: make && make test
- stage: cli go: "1.13.x" rvm: "2.5" script: | make install && ./install --all && tmux new "ruby test/test_go.rb > out && touch ok" && cat out && [ -e ok ]
- fish - zsh homebrew: packages: - fish - tmux update: truescript: - make test # LC_ALL=C to avoid escape codes in # printf %q $'\355\205\214\354\212\244\355\212\270' on macOS. Bash on # macOS is built without HANDLE_MULTIBYTE? - make install && ./install --all && LC_ALL=C tmux new-session -d && ruby test/test_go.rb