less.sh 590 B

123456789101112131415161718192021222324252627
  1. #!/bin/sh
  2. # Shell script to start Vim with less.vim.
  3. # Read stdin if no arguments were given and stdin was redirected.
  4. if test -t 1; then
  5. if test $# = 0; then
  6. if test -t 0; then
  7. echo "Missing filename" 1>&2
  8. exit
  9. fi
  10. nvim --cmd 'let no_plugin_maps = 1' -c 'runtime! macros/less.vim' -
  11. else
  12. nvim --cmd 'let no_plugin_maps = 1' -c 'runtime! macros/less.vim' "$@"
  13. fi
  14. else
  15. # Output is not a terminal, cat arguments or stdin
  16. if test $# = 0; then
  17. if test -t 0; then
  18. echo "Missing filename" 1>&2
  19. exit
  20. fi
  21. cat
  22. else
  23. cat "$@"
  24. fi
  25. fi