doing 2.0.19 → 2.0.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/Gemfile.lock +15 -5
  4. data/README.md +1 -1
  5. data/bin/doing +2 -18
  6. data/doing.gemspec +5 -4
  7. data/doing.rdoc +2 -2
  8. data/generate_completions.sh +3 -3
  9. data/lib/doing/cli_status.rb +6 -2
  10. data/lib/doing/completion/bash_completion.rb +185 -0
  11. data/lib/doing/completion/fish_completion.rb +175 -0
  12. data/lib/doing/completion/string.rb +17 -0
  13. data/lib/doing/completion/zsh_completion.rb +140 -0
  14. data/lib/doing/completion.rb +39 -0
  15. data/lib/doing/version.rb +1 -1
  16. data/lib/doing/wwid.rb +19 -5
  17. data/lib/doing.rb +1 -1
  18. data/lib/helpers/fzf/.goreleaser.yml +119 -0
  19. data/lib/helpers/fzf/.rubocop.yml +28 -0
  20. data/lib/helpers/fzf/ADVANCED.md +565 -0
  21. data/lib/helpers/fzf/BUILD.md +49 -0
  22. data/lib/helpers/fzf/CHANGELOG.md +1193 -0
  23. data/lib/helpers/fzf/Dockerfile +11 -0
  24. data/lib/helpers/fzf/LICENSE +21 -0
  25. data/lib/helpers/fzf/Makefile +166 -0
  26. data/lib/helpers/fzf/README-VIM.md +486 -0
  27. data/lib/helpers/fzf/README.md +712 -0
  28. data/lib/helpers/fzf/bin/fzf-tmux +233 -0
  29. data/lib/helpers/fzf/doc/fzf.txt +512 -0
  30. data/lib/helpers/fzf/go.mod +17 -0
  31. data/lib/helpers/fzf/go.sum +31 -0
  32. data/lib/helpers/fzf/install +382 -0
  33. data/lib/helpers/fzf/install.ps1 +65 -0
  34. data/lib/helpers/fzf/main.go +14 -0
  35. data/lib/helpers/fzf/man/man1/fzf-tmux.1 +68 -0
  36. data/lib/helpers/fzf/man/man1/fzf.1 +1001 -0
  37. data/lib/helpers/fzf/plugin/fzf.vim +1048 -0
  38. data/lib/helpers/fzf/shell/completion.bash +381 -0
  39. data/lib/helpers/fzf/shell/completion.zsh +329 -0
  40. data/lib/helpers/fzf/shell/key-bindings.bash +96 -0
  41. data/lib/helpers/fzf/shell/key-bindings.fish +172 -0
  42. data/lib/helpers/fzf/shell/key-bindings.zsh +114 -0
  43. data/lib/helpers/fzf/src/LICENSE +21 -0
  44. data/lib/helpers/fzf/src/algo/algo.go +884 -0
  45. data/lib/helpers/fzf/src/algo/algo_test.go +197 -0
  46. data/lib/helpers/fzf/src/algo/normalize.go +492 -0
  47. data/lib/helpers/fzf/src/ansi.go +409 -0
  48. data/lib/helpers/fzf/src/ansi_test.go +427 -0
  49. data/lib/helpers/fzf/src/cache.go +81 -0
  50. data/lib/helpers/fzf/src/cache_test.go +39 -0
  51. data/lib/helpers/fzf/src/chunklist.go +89 -0
  52. data/lib/helpers/fzf/src/chunklist_test.go +80 -0
  53. data/lib/helpers/fzf/src/constants.go +85 -0
  54. data/lib/helpers/fzf/src/core.go +351 -0
  55. data/lib/helpers/fzf/src/history.go +96 -0
  56. data/lib/helpers/fzf/src/history_test.go +68 -0
  57. data/lib/helpers/fzf/src/item.go +44 -0
  58. data/lib/helpers/fzf/src/item_test.go +23 -0
  59. data/lib/helpers/fzf/src/matcher.go +235 -0
  60. data/lib/helpers/fzf/src/merger.go +120 -0
  61. data/lib/helpers/fzf/src/merger_test.go +88 -0
  62. data/lib/helpers/fzf/src/options.go +1691 -0
  63. data/lib/helpers/fzf/src/options_test.go +457 -0
  64. data/lib/helpers/fzf/src/pattern.go +425 -0
  65. data/lib/helpers/fzf/src/pattern_test.go +209 -0
  66. data/lib/helpers/fzf/src/protector/protector.go +8 -0
  67. data/lib/helpers/fzf/src/protector/protector_openbsd.go +10 -0
  68. data/lib/helpers/fzf/src/reader.go +201 -0
  69. data/lib/helpers/fzf/src/reader_test.go +63 -0
  70. data/lib/helpers/fzf/src/result.go +243 -0
  71. data/lib/helpers/fzf/src/result_others.go +16 -0
  72. data/lib/helpers/fzf/src/result_test.go +159 -0
  73. data/lib/helpers/fzf/src/result_x86.go +16 -0
  74. data/lib/helpers/fzf/src/terminal.go +2832 -0
  75. data/lib/helpers/fzf/src/terminal_test.go +638 -0
  76. data/lib/helpers/fzf/src/terminal_unix.go +26 -0
  77. data/lib/helpers/fzf/src/terminal_windows.go +45 -0
  78. data/lib/helpers/fzf/src/tokenizer.go +253 -0
  79. data/lib/helpers/fzf/src/tokenizer_test.go +112 -0
  80. data/lib/helpers/fzf/src/tui/dummy.go +46 -0
  81. data/lib/helpers/fzf/src/tui/light.go +987 -0
  82. data/lib/helpers/fzf/src/tui/light_unix.go +110 -0
  83. data/lib/helpers/fzf/src/tui/light_windows.go +145 -0
  84. data/lib/helpers/fzf/src/tui/tcell.go +721 -0
  85. data/lib/helpers/fzf/src/tui/tcell_test.go +392 -0
  86. data/lib/helpers/fzf/src/tui/ttyname_unix.go +47 -0
  87. data/lib/helpers/fzf/src/tui/ttyname_windows.go +14 -0
  88. data/lib/helpers/fzf/src/tui/tui.go +625 -0
  89. data/lib/helpers/fzf/src/tui/tui_test.go +20 -0
  90. data/lib/helpers/fzf/src/util/atomicbool.go +34 -0
  91. data/lib/helpers/fzf/src/util/atomicbool_test.go +17 -0
  92. data/lib/helpers/fzf/src/util/chars.go +198 -0
  93. data/lib/helpers/fzf/src/util/chars_test.go +46 -0
  94. data/lib/helpers/fzf/src/util/eventbox.go +96 -0
  95. data/lib/helpers/fzf/src/util/eventbox_test.go +61 -0
  96. data/lib/helpers/fzf/src/util/slab.go +12 -0
  97. data/lib/helpers/fzf/src/util/util.go +138 -0
  98. data/lib/helpers/fzf/src/util/util_test.go +40 -0
  99. data/lib/helpers/fzf/src/util/util_unix.go +47 -0
  100. data/lib/helpers/fzf/src/util/util_windows.go +83 -0
  101. data/lib/helpers/fzf/test/fzf.vader +175 -0
  102. data/lib/helpers/fzf/test/test_go.rb +2626 -0
  103. data/lib/helpers/fzf/uninstall +117 -0
  104. data/scripts/generate_bash_completions.rb +6 -12
  105. data/scripts/generate_fish_completions.rb +7 -16
  106. data/scripts/generate_zsh_completions.rb +6 -15
  107. metadata +144 -9
@@ -0,0 +1,96 @@
1
+ # ____ ____
2
+ # / __/___ / __/
3
+ # / /_/_ / / /_
4
+ # / __/ / /_/ __/
5
+ # /_/ /___/_/ key-bindings.bash
6
+ #
7
+ # - $FZF_TMUX_OPTS
8
+ # - $FZF_CTRL_T_COMMAND
9
+ # - $FZF_CTRL_T_OPTS
10
+ # - $FZF_CTRL_R_OPTS
11
+ # - $FZF_ALT_C_COMMAND
12
+ # - $FZF_ALT_C_OPTS
13
+
14
+ # Key bindings
15
+ # ------------
16
+ __fzf_select__() {
17
+ local cmd="${FZF_CTRL_T_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
18
+ -o -type f -print \
19
+ -o -type d -print \
20
+ -o -type l -print 2> /dev/null | cut -b3-"}"
21
+ eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS" $(__fzfcmd) -m "$@" | while read -r item; do
22
+ printf '%q ' "$item"
23
+ done
24
+ echo
25
+ }
26
+
27
+ if [[ $- =~ i ]]; then
28
+
29
+ __fzfcmd() {
30
+ [[ -n "$TMUX_PANE" ]] && { [[ "${FZF_TMUX:-0}" != 0 ]] || [[ -n "$FZF_TMUX_OPTS" ]]; } &&
31
+ echo "fzf-tmux ${FZF_TMUX_OPTS:--d${FZF_TMUX_HEIGHT:-40%}} -- " || echo "fzf"
32
+ }
33
+
34
+ fzf-file-widget() {
35
+ local selected="$(__fzf_select__)"
36
+ READLINE_LINE="${READLINE_LINE:0:$READLINE_POINT}$selected${READLINE_LINE:$READLINE_POINT}"
37
+ READLINE_POINT=$(( READLINE_POINT + ${#selected} ))
38
+ }
39
+
40
+ __fzf_cd__() {
41
+ local cmd dir
42
+ cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
43
+ -o -type d -print 2> /dev/null | cut -b3-"}"
44
+ dir=$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m) && printf 'cd -- %q' "$dir"
45
+ }
46
+
47
+ __fzf_history__() {
48
+ local output
49
+ output=$(
50
+ builtin fc -lnr -2147483648 |
51
+ last_hist=$(HISTTIMEFORMAT='' builtin history 1) perl -n -l0 -e 'BEGIN { getc; $/ = "\n\t"; $HISTCMD = $ENV{last_hist} + 1 } s/^[ *]//; print $HISTCMD - $. . "\t$_" if !$seen{$_}++' |
52
+ FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort,ctrl-z:ignore $FZF_CTRL_R_OPTS +m --read0" $(__fzfcmd) --query "$READLINE_LINE"
53
+ ) || return
54
+ READLINE_LINE=${output#*$'\t'}
55
+ if [[ -z "$READLINE_POINT" ]]; then
56
+ echo "$READLINE_LINE"
57
+ else
58
+ READLINE_POINT=0x7fffffff
59
+ fi
60
+ }
61
+
62
+ # Required to refresh the prompt after fzf
63
+ bind -m emacs-standard '"\er": redraw-current-line'
64
+
65
+ bind -m vi-command '"\C-z": emacs-editing-mode'
66
+ bind -m vi-insert '"\C-z": emacs-editing-mode'
67
+ bind -m emacs-standard '"\C-z": vi-editing-mode'
68
+
69
+ if (( BASH_VERSINFO[0] < 4 )); then
70
+ # CTRL-T - Paste the selected file path into the command line
71
+ bind -m emacs-standard '"\C-t": " \C-b\C-k \C-u`__fzf_select__`\e\C-e\er\C-a\C-y\C-h\C-e\e \C-y\ey\C-x\C-x\C-f"'
72
+ bind -m vi-command '"\C-t": "\C-z\C-t\C-z"'
73
+ bind -m vi-insert '"\C-t": "\C-z\C-t\C-z"'
74
+
75
+ # CTRL-R - Paste the selected command from history into the command line
76
+ bind -m emacs-standard '"\C-r": "\C-e \C-u\C-y\ey\C-u"$(__fzf_history__)"\e\C-e\er"'
77
+ bind -m vi-command '"\C-r": "\C-z\C-r\C-z"'
78
+ bind -m vi-insert '"\C-r": "\C-z\C-r\C-z"'
79
+ else
80
+ # CTRL-T - Paste the selected file path into the command line
81
+ bind -m emacs-standard -x '"\C-t": fzf-file-widget'
82
+ bind -m vi-command -x '"\C-t": fzf-file-widget'
83
+ bind -m vi-insert -x '"\C-t": fzf-file-widget'
84
+
85
+ # CTRL-R - Paste the selected command from history into the command line
86
+ bind -m emacs-standard -x '"\C-r": __fzf_history__'
87
+ bind -m vi-command -x '"\C-r": __fzf_history__'
88
+ bind -m vi-insert -x '"\C-r": __fzf_history__'
89
+ fi
90
+
91
+ # ALT-C - cd into the selected directory
92
+ bind -m emacs-standard '"\ec": " \C-b\C-k \C-u`__fzf_cd__`\e\C-e\er\C-m\C-y\C-h\e \C-y\ey\C-x\C-x\C-d"'
93
+ bind -m vi-command '"\ec": "\C-z\ec\C-z"'
94
+ bind -m vi-insert '"\ec": "\C-z\ec\C-z"'
95
+
96
+ fi
@@ -0,0 +1,172 @@
1
+ # ____ ____
2
+ # / __/___ / __/
3
+ # / /_/_ / / /_
4
+ # / __/ / /_/ __/
5
+ # /_/ /___/_/ key-bindings.fish
6
+ #
7
+ # - $FZF_TMUX_OPTS
8
+ # - $FZF_CTRL_T_COMMAND
9
+ # - $FZF_CTRL_T_OPTS
10
+ # - $FZF_CTRL_R_OPTS
11
+ # - $FZF_ALT_C_COMMAND
12
+ # - $FZF_ALT_C_OPTS
13
+
14
+ # Key bindings
15
+ # ------------
16
+ function fzf_key_bindings
17
+
18
+ # Store current token in $dir as root for the 'find' command
19
+ function fzf-file-widget -d "List files and folders"
20
+ set -l commandline (__fzf_parse_commandline)
21
+ set -l dir $commandline[1]
22
+ set -l fzf_query $commandline[2]
23
+ set -l prefix $commandline[3]
24
+
25
+ # "-path \$dir'*/\\.*'" matches hidden files/folders inside $dir but not
26
+ # $dir itself, even if hidden.
27
+ test -n "$FZF_CTRL_T_COMMAND"; or set -l FZF_CTRL_T_COMMAND "
28
+ command find -L \$dir -mindepth 1 \\( -path \$dir'*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' \\) -prune \
29
+ -o -type f -print \
30
+ -o -type d -print \
31
+ -o -type l -print 2> /dev/null | sed 's@^\./@@'"
32
+
33
+ test -n "$FZF_TMUX_HEIGHT"; or set FZF_TMUX_HEIGHT 40%
34
+ begin
35
+ set -lx FZF_DEFAULT_OPTS "--height $FZF_TMUX_HEIGHT --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS"
36
+ eval "$FZF_CTRL_T_COMMAND | "(__fzfcmd)' -m --query "'$fzf_query'"' | while read -l r; set result $result $r; end
37
+ end
38
+ if [ -z "$result" ]
39
+ commandline -f repaint
40
+ return
41
+ else
42
+ # Remove last token from commandline.
43
+ commandline -t ""
44
+ end
45
+ for i in $result
46
+ commandline -it -- $prefix
47
+ commandline -it -- (string escape $i)
48
+ commandline -it -- ' '
49
+ end
50
+ commandline -f repaint
51
+ end
52
+
53
+ function fzf-history-widget -d "Show command history"
54
+ test -n "$FZF_TMUX_HEIGHT"; or set FZF_TMUX_HEIGHT 40%
55
+ begin
56
+ set -lx FZF_DEFAULT_OPTS "--height $FZF_TMUX_HEIGHT $FZF_DEFAULT_OPTS --tiebreak=index --bind=ctrl-r:toggle-sort,ctrl-z:ignore $FZF_CTRL_R_OPTS +m"
57
+
58
+ set -l FISH_MAJOR (echo $version | cut -f1 -d.)
59
+ set -l FISH_MINOR (echo $version | cut -f2 -d.)
60
+
61
+ # history's -z flag is needed for multi-line support.
62
+ # history's -z flag was added in fish 2.4.0, so don't use it for versions
63
+ # before 2.4.0.
64
+ if [ "$FISH_MAJOR" -gt 2 -o \( "$FISH_MAJOR" -eq 2 -a "$FISH_MINOR" -ge 4 \) ];
65
+ history -z | eval (__fzfcmd) --read0 --print0 -q '(commandline)' | read -lz result
66
+ and commandline -- $result
67
+ else
68
+ history | eval (__fzfcmd) -q '(commandline)' | read -l result
69
+ and commandline -- $result
70
+ end
71
+ end
72
+ commandline -f repaint
73
+ end
74
+
75
+ function fzf-cd-widget -d "Change directory"
76
+ set -l commandline (__fzf_parse_commandline)
77
+ set -l dir $commandline[1]
78
+ set -l fzf_query $commandline[2]
79
+ set -l prefix $commandline[3]
80
+
81
+ test -n "$FZF_ALT_C_COMMAND"; or set -l FZF_ALT_C_COMMAND "
82
+ command find -L \$dir -mindepth 1 \\( -path \$dir'*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' \\) -prune \
83
+ -o -type d -print 2> /dev/null | sed 's@^\./@@'"
84
+ test -n "$FZF_TMUX_HEIGHT"; or set FZF_TMUX_HEIGHT 40%
85
+ begin
86
+ set -lx FZF_DEFAULT_OPTS "--height $FZF_TMUX_HEIGHT --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS"
87
+ eval "$FZF_ALT_C_COMMAND | "(__fzfcmd)' +m --query "'$fzf_query'"' | read -l result
88
+
89
+ if [ -n "$result" ]
90
+ cd -- $result
91
+
92
+ # Remove last token from commandline.
93
+ commandline -t ""
94
+ commandline -it -- $prefix
95
+ end
96
+ end
97
+
98
+ commandline -f repaint
99
+ end
100
+
101
+ function __fzfcmd
102
+ test -n "$FZF_TMUX"; or set FZF_TMUX 0
103
+ test -n "$FZF_TMUX_HEIGHT"; or set FZF_TMUX_HEIGHT 40%
104
+ if [ -n "$FZF_TMUX_OPTS" ]
105
+ echo "fzf-tmux $FZF_TMUX_OPTS -- "
106
+ else if [ $FZF_TMUX -eq 1 ]
107
+ echo "fzf-tmux -d$FZF_TMUX_HEIGHT -- "
108
+ else
109
+ echo "fzf"
110
+ end
111
+ end
112
+
113
+ bind \ct fzf-file-widget
114
+ bind \cr fzf-history-widget
115
+ bind \ec fzf-cd-widget
116
+
117
+ if bind -M insert > /dev/null 2>&1
118
+ bind -M insert \ct fzf-file-widget
119
+ bind -M insert \cr fzf-history-widget
120
+ bind -M insert \ec fzf-cd-widget
121
+ end
122
+
123
+ function __fzf_parse_commandline -d 'Parse the current command line token and return split of existing filepath, fzf query, and optional -option= prefix'
124
+ set -l commandline (commandline -t)
125
+
126
+ # strip -option= from token if present
127
+ set -l prefix (string match -r -- '^-[^\s=]+=' $commandline)
128
+ set commandline (string replace -- "$prefix" '' $commandline)
129
+
130
+ # eval is used to do shell expansion on paths
131
+ eval set commandline $commandline
132
+
133
+ if [ -z $commandline ]
134
+ # Default to current directory with no --query
135
+ set dir '.'
136
+ set fzf_query ''
137
+ else
138
+ set dir (__fzf_get_dir $commandline)
139
+
140
+ if [ "$dir" = "." -a (string sub -l 1 -- $commandline) != '.' ]
141
+ # if $dir is "." but commandline is not a relative path, this means no file path found
142
+ set fzf_query $commandline
143
+ else
144
+ # Also remove trailing slash after dir, to "split" input properly
145
+ set fzf_query (string replace -r "^$dir/?" -- '' "$commandline")
146
+ end
147
+ end
148
+
149
+ echo $dir
150
+ echo $fzf_query
151
+ echo $prefix
152
+ end
153
+
154
+ function __fzf_get_dir -d 'Find the longest existing filepath from input string'
155
+ set dir $argv
156
+
157
+ # Strip all trailing slashes. Ignore if $dir is root dir (/)
158
+ if [ (string length -- $dir) -gt 1 ]
159
+ set dir (string replace -r '/*$' -- '' $dir)
160
+ end
161
+
162
+ # Iteratively check if dir exists and strip tail end of path
163
+ while [ ! -d "$dir" ]
164
+ # If path is absolute, this can keep going until ends up at /
165
+ # If path is relative, this can keep going until entire input is consumed, dirname returns "."
166
+ set dir (dirname -- "$dir")
167
+ end
168
+
169
+ echo $dir
170
+ end
171
+
172
+ end
@@ -0,0 +1,114 @@
1
+ # ____ ____
2
+ # / __/___ / __/
3
+ # / /_/_ / / /_
4
+ # / __/ / /_/ __/
5
+ # /_/ /___/_/ key-bindings.zsh
6
+ #
7
+ # - $FZF_TMUX_OPTS
8
+ # - $FZF_CTRL_T_COMMAND
9
+ # - $FZF_CTRL_T_OPTS
10
+ # - $FZF_CTRL_R_OPTS
11
+ # - $FZF_ALT_C_COMMAND
12
+ # - $FZF_ALT_C_OPTS
13
+
14
+ # Key bindings
15
+ # ------------
16
+
17
+ # The code at the top and the bottom of this file is the same as in completion.zsh.
18
+ # Refer to that file for explanation.
19
+ if 'zmodload' 'zsh/parameter' 2>'/dev/null' && (( ${+options} )); then
20
+ __fzf_key_bindings_options="options=(${(j: :)${(kv)options[@]}})"
21
+ else
22
+ () {
23
+ __fzf_key_bindings_options="setopt"
24
+ 'local' '__fzf_opt'
25
+ for __fzf_opt in "${(@)${(@f)$(set -o)}%% *}"; do
26
+ if [[ -o "$__fzf_opt" ]]; then
27
+ __fzf_key_bindings_options+=" -o $__fzf_opt"
28
+ else
29
+ __fzf_key_bindings_options+=" +o $__fzf_opt"
30
+ fi
31
+ done
32
+ }
33
+ fi
34
+
35
+ 'emulate' 'zsh' '-o' 'no_aliases'
36
+
37
+ {
38
+
39
+ [[ -o interactive ]] || return 0
40
+
41
+ # CTRL-T - Paste the selected file path(s) into the command line
42
+ __fsel() {
43
+ local cmd="${FZF_CTRL_T_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
44
+ -o -type f -print \
45
+ -o -type d -print \
46
+ -o -type l -print 2> /dev/null | cut -b3-"}"
47
+ setopt localoptions pipefail no_aliases 2> /dev/null
48
+ local item
49
+ eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS" $(__fzfcmd) -m "$@" | while read item; do
50
+ echo -n "${(q)item} "
51
+ done
52
+ local ret=$?
53
+ echo
54
+ return $ret
55
+ }
56
+
57
+ __fzfcmd() {
58
+ [ -n "$TMUX_PANE" ] && { [ "${FZF_TMUX:-0}" != 0 ] || [ -n "$FZF_TMUX_OPTS" ]; } &&
59
+ echo "fzf-tmux ${FZF_TMUX_OPTS:--d${FZF_TMUX_HEIGHT:-40%}} -- " || echo "fzf"
60
+ }
61
+
62
+ fzf-file-widget() {
63
+ LBUFFER="${LBUFFER}$(__fsel)"
64
+ local ret=$?
65
+ zle reset-prompt
66
+ return $ret
67
+ }
68
+ zle -N fzf-file-widget
69
+ bindkey '^T' fzf-file-widget
70
+
71
+ # ALT-C - cd into the selected directory
72
+ fzf-cd-widget() {
73
+ local cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
74
+ -o -type d -print 2> /dev/null | cut -b3-"}"
75
+ setopt localoptions pipefail no_aliases 2> /dev/null
76
+ local dir="$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m)"
77
+ if [[ -z "$dir" ]]; then
78
+ zle redisplay
79
+ return 0
80
+ fi
81
+ zle push-line # Clear buffer. Auto-restored on next prompt.
82
+ BUFFER="cd -- ${(q)dir}"
83
+ zle accept-line
84
+ local ret=$?
85
+ unset dir # ensure this doesn't end up appearing in prompt expansion
86
+ zle reset-prompt
87
+ return $ret
88
+ }
89
+ zle -N fzf-cd-widget
90
+ bindkey '\ec' fzf-cd-widget
91
+
92
+ # CTRL-R - Paste the selected command from history into the command line
93
+ fzf-history-widget() {
94
+ local selected num
95
+ setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases 2> /dev/null
96
+ selected=( $(fc -rl 1 | perl -ne 'print if !$seen{(/^\s*[0-9]+\**\s+(.*)/, $1)}++' |
97
+ FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort,ctrl-z:ignore $FZF_CTRL_R_OPTS --query=${(qqq)LBUFFER} +m" $(__fzfcmd)) )
98
+ local ret=$?
99
+ if [ -n "$selected" ]; then
100
+ num=$selected[1]
101
+ if [ -n "$num" ]; then
102
+ zle vi-fetch-history -n $num
103
+ fi
104
+ fi
105
+ zle reset-prompt
106
+ return $ret
107
+ }
108
+ zle -N fzf-history-widget
109
+ bindkey '^R' fzf-history-widget
110
+
111
+ } always {
112
+ eval $__fzf_key_bindings_options
113
+ 'unset' '__fzf_key_bindings_options'
114
+ }
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013-2021 Junegunn Choi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.