diff --git a/clean_files.txt b/clean_files.txt index 2242ef5e..240c6059 100644 --- a/clean_files.txt +++ b/clean_files.txt @@ -90,6 +90,7 @@ plugins/available/history-substring-search.plugin.bash plugins/available/history.plugin.bash plugins/available/hub.plugin.bash plugins/available/jump.plugin.bash +plugins/available/less-pretty-cat.plugin.bash plugins/available/node.plugin.bash plugins/available/nodenv.plugin.bash plugins/available/plenv.plugin.bash diff --git a/plugins/available/less-pretty-cat.plugin.bash b/plugins/available/less-pretty-cat.plugin.bash index bfe0fe09..cde646c5 100644 --- a/plugins/available/less-pretty-cat.plugin.bash +++ b/plugins/available/less-pretty-cat.plugin.bash @@ -2,30 +2,29 @@ cite about-plugin about-plugin 'pygmentize instead of cat to terminal if possible' -if _command_exists pygmentize -then - # pigmentize cat and less outputs - call them ccat and cless to avoid that - # especially cat'ed output in scripts gets mangled with pygemtized meta characters - function ccat() - { - about 'runs either pygmentize or cat on each file passed in' - param '*: files to concatenate (as normally passed to cat)' - example 'cat mysite/manage.py dir/text-file.txt' - local file - : "${BASH_IT_CCAT_STYLE:=default}" +_command_exists pygmentize || return - for file in "$@" - do - pygmentize -f 256 -O style="$BASH_IT_CCAT_STYLE" -g "$file" 2>/dev/null || command cat "$file"; - done - } +# pigmentize cat and less outputs - call them ccat and cless to avoid that +# especially cat'ed output in scripts gets mangled with pygemtized meta characters +function ccat() { + about 'runs either pygmentize or cat on each file passed in' + param '*: files to concatenate (as normally passed to cat)' + example 'ccat mysite/manage.py dir/text-file.txt' - function cless() - { - about 'pigments the file passed in and passes it to less for pagination' - param '$1: the file to paginate with less' - example 'less mysite/manage.py' - : "${BASH_IT_CLESS_STYLE:=default}" - pygmentize -f 256 -O style="$BASH_IT_CLESS_STYLE" -g "$@" | command less -R - } -fi + local file + : "${BASH_IT_CCAT_STYLE:=default}" + + for file in "$@"; do + pygmentize -f 256 -O style="$BASH_IT_CCAT_STYLE" -g "$file" 2> /dev/null || command cat "$file" + done +} + +function cless() { + about 'pigments the file passed in and passes it to less for pagination' + param '1: the file to paginate with less' + example 'cless mysite/manage.py' + + : "${BASH_IT_CLESS_STYLE:=default}" + + pygmentize -f 256 -O style="$BASH_IT_CLESS_STYLE" -g "$@" | command less -R +}