From 0bdcf196aaaffbc2af4884570a05144831e012f3 Mon Sep 17 00:00:00 2001 From: Miguel Morales Date: Tue, 12 May 2015 11:30:49 -0500 Subject: [PATCH] Add pretty cat plugin for cat with syntax highlighting --- plugins/available/pretty-cat.plugin.bash | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 plugins/available/pretty-cat.plugin.bash diff --git a/plugins/available/pretty-cat.plugin.bash b/plugins/available/pretty-cat.plugin.bash new file mode 100644 index 00000000..6e5f57c9 --- /dev/null +++ b/plugins/available/pretty-cat.plugin.bash @@ -0,0 +1,21 @@ +cite about-plugin +about-plugin 'pygmentize instead of cat to terminal if possible' + +if [ -z $(which pygmentize) ] +then + echo "Pygments is required to use this pluging" + echo "Install it by doing 'pip install Pygments' as the superuser" + exit +fi + +# get the actual cat binary +CAT_BIN=$(which cat) + +# replace the cat binary for a pygmentize if possible +cat() +{ + for var; + do + pygmentize "$var" 2>/dev/null || "$CAT_BIN" "$var"; + done +}