Hello.
I have been wanting to just have some simple commands with FZF and Ripgrep.
I’m running into the issue of FZF coming up with 0 results for this command.
define-command -params 0..2 -file-completion \
-docstring "Find and edit files with fzf. You can also pass a UNIX glob." \
files %{
evaluate-commands %sh{
glob="$1"
dir="$2"
if [ -z "${kak_client_env_TMUX}" ]; then
printf 'fail "Client was not started under tmux"\n'
else
if [ -z "$glob" ]; then
cmd=rg --files --hidden --no-heading --column --color=auto --smart-case
else
cmd=rg --files --hidden --no-heading --column --color=auto --glob "$glob" --smart-case
fi
if [ -n "$dir" ]; then
file=$("$cmd" "$dir" | \
TMUX="${kak_client_env_TMUX}" \
fzf-tmux --height=30% --reverse --ansi)
else
file=$("$cmd" "$PWD" | \
TMUX="${kak_client_env_TMUX}" \
fzf-tmux --height=30% --reverse --ansi)
fi
if [ -n $file ]; then
printf 'edit "%s"\n' "$file"
fi
fi
}
}
And how I would call it is say to look at my Kakoune config directory without the plugins/
directory: :files "!.config/kak/plugins/**" ~/.config/kak
.
Now the does this just from the command line with
rg --files --hidden --no-heading --column --color=auto --glob "!.config/kak/plugins/**" ~/.config/kak | fzf --reverse --height=30% --ansi
Works fine.
And the example from the Github wiki works fine as well.
All I want is to use this with either 0 to 2 arguments, and those two arguments to be a glob and/or a path to a directory.
Another reason I’m posting this is probably because you all could probably help me make it less sloppy.