batpipe: Add support for *.xz files

This commit is contained in:
Ethan P 2021-03-24 20:13:27 -07:00
parent 0d2e999b2a
commit dafd2addc0
No known key found for this signature in database
GPG Key ID: 6963FD04F6CF35EA
2 changed files with 20 additions and 1 deletions

View File

@ -27,6 +27,7 @@ Like [lesspipe](https://github.com/wofr06/lesspipe), `batpipe` is designed to wo
| `*.tar`, `*.tar.gz` | `tar` |
| `*.zip`, `*.jar` | `unzip` |
| `*.gz` | `gunzip` |
| `*.xz` | `xz` |
## External Viewers

View File

@ -109,7 +109,7 @@ fi
# Viewers:
# -----------------------------------------------------------------------------
BATPIPE_VIEWERS=("ls" "tar" "unzip" "gunzip")
BATPIPE_VIEWERS=("ls" "tar" "unzip" "gunzip" "xz")
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -189,6 +189,24 @@ viewer_gunzip_process() {
return $?
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
viewer_xz_supports() {
command -v "xz" &> /dev/null || return 1
[[ -z "$3" ]] || return 1
case "$2" in
*.xz) return 0 ;;
esac
return 1
}
viewer_xz_process() {
xz --decompress -k -c "$1"
return $?
}
# -----------------------------------------------------------------------------
# Functions:
# -----------------------------------------------------------------------------