Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
5aa22d4
A Nushell partial support test
imsys May 4, 2025
79eab96
Some efforts to get it working
imsys May 4, 2025
64d5ace
Almost working
imsys May 4, 2025
6011574
somewhat working
imsys May 4, 2025
785bc07
seems to be working
imsys May 4, 2025
30d1d45
lower case tab
imsys May 4, 2025
a4ef417
different implementation approach: External Completers
imsys May 4, 2025
5236752
fixes fzf custom height
imsys May 5, 2025
4b8fef0
Nushell - fzf uses realative path
imsys May 5, 2025
3bd895c
nushell - layout reverse
imsys May 5, 2025
15314f4
nushell: fixes ssh completion
imsys May 5, 2025
b2b25b2
Nushell: refactoring
imsys May 6, 2025
e4ceecb
Nushell: makes the code of both options similar.
imsys May 6, 2025
3e0d3a8
removing debug print
imsys May 6, 2025
da97e61
Nushell: seems to be the final fix for path issues
imsys May 6, 2025
20bb07c
cleanup and kill completion
imsys May 6, 2025
c39e328
Nushell: prepend binding instead of appending
imsys May 7, 2025
bde90bc
Nushell: Another alternative implementation, but using nushell menu
imsys May 7, 2025
456cf2a
Nushell: notes
imsys May 7, 2025
6289a28
renames completion.nu to completion-bind.nu
imsys May 7, 2025
77d0b56
Nushell: notes
imsys May 7, 2025
d1a6120
Nushell: minor grammar/spelling
imsys May 7, 2025
1f66d6e
fix typo
zalewskigrzegorz Jul 8, 2025
7ec4d98
completion-external: add pass completion
sim590 Dec 7, 2025
95f636f
completion-external: use type "any" for optional closure
sim590 Dec 7, 2025
e9ac742
completion-external: use flag for _fzf_complete_nu's post_process_clo…
sim590 Dec 7, 2025
8c2183d
completion-external: remove bad "return" calls
sim590 Dec 7, 2025
90d2331
completion-external: remove unused input_line_before_trigger parameter
sim590 Dec 7, 2025
ef66bd7
completion-external: fix alignement
sim590 Dec 7, 2025
535ff16
Merge pull request #1 from zalewskigrzegorz/fix/nushel-scipt-typo
imsys Dec 8, 2025
581e2b3
Merge pull request #4 from sim590/nushell-remove-bad-return-calls
imsys Dec 8, 2025
5bee4c5
Merge pull request #3 from sim590/nushell-completion-fix-empty-closure
imsys Dec 8, 2025
b3d751e
compatibility with the other pull request.
imsys Dec 8, 2025
5ff54eb
Merge pull request #2 from sim590/nushell-completion-pass
imsys Dec 8, 2025
40094b7
shell/completion-external.nu: just some alignment
sim590 Dec 8, 2025
fc23c6e
Merge pull request #5 from sim590/nushell-completion-some-alignment
imsys Dec 8, 2025
f4f73a2
shell: keeping keybindings and external impl
sim590 Dec 9, 2025
8c6c0e2
shell/key-bindings.nu: enhance ctrlr
sim590 Dec 9, 2025
b0608cb
shell/key-bindings.nu: make CTRL_R opts overridable by FZF_CTRL_R_OPTS
sim590 Dec 9, 2025
c834dd1
shell/key-bindings.nu: rm mention of unused rg, nufmt commands
sim590 Dec 9, 2025
10bc522
shell/key-bindings.nu: uniformisation of command variable names
sim590 Dec 9, 2025
7ab8d25
shell/key-bindings.nu: separating necessary options from others
sim590 Dec 9, 2025
032bde7
shell/key-bindings.nu: keep full screen
sim590 Dec 9, 2025
5742835
shell/completion.nu: disable export, printenv, unset, unalias
sim590 Dec 9, 2025
55de1bf
shell/completion.nu: fix _fzf_complete_nu when `-m` is passed
sim590 Dec 9, 2025
4f10ad7
shell/completion.nu: disable `-m` for pass completion
sim590 Dec 9, 2025
e3fa04b
shell/completion-external.nu: pacman completion
sim590 Dec 8, 2025
2c9234c
shell/key-bindings.nu: make env variables overridable
sim590 Dec 9, 2025
a8aaf42
refactor(nushell): use fzf built-in walker instead of fd
sim590 Apr 18, 2026
77f28e4
feat(nushell): add missing CTRL-R options for parity with bash/zsh
sim590 Apr 18, 2026
f624009
feat(nushell): merge FZF_DEFAULT_OPTS and FZF_DEFAULT_OPTS_FILE
sim590 Apr 19, 2026
54aa577
feat(nushell): add fzf-tmux support in key bindings
sim590 Apr 19, 2026
bf9eb9e
fix(nushell): handle inherited env var type for __keybindings_loaded
sim590 Apr 19, 2026
c596a06
feat(nushell): allow disabling key bindings via empty variable
sim590 Apr 19, 2026
557e5e7
refactor(nushell): document completion extensibility pattern
sim590 Apr 19, 2026
97529ab
perf(nushell): replace slow help commands with which
sim590 Apr 19, 2026
03a14e1
fix(nushell): prevent ps from blocking in kill completion
sim590 Apr 19, 2026
828b782
fix(nushell): replace commandline content on CTRL-R selection
sim590 Apr 19, 2026
a55fc6f
refactor(nushell): remove unused closure in pacman completion
sim590 Apr 19, 2026
4012253
fix(nushell): use split row instead of split words for fzf options
sim590 Apr 19, 2026
12aa334
fix(nushell): use closure syntax in where filter for empty strings
sim590 Apr 19, 2026
0ad7787
fix(nushell): use split row instead of split column for ssh host parsing
sim590 Apr 19, 2026
969327b
fix(nushell): correct filename in header comment
sim590 Apr 19, 2026
1174f3d
refactor(nushell): remove unused variable and stale comment
sim590 Apr 19, 2026
58cce52
refactor(nushell): remove dead code in path completion
sim590 Apr 19, 2026
ed241f1
refactor(nushell): use FZF_COMPLETION_DIR_COMMANDS in dispatch
sim590 Apr 19, 2026
cea66b2
perf(nushell): use pacman -Slq/-Qq for faster package listing
sim590 Apr 19, 2026
28d154b
refactor(nushell): remove redundant FZF_TMUX env assignments
sim590 Apr 19, 2026
3868e40
feat(nushell): add --nushell flag to emit shell integration scripts
sim590 Apr 19, 2026
1761e10
feat(nushell): add nushell support to install/uninstall scripts
sim590 Apr 19, 2026
f23d70f
docs: add Nushell to README
sim590 Apr 19, 2026
df702d0
test(nushell): add shell integration test scaffolding
sim590 Apr 19, 2026
b2650de
fix(nushell): use sh -c instead of nu -c for CTRL-T and ALT-C
sim590 Apr 19, 2026
5836bc6
test(nushell): fix initialization, prepare, and add keybinding tests
sim590 Apr 19, 2026
3bf3bfc
fix(test): clear nushell history between tests
sim590 Apr 19, 2026
5f68a8b
refactor(nushell): remove unused export/unset/unalias completion
sim590 Apr 19, 2026
10787b8
feat(nushell): add sudo support, paru, and pacman preview
sim590 Apr 20, 2026
2efe7b8
Merge origin/master into nushell-integration
sim590 Apr 20, 2026
196a148
todo.txt: removed
sim590 Apr 20, 2026
37c86f0
docs: move Nushell completion to dedicated section and remove debug file
sim590 Apr 20, 2026
732c1e8
chore: remove .bundle/config from tracking
sim590 Apr 20, 2026
8d405a7
fix(nushell): remove unused var, fix typos, and guard empty cd result
sim590 Apr 21, 2026
8963f38
test(nushell): add file completion smoke test
sim590 Apr 21, 2026
17b194e
fix: restore missing src assignment in install and fix let syntax
sim590 Apr 21, 2026
f3f904c
fix(ci): add Slq to typos exceptions
sim590 Apr 21, 2026
0ec52ca
ci: install nushell via apt in GitHub Actions
sim590 Apr 21, 2026
452d42e
fix(test): rubocop fixes and safe teardown for nushell tests
sim590 Apr 21, 2026
95a0ff5
Merge branch 'master' into nushell-integration
sim590 Apr 21, 2026
691dfa3
docs: rewrite nushell setup to use native syntax
sim590 Apr 22, 2026
305a650
docs: remove --nushell from version note
sim590 Apr 22, 2026
adbd8e7
docs: simplify version note and create autoload dir
sim590 Apr 23, 2026
a56922c
docs: add nushell example for disabling keybindings
sim590 Apr 23, 2026
8057be9
fix(nushell): handle missing password store in pass completion
sim590 Apr 23, 2026
e127c4e
fix(nushell): join multi-selected paths into single completion result
sim590 Apr 23, 2026
95416c8
fix(nushell): clear FZF_DEFAULT_OPTS when calling fzf in completer
sim590 Apr 23, 2026
0025d22
fix(completion): align __fzf_defaults_nu with bash for --tmux support
sim590 Apr 23, 2026
ddf7025
fix(readme): use -- instead of em dash for Nushell bullet
sim590 Apr 23, 2026
1901af7
refactor(test): remove redundant test_ctrl_t and test_alt_c_command
sim590 Apr 23, 2026
3c1bfb6
refactor(test): remove redundant test_ctrl_r, document overrides
sim590 Apr 24, 2026
b4e1992
fix(completion): expand tilde in walker-root for path completion
sim590 Apr 24, 2026
6f1ed5a
fix(test): replace em-dash with ASCII double dash
sim590 Apr 24, 2026
4ec77b9
test(nushell): add multi-selection and hidden files to test_file_comp…
sim590 Apr 24, 2026
73e3ecb
fix(completion): use $nu.home-dir instead of $nu.home-path
sim590 Apr 25, 2026
85cd042
feat(completion): add $env.FZF_COMPLETERS for custom completers
sim590 Apr 25, 2026
450f0b5
fix(completion): remove leftover debug log
sim590 Apr 27, 2026
ba6dea5
style(completion): remove unnecessary empty line
sim590 Apr 27, 2026
4d81f66
refactor(completion): uncomment examples and remove combined section
sim590 Apr 27, 2026
673f979
feat(completion): expose post-processing hook in FZF_COMPLETERS
sim590 Apr 27, 2026
29d3018
docs(key-bindings): explain why reverse | uniq is safe
sim590 Apr 27, 2026
63c7e34
fix(key-bindings): check all fzf bindings to prevent duplicates
sim590 Apr 27, 2026
4837286
style(completion): remove trailing empty line after modeline
sim590 Apr 27, 2026
08a2ec1
refactor(key-bindings): replace duplicates guard with filter-and-append
sim590 Apr 29, 2026
76af275
refactor(completion): remove unused code and outdated comments
sim590 Apr 29, 2026
8b4d29c
Apply rewording of comment on $env.history from @junegunn
sim590 May 4, 2026
8632148
fix(completion): use open --raw for FZF_DEFAULT_OPTS_FILE
sim590 May 4, 2026
a96feb6
fix(completion): harmonize TMUX_PANE check with key-bindings.nu
sim590 May 4, 2026
76bcb97
refactor(completion): remove _nu suffix from function names
sim590 May 4, 2026
0b1d82e
fix(completion): prevent wrapper nesting on re-source
sim590 May 4, 2026
41af912
test: replace sleep with polling for nushell readiness
sim590 May 4, 2026
22c1fb1
fixup! test: replace sleep with polling for nushell readiness
sim590 May 4, 2026
6485735
refactor(completion): harmonize __fzf_defaults with key-bindings.nu
sim590 May 5, 2026
7bf47c7
fix(completion): allow re-sourcing to update the completer
sim590 May 6, 2026
9c4d392
style(completion): fix some code alignment
sim590 May 6, 2026
bae407b
Apply copilot suggestion for /etc/apt/keyrings
sim590 May 7, 2026
9bf1b8a
fix(install): respect --[no-]key-bindings and --[no-]completion for n…
sim590 May 10, 2026
a6fb102
fix(install): rename fzf.nu to _fzf_integration.nu, simplify partial cp
sim590 May 12, 2026
37d83c1
fix(uninstall): rename fzf.nu to _fzf_integration.nu
sim590 May 12, 2026
52a23e3
docs(man): add --nushell flag to man page
sim590 May 13, 2026
d25f3da
Merge branch 'master' into nushell-integration
junegunn May 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ jobs:
ruby-version: 3.4.6

- name: Install packages
run: sudo apt-get install --yes zsh fish tmux shfmt
run: |
Comment thread
sim590 marked this conversation as resolved.
sudo install -d -m 0755 /etc/apt/keyrings
wget -qO- https://apt.fury.io/nushell/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/fury-nushell.gpg
echo "deb [signed-by=/etc/apt/keyrings/fury-nushell.gpg] https://apt.fury.io/nushell/ /" | sudo tee /etc/apt/sources.list.d/fury-nushell.list
sudo apt-get update
sudo apt-get install --yes zsh fish tmux shfmt nushell

- name: Install Ruby gems
run: bundle install
Expand Down
52 changes: 47 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Highlights
- **Portable** -- Distributed as a single binary for easy installation
- **Fast** -- Optimized to process millions of items instantly
- **Versatile** -- Fully customizable through an event-action binding mechanism
- **All-inclusive** -- Comes with integrations for Bash, Zsh, Fish, Vim, and Neovim
- **All-inclusive** -- Comes with integrations for Bash, Zsh, Fish, Nushell, Vim, and Neovim

Table of Contents
-----------------
Expand Down Expand Up @@ -81,6 +81,7 @@ Table of Contents
* [Supported commands (bash)](#supported-commands-bash)
* [Custom fuzzy completion](#custom-fuzzy-completion)
* [Fuzzy completion for fish](#fuzzy-completion-for-fish)
* [Fuzzy completion for Nushell](#fuzzy-completion-for-nushell)
* [Vim plugin](#vim-plugin)
* [Advanced topics](#advanced-topics)
* [Customizing for different types of input](#customizing-for-different-types-of-input)
Expand Down Expand Up @@ -210,10 +211,18 @@ Add the following line to your shell configuration file.
# Set up fzf key bindings
fzf --fish | source
```
* Nushell -- Nushell does not support piping into `source`, so the install
script generates a file in the autoload directory. If you didn't use the
install script, you can manually set it up:
```nu
# Generate the integration script
mkdir ($nu.default-config-dir | path join "autoload")
fzf --nushell | save -f ($nu.default-config-dir | path join "autoload" "_fzf_integration.nu")
```

> [!NOTE]
> `--bash`, `--zsh`, and `--fish` options are only available in fzf 0.48.0 or
> later. If you have an older version of fzf, or want finer control, you can
> `--bash`, `--zsh`, `--fish`, and `--nushell` options are only available in
> recent versions of fzf. If you have an older version of fzf, or want finer control, you can
> source individual script files in the [/shell](/shell) directory. The
> location of the files may vary depending on the package manager you use.
> Please refer to the package documentation for more information.
Expand All @@ -227,6 +236,8 @@ Add the following line to your shell configuration file.
> * bash: `FZF_CTRL_R_COMMAND= FZF_ALT_C_COMMAND= eval "$(fzf --bash)"`
> * zsh: `FZF_CTRL_R_COMMAND= FZF_ALT_C_COMMAND= source <(fzf --zsh)`
> * fish: `fzf --fish | FZF_CTRL_R_COMMAND= FZF_ALT_C_COMMAND= source`
> * nushell: add to your `env.nu`:
> `$env.FZF_CTRL_R_COMMAND = ""; $env.FZF_ALT_C_COMMAND = ""`
>
> Setting the variables after sourcing the script will have no effect.

Expand Down Expand Up @@ -506,7 +517,7 @@ Key bindings for command-line
-----------------------------

By [setting up shell integration](#setting-up-shell-integration), you can use
the following key bindings in bash, zsh, and fish.
the following key bindings in bash, zsh, fish, and Nushell.

- `CTRL-T` - Paste the selected files and directories onto the command-line
- The list is generated using `--walker file,dir,follow,hidden` option
Expand Down Expand Up @@ -574,7 +585,7 @@ More tips can be found on [the wiki page](https://github.com/junegunn/fzf/wiki/C
Fuzzy completion
----------------

Shell integration also provides fuzzy completion for bash, zsh, and fish.
Shell integration also provides fuzzy completion for bash, zsh, fish, and Nushell.

### Files and directories

Expand Down Expand Up @@ -823,6 +834,37 @@ function _fzf_post_complete_foo
end
```

### Fuzzy completion for Nushell

Fuzzy completion in Nushell works via the
[external completer](https://www.nushell.sh/cookbook/external_completers.html)
mechanism. There are some differences compared to bash and zsh:

- On Nushell >= 0.103.0, the external completer is no longer called for
built-in commands (e.g. `cd`, `ls`). Fuzzy completion with `**<TAB>` only
works for external commands.
- Custom completers can be defined via the `$env.FZF_COMPLETERS` record in
your `config.nu`. Each entry is a closure that receives the prefix and the
command spans, and returns either a list of candidate strings or a record
`{ candidates: [...], opts: [...] }` for custom fzf options:
```nu
$env.FZF_COMPLETERS = {
pacman: {|prefix, spans|
let sub = $spans | skip 1 | first
let candidates = (if ($sub =~ "-[SF]") { ^pacman -Slq | lines
} else if ($sub =~ "-[QR]") { ^pacman -Qq | lines
} else { [] })
{ candidates: $candidates, opts: ["--preview", "pacman -Si {}"] }
}
}
```
See [shell/completion-examples.nu](shell/completion-examples.nu) for more
examples.
- The following environment variables are supported:
`FZF_COMPLETION_TRIGGER`, `FZF_COMPLETION_OPTS`,
`FZF_COMPLETION_PATH_OPTS`, `FZF_COMPLETION_DIR_OPTS`,
`FZF_COMPLETION_DIR_COMMANDS`.

Vim plugin
----------

Expand Down
29 changes: 27 additions & 2 deletions install
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ version=0.72.0
auto_completion=
key_bindings=
update_config=2
shells="bash zsh fish"
shells="bash zsh fish nushell"
prefix='~/.fzf'
prefix_expand=~/.fzf
fish_dir=${XDG_CONFIG_HOME:-$HOME/.config}/fish
nushell_autoload_dir=${XDG_CONFIG_HOME:-$HOME/.config}/nushell/autoload

help() {
cat << EOF
Expand All @@ -27,6 +28,7 @@ usage: $0 [OPTIONS]
--no-bash Do not set up bash configuration
--no-zsh Do not set up zsh configuration
--no-fish Do not set up fish configuration
--no-nushell Do not set up nushell configuration
EOF
}

Expand Down Expand Up @@ -56,6 +58,7 @@ for opt in "$@"; do
--no-bash) shells=${shells/bash/} ;;
--no-zsh) shells=${shells/zsh/} ;;
--no-fish) shells=${shells/fish/} ;;
--no-nushell) shells=${shells/nushell/} ;;
*)
echo "unknown option: $opt"
help
Expand Down Expand Up @@ -224,7 +227,9 @@ fi
[[ $* =~ "--bin" ]] && exit 0

for s in $shells; do
if ! command -v "$s" > /dev/null; then
bin=$s
[[ "$s" = nushell ]] && bin=nu
if ! command -v "$bin" > /dev/null; then
shells=${shells/$s/}
fi
done
Expand All @@ -251,6 +256,7 @@ for shell in $shells; do
fzf_completion="source \"$fzf_base/shell/completion.${shell}\""
fzf_key_bindings="source \"$fzf_base/shell/key-bindings.${shell}\""
[[ $shell == fish ]] && continue
[[ $shell == nushell ]] && continue
Comment thread
junegunn marked this conversation as resolved.
src=${prefix_expand}.${shell}
echo -n "Generate $src ... "

Expand Down Expand Up @@ -368,6 +374,7 @@ fi
echo
for shell in $shells; do
[[ $shell == fish ]] && continue
[[ $shell == nushell ]] && continue
[ $shell = zsh ] && dest=${ZDOTDIR:-~}/.zshrc || dest=~/.bashrc
append_line $update_config "[ -f ${prefix}.${shell} ] && source ${prefix}.${shell}" "$dest" "${prefix}.${shell}"
done
Expand Down Expand Up @@ -436,6 +443,23 @@ if [[ $shells =~ fish ]]; then
fi
fi

if [[ "$shells" =~ nushell ]]; then
if [[ $key_bindings -eq 1 || $auto_completion -eq 1 ]]; then
echo "Setting up Nushell integration ..."
mkdir -p "$nushell_autoload_dir"
echo -n " Generate _fzf_integration.nu ... "
if [[ $key_bindings -eq 1 && $auto_completion -eq 1 ]]; then
"$fzf_base"/bin/fzf --nushell > "$nushell_autoload_dir/_fzf_integration.nu"
elif [[ $key_bindings -eq 1 ]]; then
cp "$fzf_base/shell/key-bindings.nu" "$nushell_autoload_dir/_fzf_integration.nu"
else
cp "$fzf_base/shell/completion.nu" "$nushell_autoload_dir/_fzf_integration.nu"
fi
echo "OK"
echo
fi
fi

if [ $update_config -eq 1 ]; then
echo 'Finished. Restart your shell or reload config file.'
if [[ $shells =~ bash ]]; then
Expand All @@ -445,6 +469,7 @@ if [ $update_config -eq 1 ]; then
fi
[[ $shells =~ zsh ]] && echo " source ${ZDOTDIR:-~}/.zshrc # zsh"
[[ $shells =~ fish && $lno_func -ne 0 ]] && echo ' fish_user_key_bindings # fish'
[[ $shells =~ nushell ]] && echo ' # nushell: files are loaded automatically from autoload directory'
echo
echo 'Use uninstall script to remove fzf.'
echo
Expand Down
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ var zshCompletion []byte
//go:embed shell/key-bindings.fish
var fishKeyBindings []byte

//go:embed shell/key-bindings.nu
var nushellKeyBindings []byte

//go:embed shell/completion.nu
var nushellCompletion []byte

//go:embed shell/completion.fish
var fishCompletion []byte

Expand Down Expand Up @@ -71,6 +77,11 @@ func main() {
printScript("completion.fish", fishCompletion)
return
}
if options.Nushell {
printScript("key-bindings.nu", nushellKeyBindings)
printScript("completion.nu", nushellCompletion)
return
}
if options.Help {
fmt.Print(fzf.Usage)
return
Expand Down
6 changes: 6 additions & 0 deletions man/man1/fzf.1
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,12 @@ Print script to set up Fish shell integration

e.g. \fBfzf \-\-fish | source\fR

.TP
.B "\-\-nushell"
Print script to set up Nushell shell integration

e.g. \fBfzf \-\-nushell | save \-f ~/.config/nushell/autoload/_fzf_integration.nu\fR

.SS OTHERS
.TP
.B "\-\-no\-mouse"
Expand Down
91 changes: 91 additions & 0 deletions shell/completion-examples.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# ____ ____
# / __/___ / __/
# / /_/_ / / /_
# / __/ / /_/ __/
# /_/ /___/_/ completion-examples.nu
#
# Example custom completers for fzf's Nushell integration.
#
# To use these, add the desired entries to $env.FZF_COMPLETERS in your
# config.nu. Each closure receives two arguments:
# - prefix: the text before the trigger (e.g. "vim" in "vim **<TAB>")
# - spans: the full command as a list of words (e.g. ["pacman", "-S", "vim**"])
#
# A closure can return either:
# - a list of candidate strings (fzf will use default options), or
# - a record with the following optional fields:
# candidates: list<string> # candidates to feed to fzf
# opts: list<string> # custom fzf options (default: ["-m"])
# post: closure (|sel| ...) # post-processing of the selected item
#
# Simple example:
# $env.FZF_COMPLETERS = {
# git: {|prefix, spans| ["branch-main", "branch-dev", "branch-feature"]}
# }

# --- pacman / paru ---
# Completes package names for pacman and paru.
# Uses the spans to distinguish between subcommands:
# -S (sync), -F (files): list available packages from repos
# -Q (query), -R (remove): list installed packages
# Returns a record with custom fzf options for package preview.

$env.FZF_COMPLETERS = {}

$env.FZF_COMPLETERS.pacman = {|prefix, spans|
let sub = $spans | skip 1 | first
let candidates = (if ($sub =~ "-[SF]") {
^pacman -Slq | lines
} else if ($sub =~ "-[QR]") {
^pacman -Qq | lines
} else {
[]
})
{
candidates: $candidates
opts: ["-m", "--preview", "pacman -Si {}", "--prompt", "Package > "]
}
}

$env.FZF_COMPLETERS.paru = {|prefix, spans|
let sub = $spans | skip 1 | first
let candidates = (if ($sub =~ "-[SF]") {
^pacman -Slq | lines
} else if ($sub =~ "-[QR]") {
^pacman -Qq | lines
} else {
[]
})
{
candidates: $candidates
opts: ["-m", "--preview", "pacman -Si {}", "--prompt", "Package > "]
}
}

# --- pass (password-store) ---
# Completes entry names from ~/.password-store.
# Returns a simple list (no custom fzf options needed).

$env.FZF_COMPLETERS.pass = {|prefix, spans|
try {
ls ~/.password-store/**/*.gpg
| get name
| each {$in | str replace -r '^.*?\.password-store/(.*).gpg' '${1}'}
} catch {
[]
}
}

# --- Example with post-processing hook ---
# The "post" closure transforms the selected line after fzf returns.
# This is useful when the displayed line contains more information than
# what you want inserted on the command line (e.g. extracting a PID from
# a full "ps" output line).
#
# $env.FZF_COMPLETERS.mycommand = {|prefix, spans|
# {
# candidates: (^some-command | lines)
# opts: ["+m", "--header-lines=1"]
# post: {|selection| $selection | split row ' ' | get 0}
# }
# }
Loading
Loading