__fzf_complete_preview.fish 893 B

1234567891011121314151617181920212223242526272829
  1. function __fzf_complete_preview -d 'generate preview for completion widget.
  2. argv[1] is the currently selected candidate in fzf
  3. argv[2] is a string containing the rest of the output produced by `complete -Ccmd`
  4. '
  5. if test "$argv[2]" = "Redefine variable"
  6. # show environment variables current value
  7. set -l evar (echo $argv[1] | cut -d= -f1)
  8. echo $argv[1]$$evar
  9. else
  10. echo $argv[1]
  11. end
  12. # list directories on preview
  13. if test -d "$argv[1]"
  14. eval $FZF_PREVIEW_DIR_CMD (string escape $argv[1])
  15. end
  16. # show ten lines of non-binary files preview
  17. if test -f "$argv[1]"; and grep -qI . "$argv[1]"
  18. eval $FZF_PREVIEW_FILE_CMD (string escape $argv[1])
  19. end
  20. # if fish knows about it, let it show info
  21. type -q "$argv[1]" 2>/dev/null; and type -a "$argv[1]"
  22. # show aditional data
  23. echo $argv[2]
  24. end