3 # runs the less command but with some additional options.
5 # we always pass the raw flag (-r) so our special formatting is not lost.
6 # this may not be the best choice for some text terminals.
8 # there is also a "code" option added (-c) that formats the incoming data as
9 # if it were source code before showing the output. this works great on files
10 # that are actually recognized as source code, and not so great on other
11 # things like simple lists or error output.
14 local code_view_flag="$1"
15 if [ "$code_view_flag" == "-c" ]; then
16 # saw the 'code' flag, which means show the file with source highlighting.
19 # drop the value and emptiness will mean don't show code.
23 if [ ! -z "$code_view_flag" ]; then
24 # establish a pipe for less to see our beloved syntax highlighting.
25 export LESSOPEN="| source-highlight -f esc -o STDOUT -i %s"
29 # run the source highlighter first if needed.
35 # now that we have our function, just use it on all the input parameters.
36 # this is done to avoid adding yet another function to the core.