#!/usr/bin/env zsh setopt ERR_EXIT sel=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} [[ -s $sel ]] tgts=$(xargs -0 -L1 < $sel) tgts=(${(f)tgts}) size=$(du -A -c $tgts) size=(${=size}) size=${size[$#size - 1]} for tgt ($tgts) { pushd $tgt:h ; tar cf - $tgt:t ; popd } | pv --wait --interval 0.5 --size ${size}k | tar xf - --options read_concatenated_archives