mirror of
https://github.com/junegunn/fzf
synced 2026-06-09 10:03:17 +00:00
shell: nushell integration scripts (#4630)
Co-authored-by: imsys <911254+imsys@users.noreply.github.com> Co-authored-by: Grzegorz Zalewski (Greg) <12560152+zalewskigrzegorz@users.noreply.github.com> Co-authored-by: René Jochum <rene@jochum.dev> Co-authored-by: Junegunn Choi <junegunn.c@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
ccedd064ca
commit
290b18d9fe
@@ -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
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
src=${prefix_expand}.${shell}
|
||||
echo -n "Generate $src ... "
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user