batpipe: Add support for *.gz files

This commit is contained in:
Ethan P 2021-03-24 20:06:10 -07:00
parent 9072ab47a1
commit 988780bce9
No known key found for this signature in database
GPG Key ID: 6963FD04F6CF35EA
2 changed files with 20 additions and 2 deletions

View File

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

View File

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