mirror of
https://github.com/eth-p/bat-extras.git
synced 2025-06-20 11:47:43 +02:00
Merge branch 'compressed-tar'
This commit is contained in:
commit
895b4ee0ce
@ -153,9 +153,9 @@ fi
|
|||||||
|
|
||||||
if ! command -v eza &> /dev/null
|
if ! command -v eza &> /dev/null
|
||||||
then
|
then
|
||||||
BATPIPE_VIEWERS=("eza" "ls" "tar" "unzip" "gunzip" "xz")
|
BATPIPE_VIEWERS=("eza" "ls" "tar" "tar_gz" "unzip" "gunzip" "xz")
|
||||||
else
|
else
|
||||||
BATPIPE_VIEWERS=("exa" "ls" "tar" "unzip" "gunzip" "xz")
|
BATPIPE_VIEWERS=("exa" "ls" "tar" "tar_bz2" "unzip" "gunzip" "xz")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
@ -221,17 +221,50 @@ viewer_tar_supports() {
|
|||||||
|
|
||||||
viewer_tar_process() {
|
viewer_tar_process() {
|
||||||
if [[ -n "$2" ]]; then
|
if [[ -n "$2" ]]; then
|
||||||
tar -xf "$1" -O "$2" | bat --file-name="$1/$2"
|
tar $3 -xf "$1" -O "$2" | bat --file-name="$1/$2"
|
||||||
else
|
else
|
||||||
batpipe_header "Viewing contents of archive: %{PATH}%s" "$1"
|
batpipe_archive_header
|
||||||
batpipe_subheader "To view files within the archive, add the file path after the archive."
|
tar $3 -tvf "$1"
|
||||||
tar -tvf "$1"
|
|
||||||
return $?
|
return $?
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
|
viewer_tar_gz_supports() {
|
||||||
|
command -v "tar" &> /dev/null || return 1
|
||||||
|
command -v "gzip" &> /dev/null || return 1
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
*.tar.gz | *.tgz) return 0 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
viewer_tar_gz_process() {
|
||||||
|
viewer_tar_process "$1" "$2" -z
|
||||||
|
}
|
||||||
|
|
||||||
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
|
viewer_tar_bz2_supports() {
|
||||||
|
command -v "tar" &> /dev/null || return 1
|
||||||
|
command -v "bzip2" &> /dev/null || return 1
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
*.tar.bz2 | *.tbz) return 0 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
viewer_tar_bz2_process() {
|
||||||
|
viewer_tar_process "$1" "$2" -j
|
||||||
|
}
|
||||||
|
|
||||||
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
viewer_unzip_supports() {
|
viewer_unzip_supports() {
|
||||||
command -v "unzip" &> /dev/null || return 1
|
command -v "unzip" &> /dev/null || return 1
|
||||||
|
|
||||||
@ -246,8 +279,7 @@ viewer_unzip_process() {
|
|||||||
if [[ -n "$2" ]]; then
|
if [[ -n "$2" ]]; then
|
||||||
unzip -p "$1" "$2" | bat --file-name="$1/$2"
|
unzip -p "$1" "$2" | bat --file-name="$1/$2"
|
||||||
else
|
else
|
||||||
batpipe_header "Viewing contents of archive: %{PATH}%s" "$1"
|
batpipe_archive_header
|
||||||
batpipe_subheader "To view files within the archive, add the file path after the archive."
|
|
||||||
unzip -l "$1"
|
unzip -l "$1"
|
||||||
return $?
|
return $?
|
||||||
fi
|
fi
|
||||||
@ -311,6 +343,11 @@ batpipe_subheader() {
|
|||||||
printc "%{SUBHEADER}==> $pattern%{C}\n" "${@:2}"
|
printc "%{SUBHEADER}==> $pattern%{C}\n" "${@:2}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
batpipe_archive_header() {
|
||||||
|
batpipe_header "Viewing contents of archive: %{PATH}%s" "$1"
|
||||||
|
batpipe_subheader "To view files within the archive, add the file path after the archive."
|
||||||
|
}
|
||||||
|
|
||||||
# Executes `bat` (or `cat`, if already running from within `bat`).
|
# Executes `bat` (or `cat`, if already running from within `bat`).
|
||||||
# Supports the `--file-name` argument if the bat version is new enough.
|
# Supports the `--file-name` argument if the bat version is new enough.
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user