summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Cornellà <marc@mcornella.com>2024-09-26 13:12:53 +0200
committerMarc Cornellà <marc@mcornella.com>2024-10-01 10:01:07 +0200
commitf4423ebd09fbc7670815c3c20cc86c81b7319e5f (patch)
tree25c2be974308457840549de3e3370a9ccf39fabf
parentec3cb127b2803712a1c19127f6a7382748675fcb (diff)
downloadzsh-f4423ebd09fbc7670815c3c20cc86c81b7319e5f.tar.gz
zsh-f4423ebd09fbc7670815c3c20cc86c81b7319e5f.tar.bz2
zsh-f4423ebd09fbc7670815c3c20cc86c81b7319e5f.zip
feat(cli): style plugin README in `omz plugin info`
-rw-r--r--lib/cli.zsh19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/cli.zsh b/lib/cli.zsh
index 383b0cfb0..d1896f18d 100644
--- a/lib/cli.zsh
+++ b/lib/cli.zsh
@@ -397,8 +397,23 @@ function _omz::plugin::info {
local readme
for readme in "$ZSH_CUSTOM/plugins/$1/README.md" "$ZSH/plugins/$1/README.md"; do
if [[ -f "$readme" ]]; then
- (( ${+commands[less]} )) && less "$readme" || cat "$readme"
- return 0
+ # If being piped, just cat the README
+ if [[ ! -t 1 ]]; then
+ cat "$readme"
+ return $?
+ fi
+
+ # Enrich the README display depending on the tools we have
+ # - glow: https://github.com/charmbracelet/glow
+ # - bat: https://github.com/sharkdp/bat
+ # - less: typical pager command
+ case 1 in
+ ${+commands[glow]}) glow -p "$readme" ;;
+ ${+commands[bat]}) bat -l md --style plain "$readme" ;;
+ ${+commands[less]}) less "$readme" ;;
+ *) cat "$readme" ;;
+ esac
+ return $?
fi
done