diff --git a/doc/batpipe.md b/doc/batpipe.md index 40334cf..3540dcb 100644 --- a/doc/batpipe.md +++ b/doc/batpipe.md @@ -23,7 +23,7 @@ Like [lesspipe](https://github.com/wofr06/lesspipe), `batpipe` is designed to wo | Files | Program | | -------------------- | --------------------------- | -| Directories | `ls` | +| Directories | `exa`, `ls` | | `*.tar`, `*.tar.gz` | `tar` | | `*.zip`, `*.jar` | `unzip` | | `*.gz` | `gunzip` | diff --git a/src/batpipe.sh b/src/batpipe.sh index aa7e66d..eee4c3c 100755 --- a/src/batpipe.sh +++ b/src/batpipe.sh @@ -109,7 +109,26 @@ fi # Viewers: # ----------------------------------------------------------------------------- -BATPIPE_VIEWERS=("ls" "tar" "unzip" "gunzip" "xz") +BATPIPE_VIEWERS=("exa" "ls" "tar" "unzip" "gunzip" "xz") + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +viewer_exa_supports() { + [[ -d "$2" ]] || return 1 + command -v "exa" &> /dev/null || return 1 + return 0 +} + +viewer_exa_process() { + local dir="$(strip_trailing_slashes "$1")" + batpipe_header "Viewing contents of directory: %{PATH}%s" "$dir" + if "$BATPIPE_ENABLE_COLOR"; then + exa -la --color=always "$1" 2>&1 + else + exa -la --color=never "$1" 2>&1 + fi + return $? +} # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -