From: Oleg Broytman Date: Sat, 17 Jan 2015 18:06:15 +0000 (+0300) Subject: mc.menu refactoring: extract an archive X-Git-Url: https://git.phdru.name/?p=dotfiles.git;a=commitdiff_plain;h=c44e2d64005700aaa9016aed0e92a8af7d672b79 mc.menu refactoring: extract an archive --- diff --git a/.mc/menu b/.mc/menu index 3862c3b..1161ca1 100644 --- a/.mc/menu +++ b/.mc/menu @@ -289,9 +289,23 @@ Y zip these files/directories with recoded filenames ZIP=%{Enter zip name} exec zip.py "$ZIP" %s -+ t r & f \.tar\.bz2$ -u Extract from tar-bzip2 - exec bzip2 -cd %f | tar xpvf - ++ f \.tar\.bz2$ | f \.tar\.gz$ | f \.tgz$ | f \.tar\.lz$ | f \.tar\.lzma$ | f \.(zip|ZIP)$ | f \.(rar|RAR)$ | f \.7z$ | f \.xz$ & t r +n Create a directory for this archive + case %f in + *.tar.bz2) D="`basename %f .tar.bz2`";; + *.tar.gz) D="`basename %f .tar.gz`";; + *.tgz) D="`basename %f .tgz`";; + *.tar.lz) D="`basename %f .tar.lz`";; + *.tar.lzma) D="`basename %f .tar.lzma`";; + *.zip) D="`basename %f .zip`";; + *.ZIP) D="`basename %f .ZIP`";; + *.rar) D="`basename %f .rar`";; + *.RAR) D="`basename %f .RAR`";; + *.7z) D="`basename %f .7z`";; + *.xz) D="`basename %f .xz`";; + esac + exec mkdir "$D" + + F \.tar\.bz2$ | F \.tar\.gz$ | F \.tgz$ | F \.tar\.lz$ | F \.tar\.lzma$ | F \.(zip|ZIP)$ | F \.(rar|RAR)$ | F \.7z$ | F \.xz$ & T r N Create a directory for the other archive case %D/%F in @@ -309,9 +323,61 @@ N Create a directory for the other archive esac exec mkdir "$D" -+ f \.tar\.gz$ | f \.tgz$ & t r -u Extract from tar-gzip - exec gzip -cd %f | tar xpvf - ++ f \.tar\.gz$ | f \.tar\.z$ | f \.tgz$ | f \.tpz$ | f \.tar\.lz$ | f \.tar\.lzma$ | f \.tar\.7z$ | f \.tar\.xz$ | f \.tar\.Z$ | f \.tar\.bz2$ & t r +x Extract the contents of a compressed tar file + unset PRG + case %f in + *.tar.bz2) + PRG="bunzip2 -c" + ;; + *.tar.gz|*.tar.z|*.tgz|*.tpz|*.tar.Z) + PRG="gzip -dc" + ;; + *.tar.lz) + PRG="lzip -dc" + ;; + *.tar.lzma) + PRG="lzma -dc" + ;; + *.tar.7z) + PRG="7za e -so" + ;; + *.tar.xz) + PRG="xz -dc" + ;; + *) + exit 1 + ;; + esac + $PRG %f | tar xvf - + ++ F \.tar\.gz$ | F \.tar\.z$ | F \.tgz$ | F \.tpz$ | F \.tar\.lz$ | F \.tar\.lzma$ | F \.tar\.7z$ | F \.tar\.xz$ | F \.tar\.Z$ | F \.tar\.bz2$ & t r +X Extract the contents of an other compressed tar file + unset PRG + case %F in + *.tar.bz2) + PRG="bunzip2 -c" + ;; + *.tar.gz|*.tar.z|*.tgz|*.tpz|*.tar.Z) + PRG="gzip -dc" + ;; + *.tar.lz) + PRG="lzip -dc" + ;; + *.tar.lzma) + PRG="lzma -dc" + ;; + *.tar.7z) + PRG="7za e -so" + ;; + *.tar.xz) + PRG="xz -dc" + ;; + *) + exit 1 + ;; + esac + $PRG %D/%F | tar xvf - + t r & f \.tar$ u Extract from tar @@ -325,50 +391,26 @@ u Extract from zip y Extract from zip with recoded filenames exec unzip.py %f -+ t r & f \.7z$ -u Extract from 7zip - exec 7zr x %f - + t r & f \.(rar|RAR)$ u Extract from rar exec unrar x -y %f -+ t r & f \.tar\.xz$ -u Extract from tar-xz - exec xz -cd %f | tar xpvf - - -+ T r & F \.tar\.bz2$ -U Extract from the other tar-bzip2 - exec bzip2 -cd %D/%F | tar xpvf - - -+ F \.tar\.gz$ | F \.tgz$ & T r -U Extract from the other tar-gzip - exec gzip -cd %D/%F | tar xpvf - - + T r & F \.tar$ -U Extract from the other tar +u Extract from other tar exec tar xpvf %D/%F + T r & F \.(zip|ZIP)$ -U Extract from the other zip +u Extract from other zip exec unzip %D/%F + T r & F \.(zip|ZIP)$ -Y Extract from the other zip with recoded filenames +y Extract from other zip with recoded filenames exec unzip.py %D/%F + T r & F \.(rar|RAR)$ -U Extract from the other rar +u Extract from other rar exec unrar x -y %D/%F -+ T r & F \.7z$ -U Extract from 7zip - exec 7zr x %D/%F - -+ T r & F \.tar\.xz$ -U Extract from tar-xz - exec xz -cd %D/%F | tar xpvf - - + t r v View via mailcap exec see %f