gnu: fzf: Use bashrc.d for Bash integration.

fzf comes with two Bash integration files.

The first, completion.bash, enables fzf-powered completion of various
types (files, variable names, processes, etc) for various commands (cat,
export, kill, etc).  This is in contrast with the Bash completions most
packages ship, which are based on the bash-completion package and only
include completions for the package binaries.  The bash-completion
package lazily loads completions from bash_completion.d directories when
the user invokes completion for a given command.  fzf’s completion.bash
shouldn’t be installed to etc/bash_completion.d/fzf, since it doesn’t
depend on bash-completion and it supplies completions for more than just
the fzf binary.  Instead, install it to the more general bashrc.d, where
users can source it so fzf-powered completions are immediately available
for common commands.

The second, key-bindings.bash, provides fzf-based history search for C-r
as well as a couple other convenient bindings. Install it to bashrc.d as
well so users can source it.

* gnu/packages/terminals.scm (fzf): [phases]{install-completions}: Use
bashrc.d for Bash integration files.

Change-Id: Ied0ec1187a04bcc74d39ee22957fc9b4573b5992
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
This commit is contained in:
Liam Hupfer 2025-06-22 12:03:50 -05:00 committed by Sharlatan Hellseher
parent a706e205cf
commit 36dc401bbd
No known key found for this signature in database
GPG key ID: 76D727BFF62CD2B5

View file

@ -44,6 +44,7 @@
;;; Copyright © 2024 Ashvith Shetty <ashvithshetty10@gmail.com>
;;; Copyright © 2024, 2025 Artyom V. Poptsov <poptsov.artyom@gmail.com>
;;; Copyright © 2025 Roman Scherer <roman@burningswell.com>
;;; Copyright © 2025 Liam Hupfer <liam@hpfr.net>
;;;
;;; This file is part of GNU Guix.
;;;
@ -1025,16 +1026,18 @@ minimalistic.")
`("PATH" ":" prefix (,(string-append ncurses "/bin")))))))
(add-after 'install 'install-completions
(lambda* (#:key import-path #:allow-other-keys)
(let* ((bash-completion
(string-append #$output "/etc/bash_completion.d"))
(let* ((bashrc-functions
(string-append #$output "/etc/bashrc.d"))
(fish-functions
(string-append #$output "/share/fish/vendor_functions.d"))
(zsh-completion
(string-append #$output "/share/zsh/site-functions")))
(with-directory-excursion (string-append "src/" import-path)
(mkdir-p bash-completion)
(mkdir-p bashrc-functions)
(copy-file "shell/completion.bash"
(string-append bash-completion "/fzf"))
(string-append bashrc-functions "/fzf-completion.bash"))
(copy-file "shell/key-bindings.bash"
(string-append bashrc-functions "/fzf-bindings.bash"))
(mkdir-p fish-functions)
(copy-file "shell/key-bindings.fish"
(string-append fish-functions "/fzf_key_bindings.fish"))