From: Chris Koeritz Date: Sun, 9 Oct 2016 17:16:31 +0000 (-0400) Subject: variety of fixes and a new script X-Git-Tag: 2.140.90~376 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=9dd72bf7c3c75823ba325948fb7b1089ab18b8ec;p=feisty_meow.git variety of fixes and a new script unpack gets to know a txz extension that is being erroneously created by chrome. i can either resist the tide or just add this as a type of compressed (or maybe even uncompressed) tar, so i added it. aliases for less, mo, more, etc get fixated to an actual function now. otherwise the machinery being added gets too cumbersome. new script is lesser which just runs less. it supports a code option as -c if you want source highlighting. variables get LESSOPEN taken away because not every file can be highlighted as source. oh well. --- diff --git a/scripts/archival/unpack.sh b/scripts/archival/unpack.sh index e420f4e4..8053c898 100644 --- a/scripts/archival/unpack.sh +++ b/scripts/archival/unpack.sh @@ -65,6 +65,7 @@ if [[ "$archive_file" =~ .*\.tar$ \ || "$archive_file" =~ .*\.iar$ \ || "$archive_file" =~ .*\.oar$ \ || "$archive_file" =~ .*\.tgz$ \ + || "$archive_file" =~ .*\.txz$ \ || "$archive_file" =~ .*\.ova$ \ || "$archive_file" =~ .*\.snarf$ \ ]]; then diff --git a/scripts/core/common.alias b/scripts/core/common.alias index 5e0d1209..2114d4b0 100644 --- a/scripts/core/common.alias +++ b/scripts/core/common.alias @@ -61,7 +61,7 @@ define_yeti_alias whence=which define_yeti_alias less='lesser' define_yeti_alias mo='lesser' define_yeti_alias more='lesser' -define_yeti_alias lesser='/bin/less -r' +define_yeti_alias lesser='bash $FEISTY_MEOW_SCRIPTS/files/lesser.sh' ############## diff --git a/scripts/core/variables.sh b/scripts/core/variables.sh index 233fadb3..bd11c465 100644 --- a/scripts/core/variables.sh +++ b/scripts/core/variables.sh @@ -183,8 +183,8 @@ if [ -z "$CORE_VARIABLES_LOADED" ]; then # set this so nechung can find its data. define_yeti_variable NECHUNG=$FEISTY_MEOW_APEX/infobase/fortunes.dat - # establish a pipe for less to see our beloved syntax highlighting. - define_yeti_variable LESSOPEN="| source-highlight -f esc -o STDOUT -i %s" +## # establish a pipe for less to see our beloved syntax highlighting. +## define_yeti_variable LESSOPEN="| source-highlight -f esc -o STDOUT -i %s" # ensure we use the right kind of secure shell. # define_yeti_variable CVS_RSH=$FEISTY_MEOW_SCRIPTS/security/ssh.sh diff --git a/scripts/files/lesser.sh b/scripts/files/lesser.sh new file mode 100644 index 00000000..afcc5625 --- /dev/null +++ b/scripts/files/lesser.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# runs the less command but with some additional options. +# +# we always pass the raw flag (-r) so our special formatting is not lost. +# this may not be the best choice for some text terminals. +# +# there is also a "code" option added (-c) that formats the incoming data as +# if it were source code before showing the output. this works great on files +# that are actually recognized as source code, and not so great on other +# things like simple lists or error output. +function lesser() +{ + code_view_flag="$1" + if [ "$code_view_flag" == "-c" ]; then + # saw the 'code' flag, which means show the file with source highlighting. + shift +#echo saw the code flag + + else + # drop the value and emptiness will mean don't show code. + unset code_view_flag + fi + + if [ ! -z "$code_view_flag" ]; then + # establish a pipe for less to see our beloved syntax highlighting. + export LESSOPEN="| source-highlight -f esc -o STDOUT -i %s" + fi + +#hmmm, will we need to iterate on the input array to get this right? + + # run the source highlighter first if needed. + /bin/less -r "${@}" + +#hmmm: do we need to protect above from space hosings? +#hmmm: done, maybe. if this still works for multiple parms... + +} + +