mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-13 05:43:48 -05:00
ADD $FZF_DIRECTION
This commit is contained in:
14
CHANGELOG.md
14
CHANGELOG.md
@@ -132,6 +132,20 @@ fzf --gutter ' ' --color gutter:reverse
|
||||
|
||||
As noted above, the `--gutter-raw CHAR` option was also added for customizing the gutter column in raw mode.
|
||||
|
||||
### Added environment variable
|
||||
|
||||
`$FZF_DIRECTION` is now exported to child processes, indicating the list direction of the current layout.
|
||||
|
||||
- `up` for the default layout
|
||||
- `down` for `reverse` or `reverse-list`
|
||||
|
||||
This simplifies writing transform actions involving layout-dependent actions
|
||||
like `{up,down}-match`, `{up,down}-selected`, and `toggle+{up,down}`.
|
||||
|
||||
```sh
|
||||
fzf --raw --bind 'result:first+transform:[[ $FZF_RAW = 0 ]] && echo $FZF_DIRECTION-match'
|
||||
```
|
||||
|
||||
### Breaking changes
|
||||
|
||||
#### Hiding the gutter column
|
||||
|
||||
@@ -1335,6 +1335,8 @@ fzf exports the following environment variables to its child processes.
|
||||
.br
|
||||
.BR FZF_COLUMNS " Number of columns fzf takes up excluding padding and margin"
|
||||
.br
|
||||
.BR FZF_DIRECTION " Direction of the list (\fBup\fR or \fBdown\fR)"
|
||||
.br
|
||||
.BR FZF_TOTAL_COUNT " Total number of items"
|
||||
.br
|
||||
.BR FZF_MATCH_COUNT " Number of matched items"
|
||||
|
||||
@@ -1307,6 +1307,11 @@ func (t *Terminal) environImpl(forPreview bool) []string {
|
||||
env = append(env, "FZF_LIST_LABEL="+t.listLabelOpts.label)
|
||||
env = append(env, "FZF_INPUT_LABEL="+t.inputLabelOpts.label)
|
||||
env = append(env, "FZF_HEADER_LABEL="+t.headerLabelOpts.label)
|
||||
direction := "down"
|
||||
if t.layout == layoutDefault {
|
||||
direction = "up"
|
||||
}
|
||||
env = append(env, "FZF_DIRECTION="+direction)
|
||||
if len(t.nthCurrent) > 0 {
|
||||
env = append(env, "FZF_NTH="+RangesToString(t.nthCurrent))
|
||||
}
|
||||
|
||||
@@ -1682,6 +1682,7 @@ class TestCore < TestInteractive
|
||||
|
||||
tmux.send_keys %(seq 100 | #{FZF} --multi --reverse --preview-window 0 --preview 'env | grep ^FZF_ | sort > #{tempname}' --no-input --bind enter:show-input+refresh-preview,space:disable-search+refresh-preview), :Enter
|
||||
expected = {
|
||||
FZF_DIRECTION: 'down',
|
||||
FZF_TOTAL_COUNT: '100',
|
||||
FZF_MATCH_COUNT: '100',
|
||||
FZF_SELECT_COUNT: '0',
|
||||
|
||||
Reference in New Issue
Block a user