mirror of
https://github.com/sharkdp/bat.git
synced 2025-02-07 13:41:14 +00:00
add zbat wrapper to decompress files automatically
This relies on bsdcat from archive-tools, which supports more formats than just gzip or, failing that, falls back to gunzip -c with a warning. Previously[1], @sharkdp stated that bat would not support compressed files, but would be open in implementing a wrapper. There was another implementation proposed elsewhere[2], but it seems overengineered to me. [1] https://github.com/sharkdp/bat/issues/642#issuecomment-526816644 [2] https://github.com/sharkdp/bat/issues/237#issuecomment-617079288
This commit is contained in:
parent
dd3d1b8cdb
commit
a9077f32ba
@ -1,6 +1,7 @@
|
|||||||
# unreleased
|
# unreleased
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
* Add a `zbat` wrapper script to automatically decompress files before display, see PR #3177 (@anarcat)
|
||||||
|
|
||||||
## Bugfixes
|
## Bugfixes
|
||||||
* Fix `BAT_THEME_DARK` and `BAT_THEME_LIGHT` being ignored, see issue #3171 and PR #3168 (@bash)
|
* Fix `BAT_THEME_DARK` and `BAT_THEME_LIGHT` being ignored, see issue #3171 and PR #3168 (@bash)
|
||||||
|
12
bin/zbat
Executable file
12
bin/zbat
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -u
|
||||||
|
# shellcheck disable=SC3040
|
||||||
|
(set -o pipefail 2> /dev/null) && set -o pipefail
|
||||||
|
|
||||||
|
cpath="$1"
|
||||||
|
# cpath without suffix
|
||||||
|
path="$(echo $cpath | sed 's/\.[^.]*$//')"
|
||||||
|
|
||||||
|
( bsdcat "$path" || gunzip -c "$path" ) | batcat --file-name "$path"
|
Loading…
x
Reference in New Issue
Block a user