
Is your feature request related to a problem? Please describe.
The $FILTER environment variable will return the current filter the user has applied, but when no filter is applied it will default to returning to the current hovered item. A plugin is not able to know if something was searched for, which makes plugin logic like this not really possible:
plugins:
my-plugin:
shortCut: Shift-E
description: My plugin
scopes:
- all
background: true
command: bash
args:
- -c
- |
if [[ -n "$FILTER" ]]; then
kubectl get $RESOURCE_NAME --context $CONTEXT | sed -n "1p; /^$FILTER/p" #....
fi;
Describe the solution you'd like
A way for plugins to know whether a filter is actually active. To avoid breaking backwards compatibility, two options could be:
- A new env var like
$FILTER_APPLIED=true/false
- A new env var like
$RAW_FILTER that contains command buffer text (empty when no filter is active)
Another option is of course to leave $FILTER empty but I'm not sure about the implications of this change. I think that if you need to know the current resource name, its best to use $NAME anyways.
This would let plugins pass the filter to grep/kubectl for more customized searches.
Describe alternatives you've considered
Comparing $FILTER to $NAME to detect the fallback case, it can work but its ambiguous as the plugin might draw the wrong conclusion.
Additional context
The fallback happens in internal/view/table
env["FILTER"] = t.CmdBuff().GetText()
if env["FILTER"] == "" {
env["NAMESPACE"], env["FILTER"] = client.Namespaced(path)
}
And in internal/view/xray.go
env["FILTER"] = x.CmdBuff().GetText()
if env["FILTER"] == "" {
ns, n := client.Namespaced(spec.Path())
env["NAMESPACE"], env["FILTER"] = ns, n
}
I'm happy to make a PR for this
Is your feature request related to a problem? Please describe.
The
$FILTERenvironment variable will return the current filter the user has applied, but when no filter is applied it will default to returning to the current hovered item. A plugin is not able to know if something was searched for, which makes plugin logic like this not really possible:Describe the solution you'd like
A way for plugins to know whether a filter is actually active. To avoid breaking backwards compatibility, two options could be:
$FILTER_APPLIED=true/false$RAW_FILTERthat contains command buffer text (empty when no filter is active)Another option is of course to leave
$FILTERempty but I'm not sure about the implications of this change. I think that if you need to know the current resource name, its best to use$NAMEanyways.This would let plugins pass the filter to grep/kubectl for more customized searches.
Describe alternatives you've considered
Comparing $FILTER to $NAME to detect the fallback case, it can work but its ambiguous as the plugin might draw the wrong conclusion.
Additional context
The fallback happens in
internal/view/tableAnd in
internal/view/xray.goI'm happy to make a PR for this