Export FZF_CURRENT_ITEM to child processes (#4803)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Close #4802
authored by Junegunn Choi · committed by GitHub · parent 677e854 · Browse files · 4 files·+9 added−2 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+9 added−2 removed
- tests:+3 added−2 removed
- other:+6 added−0 removed
Provenance
- Commit
de1fca9- Tree
2a82600- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
677e854
4 files changed+9 added−2 removed
modified:man/man1/fzf.1+2 added
1473 unmodified lines1474 .BR FZF_SELECT_COUNT " Number of selected items"1475 .br1476 .BR FZF_POS " Vertical position of the cursor in the list starting from 1"1477 .br1478+.BR FZF_CURRENT_ITEM " Text of the current item (unset if the list is empty)"1479+.br1480 .BR FZF_WRAP " The line wrapping mode (char, word) when enabled"1481 .br1482 .BR FZF_QUERY " Current query string"1483 .br844 unmodified linesmodified:src/terminal.go+3 added
1436 unmodified lines1437 env = append(env, fmt.Sprintf("FZF_SELECT_COUNT=%d", len(t.selected)))1438 env = append(env, fmt.Sprintf("FZF_LINES=%d", t.areaLines))1439 env = append(env, fmt.Sprintf("FZF_COLUMNS=%d", t.areaColumns))1440 env = append(env, fmt.Sprintf("FZF_POS=%d", min(t.merger.Length(), t.cy+1)))1441+ if item := t.currentItem(); item != nil {1442+ env = append(env, "FZF_CURRENT_ITEM="+item.AsString(t.ansi))1443+ }1444 env = append(env, fmt.Sprintf("FZF_CLICK_HEADER_LINE=%d", t.clickHeaderLine))1445 env = append(env, fmt.Sprintf("FZF_CLICK_HEADER_COLUMN=%d", t.clickHeaderColumn))1446 env = append(env, fmt.Sprintf("FZF_CLICK_FOOTER_LINE=%d", t.clickFooterLine))1447 env = append(env, fmt.Sprintf("FZF_CLICK_FOOTER_COLUMN=%d", t.clickFooterColumn))6915 unmodified linesmodified:test/test_core.rb+3 added-2 removed
2284 unmodified lines2285 FZF_SELECT_COUNT: '0',2286 FZF_ACTION: 'start',2287 FZF_KEY: '',2288 FZF_POS: '1',2289+ FZF_CURRENT_ITEM: '1',2290 FZF_QUERY: '',2291 FZF_POINTER: '>',2292 FZF_PROMPT: '> ',2293 FZF_INPUT_STATE: 'hidden'7 unmodified lines2301 assert_equal expected, env_vars.slice(*expected.keys)2302 end2303 tmux.send_keys :Tab, :Tab2304 tmux.until do2304- expected.merge!(FZF_ACTION: 'toggle-down', FZF_KEY: 'tab', FZF_POS: '3', FZF_SELECT_COUNT: '2')2305+ expected.merge!(FZF_ACTION: 'toggle-down', FZF_KEY: 'tab', FZF_POS: '3', FZF_CURRENT_ITEM: '3', FZF_SELECT_COUNT: '2')2306 assert_equal expected, env_vars.slice(*expected.keys)2307 end2308 tmux.send_keys '99'2309 tmux.until do2309- expected.merge!(FZF_ACTION: 'char', FZF_KEY: '9', FZF_QUERY: '99', FZF_MATCH_COUNT: '1', FZF_POS: '1')2310+ expected.merge!(FZF_ACTION: 'char', FZF_KEY: '9', FZF_QUERY: '99', FZF_MATCH_COUNT: '1', FZF_POS: '1', FZF_CURRENT_ITEM: '99')2311 assert_equal expected, env_vars.slice(*expected.keys)2312 end2313 tmux.send_keys :Space2314 tmux.until do470 unmodified linesmodified:CHANGELOG.md+1 added
2 unmodified lines3 4 0.73.05 ------6 - Timer-driven `every(N)` event for `--bind`, where `N` is seconds (fractional, floored to `0.01`). Ticks that overlap an in-flight action are coalesced, so a slow `reload` cannot accumulate a backlog.7+- New `FZF_CURRENT_ITEM` environment variable exported to child processes, holding the text of the current item. Useful on shells where quoting `{}` is awkward (e.g. PowerShell on Windows). Unset when the list is empty (#4802).8 - New `FZF_IDLE_TIME` (whole seconds) and `FZF_IDLE_TIME_MS` (milliseconds) environment variables exported to child processes, holding the elapsed time since the last user activity. Pair with `every(N)` to build idle-based behavior such as auto-accept or auto-quit (#1211).9 ```sh10 # Live process list; --track --id-nth 2 keeps the cursor on the same PID across reloads11 fzf --header-lines 1 --track --id-nth 2 --bind 'start,every(2):reload-sync:ps -ef'3295 unmodified lines