0.51.0

junegunn/fzf0.51.0May 1, 2024by junegunn

Upgrading?

Release notes summary

Enhanced scripting capabilities with new environment variables for cursor position and last key, a new `--with-shell` option, and a dynamic `change-multi` action.

Key Highlights

  • Added `$FZF_POS` environment variable for the vertical cursor position.
  • Added `--with-shell` option to start child processes with a custom shell command.
  • Added `change-multi` action to dynamically enable or disable multi-select mode.
  • Improved Windows support for the `become` action and fixed argument escaping.

New Features

  • $FZF_POS
  • --with-shell
  • change-multi action

Full Release Notes

- Added a new environment variable `$FZF_POS` exported to the child processes. It's the vertical position of the cursor in the list starting from 1.
  ```sh
  # Toggle selection to the top or to the bottom
  seq 30 | fzf --multi --bind 'load:pos(10)' \
    --bind 'shift-up:transform:for _ in $(seq $FZF_POS $FZF_MATCH_COUNT); do echo -n +toggle+up; done' \
    --bind 'shift-down:transform:for _ in $(seq 1 $FZF_POS); do echo -n +toggle+down; done'
  ```
- Added `--with-shell` option to start child processes with a custom shell command and flags
  ```sh
  gem list | fzf --with-shell 'ruby -e' \
    --preview 'pp Gem::Specification.find_by_name({1})' \
    --bind 'ctrl-o:execute-silent:
        spec = Gem::Specification.find_by_name({1})
        [spec.homepage, *spec.metadata.filter { _1.end_with?("uri") }.values].uniq.each do
          system "open", _1
        end
    '
  ```
- Added `change-multi` action for dynamically changing `--multi` option
    - `change-multi` - enable multi-select mode with no limit
    - `change-multi(NUM)` - enable multi-select mode with a limit
    - `change-multi(0)` - disable multi-select mode
- Windows improvements
    - `become` action is now supported on Windows
        - Unlike in *nix, this does not use `execve(2)`. Instead it spawns a new process and waits for it to finish, so the exact behavior may differ.
    - Fixed argument escaping for Windows cmd.exe. No redundant escaping of backslashes.
- Bug fixes and improvements

Related Repositories