Open tapyu opened 6 months ago
You can try a workaround for the same result
% sed
# Print a specific line from a file
sed -n <number>p <file>
$ file: find . -maxdepth 1 -type f | cut -c3-
$ number: aux=$(wc -l <file> | cut -f 1) && echo "This file contains $aux pages" --- --header-lines 1
Small correction, it should be aux=$(wc -l <file> | cut -d ' ' -f 1)
, we need to define the delimiter.
Anyway, that is a good workaround, but it is a workaround. I would be great to make fzf
option aware of both shell-defined variables (e.g., $aux
) and navi-defined variables (e.g., <file>
), so that one can write something like
% sed
# Print a specific line from a file
sed -n <number>p <file>
$ file: find . -maxdepth 1 -type f | cut -c3-
$ number: export aux=$(wc -l <file> | cut -d ' ' -f 1) --- --header "The file <file> contains $aux pages "
No workarounds, no tricks, no complications.
Consider another example
# add submodule
git submodule add <is_branch>
$ is_branch: echo "" --- --map "grep -Pq '.+' && echo 'branch=<is_branch>'" --header "are you adding submodule from a specific branch? Type the branch name if yes, or leave empty if no."
I want to create an optional example. If I write something, I must append --branch=
to the written argument. Your workaround doesn't work here.
The solution would be
# add submodule
git submodule add <prefix><is_branch>
$ is_branch: echo "" --- --header "are you adding submodule from a specific branch? Type the branch name if yes, or leave empty if no."
$ prefix: [[ -n $(echo <is_branch>) ]] && echo '--branch=' || echo '' --- --fzf-overrides '-1'
Again, a functional but ugly workaround. It would be much better to be able to write former solution.
Is your feature request related to a problem? Please describe. Let us consider that I want to create a navi cheat sheet to print a line of a file using
sed
.Describe the solution you'd like My idea is that the
aux
variable becomes available tofzf
so that it prints out a header likeDescribe alternatives you've considered I tried some syntax such as
<file>
,$file
, etc. But it seems thatfzf
is insensitive to any variable declared bynavi
.