Show xattributes in promptfmt? #2105
-
|
Heya, I'm trying to display some custom xattribuets in the prompt. I've set up the following previewer: #!/usr/bin/env sh
categories=$(getfattr -n user.categories --only-values "$1")
lf -remote "send $id set promptfmt \"%d $f\""
case "$(file -Lb --mime-type -- "$1")" in
text/*)
case "$1" in
*.md)
pandoc -f markdown -t plain "$1"
;;
*)
cat "$1"
;;
esac
;;
esacHowever, I'm noticing that it doesn't seem to correctly update on each file change. It seems like the previews maybe get cached? Am I doing this right? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
The result of the If you want to run something whenever a new file is selected, it is better to define the cmd on-select &{{
# replace the contents of `$(ls -l -d "$f")` with whatever you need
lf -remote "send $id set promptfmt \"$(ls -l -d "$f")\""
}} |
Beta Was this translation helpful? Give feedback.
-
|
Wonderful, this ended up working:
```
cmd on-select &{{
lf -remote "send $id set promptfmt \"%d $(getfattr -n user.categories --only-values "$f")\""
}}
```
Cheers,
Marc
|
Beta Was this translation helpful? Give feedback.
The result of the
previewerscript is cached if it exits successfully (return code of0), so it won't be run again.If you want to run something whenever a new file is selected, it is better to define the
on-selecthook command instead: