mc.menu.in 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794
  1. shell_patterns=0
  2. ##############################################################################
  3. # %% The % character
  4. # %f The current file (if non-local vfs, file will be copied locally and
  5. # %f will be full path to it)
  6. # %p The current file
  7. # %d The current working directory
  8. # %s "Selected files"; the tagged files if any, otherwise the current file
  9. # %t Tagged files
  10. # %u Tagged files (and they are untagged on return from expand_format)
  11. # %view Runs the commands and pipes standard output to the view command
  12. # If %view is immediately followed by '{', recognize keywords
  13. # ascii, hex, nroff and unform
  14. #
  15. # If the format letter is in uppercase, it refers to the other panel
  16. #
  17. # With a number followed the % character you can turn quoting on (default)
  18. # and off. For example:
  19. # %f quote expanded macro
  20. # %1f ditto
  21. # %0f don't quote expanded macro
  22. #
  23. # Unused shortcuts: ! % ) 5 ^ f F g G h H I k K L M N n o O p P q Q t T v V
  24. ##############################################################################
  25. + ! t t
  26. @ Do something on the current file
  27. CMD=%{Enter command}
  28. $CMD %f
  29. + t t
  30. @ Do something on the tagged files
  31. CMD=%{Enter command}
  32. for i in %t ; do
  33. $CMD "$i"
  34. done
  35. =+ f \.1$ | f \.3$ | f \.4$ | f \.5$ | f \.6$ | f \.7$ | f \.8$ | f \.man$ & t r
  36. $ Display the file with roff -man
  37. %view{ascii,nroff} roff @MAN_FLAGS@ @MANDOC@ %f
  38. + f \.c$ & t r & ! t t
  39. 1 Compile and link current .c file
  40. make "`basename %f .c`" 2>/dev/null || cc -O -o "`basename %f .c`" %f
  41. + ! t t
  42. 2 Pack the current subdirectory (tar)
  43. Pwd=`basename %d /`
  44. echo -n "Name of the tarball (without extension) [$Pwd]: "
  45. read tar
  46. [ "$tar"x = x ] && tar="$Pwd"
  47. cd .. && \
  48. tar cf "$tar.tar" "$Pwd" && \
  49. echo "../$tar.tar created."
  50. + t t
  51. 2 Pack tagged directories (tar)
  52. echo "[%t]"
  53. for tar in %t; do
  54. tar cf "$tar.tar" "$tar" && \
  55. echo "$tar.tar created."
  56. done
  57. + ! t t
  58. 3 Compress the current subdirectory (tar.gz)
  59. Pwd=`basename %d /`
  60. echo -n "Name of the compressed file (without extension) [$Pwd]: "
  61. read tar
  62. [ "$tar"x = x ] && tar="$Pwd"
  63. cd .. && \
  64. tar cf - "$Pwd" | gzip -f9 > "$tar.tar.gz" && \
  65. echo "../$tar.tar.gz created."
  66. + t t
  67. 3 Compress tagged subdirectories (tar.gz)
  68. for tar in %t; do
  69. tar cf - "$tar" | gzip -f9 > "$tar.tar.gz" && \
  70. echo "$tar.tar.gz created."
  71. done
  72. + ! t t
  73. 4 Compress the current subdirectory (tar.bz2)
  74. Pwd=`basename %d /`
  75. echo -n "Name of the compressed file (without extension) [$Pwd]: "
  76. read tar
  77. [ "$tar"x = x ] && tar="$Pwd"
  78. cd .. && \
  79. tar cf - "$Pwd" | bzip2 -f > "$tar.tar.bz2" && \
  80. echo "../$tar.tar.bz2 created."
  81. + t t
  82. 4 Compress tagged subdirectories (tar.bz2)
  83. for tar in %t; do
  84. tar cf - "$tar" | bzip2 -f > "$tar.tar.bz2" && \
  85. echo "$tar.tar.bz2 created."
  86. done
  87. + ! t t
  88. 6 Compress the current subdirectory (tar.xz)
  89. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  90. Pwd=`basename %d /`
  91. echo -n "Name of the compressed file (without extension) [$Pwd]: "
  92. read tar
  93. [ "$tar"x = x ] && tar="$Pwd"
  94. cd .. && \
  95. tar cf - "$Pwd" | xz -f > "$tar.tar.xz" && \
  96. echo "../$tar.tar.xz created."
  97. + t t
  98. 6 Compress tagged subdirectories (tar.xz)
  99. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  100. for tar in %t; do
  101. tar cf - "$tar" | xz -f > "$tar.tar.xz" && \
  102. echo "../$tar.tar.xz created."
  103. done
  104. + ! t t
  105. 7 Compress the current subdirectory (tar.zst)
  106. Pwd=`basename %d /`
  107. echo -n "Name of the compressed file (without extension) [$Pwd]: "
  108. read tar
  109. [ "$tar"x = x ] && tar="$Pwd"
  110. cd .. && \
  111. tar cf - "$Pwd" | zstd $COMPRESS_OPTS_ZSTD -f > "$tar.tar.zst" && \
  112. echo "../$tar.tar.zst created."
  113. + t t
  114. 7 Compress tagged subdirectories (tar.zst)
  115. for tar in %t; do
  116. tar cf - "$tar" | zstd $COMPRESS_OPTS_ZSTD -f > "$tar.tar.zst" && \
  117. echo "$tar.tar.zst created."
  118. done
  119. + ! t t
  120. 8 Compress the current subdirectory (tar.lzo)
  121. Pwd=`basename %d /`
  122. echo -n "Name of the compressed file (without extension) [$Pwd]: "
  123. read tar
  124. [ "$tar"x = x ] && tar="$Pwd"
  125. cd .. && \
  126. tar cf - "$Pwd" | lzop -f > "$tar.tar.lzo" && \
  127. echo "../$tar.tar.lzo created."
  128. + t t
  129. 8 Compress tagged subdirectories (tar.lzo)
  130. for tar in %t; do
  131. tar cf - "$tar" | lzop -f > "$tar.tar.lzo" && \
  132. echo "$tar.tar.lzo created."
  133. done
  134. + ! t t
  135. 9 Compress the current subdirectory (7z)
  136. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  137. Pwd=`basename %d /`
  138. echo -n "Name of the compressed file (without extension) [$Pwd]: "
  139. read tar
  140. [ "$tar"x = x ] && tar="$Pwd"
  141. cd .. && \
  142. ${P7ZIP} a $COMPRESS_OPTS_7Z "$tar.7z" "$tar" && \
  143. echo "../$tar.7z created."
  144. + t t
  145. 9 Compress tagged subdirectories (7z)
  146. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  147. for tar in %t; do
  148. ${P7ZIP} a $COMPRESS_OPTS_7Z "$tar.7z" "$tar" && \
  149. echo "$tar.7z created."
  150. done
  151. + ! t t
  152. 0 Compress the current subdirectory (zip)
  153. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  154. Pwd=`basename %d /`
  155. echo -n "Name of the compressed file (without extension) [$Pwd]: "
  156. read tar
  157. [ "$tar"x = x ] && tar="$Pwd"
  158. cd .. && \
  159. zip -r "$tar.zip" "$tar" && \
  160. echo "../$tar.zip created."
  161. + t t
  162. 0 Compress tagged subdirectories (zip)
  163. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  164. for tar in %t; do
  165. zip -r "$tar.zip" "$tar" && \
  166. echo "$tar.zip created."
  167. done
  168. + ! t t
  169. ( Compress and encrypt the current subdirectory (7z)
  170. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  171. Pwd=`basename %d /`
  172. echo -n "Name of the compressed file (without extension) [$Pwd]: "
  173. read tar
  174. [ "$tar"x = x ] && tar="$Pwd"
  175. cd .. && \
  176. ${P7ZIP} a -p -mhe $COMPRESS_OPTS_7Z "$tar.7z" "$tar" && \
  177. echo "../$tar.7z created."
  178. + t t
  179. ( Compress and encrypt tagged subdirectories (7z)
  180. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  181. for tar in %t; do
  182. ${P7ZIP} a -p -mhe $COMPRESS_OPTS_7Z "$tar.7z" "$tar" && \
  183. echo "$tar.7z created."
  184. done
  185. + t r & ! t t
  186. a Append file to opposite
  187. cat %f >> %D/%f
  188. + t t
  189. A Append files to opposite files
  190. for i in %t ; do
  191. cat "$i" >> %D/"$i"
  192. done
  193. + t r & ! t t
  194. d Delete file if a copy exists in the other directory
  195. if [ %d = %D ]; then
  196. echo "The two directories must be different"
  197. exit 1
  198. fi
  199. if [ -f %D/%f ]; then # if two of them, then
  200. if cmp -s %D/%f %f; then
  201. rm %f && echo %f": DELETED."
  202. else
  203. echo %f" and "%D/%f" differ: NOT deleted"
  204. echo -n "Press RETURN "
  205. read key
  206. fi
  207. else
  208. echo %f": No copy in "%D/%f": NOT deleted"
  209. fi
  210. + t t
  211. D Delete tagged files if a copy exists in the other directory
  212. if [ %d = %D ]; then
  213. echo "The two directories must be different"
  214. exit 1
  215. fi
  216. for i in %t ; do
  217. if [ -f %D/"$i" ]; then
  218. SUM1=`sum "$i"`
  219. SUM2=`sum %D/"$i"`
  220. if [ "$SUM1" = "$SUM2" ]; then
  221. rm "$i" && echo "$i: DELETED."
  222. else
  223. echo "$i and "%D"/$i differ: NOT deleted"
  224. fi
  225. else
  226. echo "$i has no copy in "%D": NOT deleted"
  227. fi
  228. done
  229. m View manual page
  230. MAN=%{Enter manual name}
  231. %view{ascii,nroff} MANROFFOPT='@MAN_FLAGS@' MAN_KEEP_FORMATTING=1 man -P cat "$MAN"
  232. = t r
  233. + ! t t
  234. r Copy file to remote host
  235. echo -n "To which host?: "
  236. read Host
  237. echo -n "To which directory on $Host?: "
  238. read Dir
  239. scp %f "${Host}:${Dir}"
  240. + t t
  241. R Copy files to remote host (no error checking)
  242. echo -n "Copy files to which host?: "
  243. read Host
  244. echo -n "To which directory on $Host? :"
  245. read Dir
  246. scp -r %u "${Host}:${Dir}"
  247. + ! t t
  248. l List compressed archive or image (using 7z)
  249. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  250. case %f in
  251. *.tar.*)
  252. tar -taf %f;;
  253. *)
  254. ${P7ZIP} l %f;;
  255. esac
  256. + t t
  257. l List compressed archives or images (using 7z)
  258. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  259. for i in %t ; do
  260. case %f in
  261. *.tar.*)
  262. tar -taf "$i";;
  263. *)
  264. ${P7ZIP} l "$i";;
  265. esac
  266. done
  267. + ! t t
  268. e Extract compressed archive or image (using 7z)
  269. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  270. ${P7ZIP} x -bb3 -o$(dirname %f) %f
  271. + t t
  272. e Extract compressed archives or images (using 7z)
  273. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  274. for i in %t ; do
  275. ${P7ZIP} x -bb3 -o"$(dirname "$i")" "$i"
  276. done
  277. + ! t t
  278. E Extract compressed archive or image to subdirs (using 7z)
  279. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  280. id=`basename %f`
  281. iD="${id%.*}"
  282. mkdir -p "$iD"
  283. ${P7ZIP} x -bb3 -o"$iD" %f
  284. + t t
  285. E Extract compressed archives or images to subdirs (using 7z)
  286. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  287. for i in %t ; do
  288. id=`basename "$i"`
  289. iD="${id%.*}"
  290. mkdir -p "$iD"
  291. ${P7ZIP} x -bb3 -o"$iD" "$i"
  292. done
  293. + f \.tar$ | f \.tar\.gz$ | f \.tar\.z$ | f \.tgz$ | f \.tpz$ | f \.tar\.lz$ | f \.tar\.lz4$ | f \.tar\.lzma$ | f \.tar\.lzo$ | f \.tar\.7z$ | f \.tar\.xz$ | f \.txz$ | f \.tar\.zst$ | f \.tzst$ | f \.tar\.Z$ | f \.tar\.bz2$ | f \.tbz2$ & t rl & ! t t
  294. x Extract the contents of a compressed tar file
  295. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  296. unset PRG
  297. case %f in
  298. *.tar)
  299. PRG="";;
  300. *.tar.7z)
  301. PRG="${P7ZIP} e -so";;
  302. *.tar.bz2|*.tbz2)
  303. PRG="bunzip2 -c";;
  304. *.tar.gz|*.tar.z|*.tgz|*.tpz|*.tar.Z)
  305. PRG="gzip -dc";;
  306. *.tar.lz)
  307. PRG="lzip -dc";;
  308. *.tar.lz4)
  309. PRG="lz4 -dc";;
  310. *.tar.lzma)
  311. PRG="lzma -dc";;
  312. *.tar.lzo)
  313. PRG="lzop -dc";;
  314. *.tar.xz|*.txz)
  315. PRG="xz -dc";;
  316. *.tar.zst|*.tzst)
  317. PRG="zstd -dc";;
  318. *)
  319. exit 1;;
  320. esac
  321. if [ -n "$PRG" ]; then
  322. $PRG %f | tar -xvf -
  323. else
  324. tar -xf %f
  325. fi
  326. + f \.tar$ | f \.tar\.gz$ | f \.tar\.z$ | f \.tgz$ | f \.tpz$ | f \.tar\.lz$ | f \.tar\.lz4$ | f \.tar\.lzma$ | f \.tar\.lzo$ | f \.tar\.7z$ | f \.tar\.xz$ | f \.txz$ | f \.tar\.zst$ | f \.tzst$ | f \.tar\.Z$ | f \.tar\.bz2 | f \.tbz2$ & t t
  327. x Extract the contents of compressed tagged tar files
  328. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  329. for i in %t ; do
  330. unset PRG
  331. case "$i" in
  332. *.tar)
  333. PRG="";;
  334. *.tar.7z)
  335. PRG="${P7ZIP} e -so";;
  336. *.tar.bz2|*.tbz2)
  337. PRG="bunzip2 -c";;
  338. *.tar.gz|*.tar.z|*.tgz|*.tpz|*.tar.Z)
  339. PRG="gzip -dc";;
  340. *.tar.lz)
  341. PRG="lzip -dc";;
  342. *.tar.lz4)
  343. PRG="lz4 -dc";;
  344. *.tar.lzma)
  345. PRG="lzma -dc";;
  346. *.tar.lzo)
  347. PRG="lzop -dc";;
  348. *.tar.xz|*.txz)
  349. PRG="xz -dc";;
  350. *.tar.zst|*.tzst)
  351. PRG="zstd -dc";;
  352. *)
  353. exit 1;;
  354. esac
  355. if [ -n "$PRG" ]; then
  356. $PRG "$i" | tar -xvf -
  357. else
  358. tar -xf "$i"
  359. fi
  360. done
  361. + f \.tar$ | f \.tar\.gz$ | f \.tar\.z$ | f \.tgz$ | f \.tpz$ | f \.tar\.lz$ | f \.tar\.lz4$ | f \.tar\.lzma$ | f \.tar\.lzo$ | f \.tar\.7z$ | f \.tar\.xz$ | f \.txz$ | f \.tar\.zst$ | f \.tzst$ | f \.tar\.Z$ | f \.tar\.bz2$ | f \.tbz2$ & t rl & ! t t
  362. X Extract the contents of a compressed tar file to subdir
  363. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  364. unset D
  365. unset PRG
  366. case %f in
  367. *.tar)
  368. PRG=""; D=`basename %f .tar`;;
  369. *.tar.7z)
  370. PRG="${P7ZIP} e -so"; D=`basename %f .tar.7z`;;
  371. *.tar.bz2)
  372. PRG="bunzip2 -c"; D=`basename %f .tar.bz2`;;
  373. *.tbz2)
  374. PRG="bunzip2 -c"; D=`basename %f .tbz2`;;
  375. *.tar.gz)
  376. PRG="gzip -dc"; D=`basename %f .tar.gz`;;
  377. *.tar.z)
  378. PRG="gzip -dc"; D=`basename %f .tar.z`;;
  379. *.tgz)
  380. PRG="gzip -dc"; D=`basename %f .tgz`;;
  381. *.tpz)
  382. PRG="gzip -dc"; D=`basename %f .tpz`;;
  383. *.tar.Z)
  384. PRG="gzip -dc"; D=`basename %f .tar.Z`;;
  385. *.tar.lz)
  386. PRG="lzip -dc"; D=`basename %f .tar.lz`;;
  387. *.tar.lz4)
  388. PRG="lz4 -dc"; D=`basename %f .tar.lz4`;;
  389. *.tar.lzma)
  390. PRG="lzma -dc"; D=`basename %f .tar.lzma`;;
  391. *.tar.lzo)
  392. PRG="lzop -dc"; D=`basename %f .tar.lzo`;;
  393. *.tar.xz)
  394. PRG="xz -dc"; D=`basename %f .tar.xz`;;
  395. *.txz)
  396. PRG="xz -dc"; D=`basename %f .txz`;;
  397. *.tar.zst)
  398. PRG="zstd -dc"; D=`basename %f .tar.zst`;;
  399. *.tzst)
  400. PRG="zstd -dc"; D=`basename %f .tzst`;;
  401. *.tar.F)
  402. PRG="freeze -dc"; D=`basename %f .tar.F`;;
  403. *)
  404. echo "Unsupported compression,"; exit 255;;
  405. esac
  406. if [ -n "$PRG" ]; then
  407. mkdir "$D" && $PRG %f | tar -C "$D" -xvf -
  408. else
  409. mkdir "$D" && tar -C "$D" -xvf %f
  410. fi
  411. + f \.tar$ | f \.tar\.gz$ | f \.tar\.z$ | f \.tgz$ | f \.tpz$ | f \.tar\.lz$ | f \.tar\.lz4$ | f \.tar\.lzma$ | f \.tar\.lzo$ | f \.tar\.7z$ | f \.tar\.xz$ | f \.txz$ | f \.tar\.zst$ | f \.tzst$ | f \.tar\.Z$ | f \.tar\.bz2$ | f \.tbz2$ & t t
  412. X Extract the contents of compressed tar files to subdir
  413. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  414. for i in %t ; do
  415. unset D
  416. unset PRG
  417. case "$i" in
  418. *.tar)
  419. PRG=""; D=`basename $i .tar`;;
  420. *.tar.7z)
  421. PRG="${P7ZIP} e -so"; D=`basename $i .tar.7z`;;
  422. *.tar.bz2)
  423. PRG="bunzip2 -c"; D=`basename $i .tar.bz2`;;
  424. *.tbz2)
  425. PRG="bunzip2 -c"; D=`basename $i .tbz2`;;
  426. *.tar.gz)
  427. PRG="gzip -dc"; D=`basename $i .tar.gz`;;
  428. *.tar.z)
  429. PRG="gzip -dc"; D=`basename $i .tar.z`;;
  430. *.tgz)
  431. PRG="gzip -dc"; D=`basename $i .tgz`;;
  432. *.tpz)
  433. PRG="gzip -dc"; D=`basename $i .tpz`;;
  434. *.tar.Z)
  435. PRG="gzip -dc"; D=`basename $i .tar.Z`;;
  436. *.tar.lz)
  437. PRG="lzip -dc"; D=`basename $i .tar.lz`;;
  438. *.tar.lz4)
  439. PRG="lz4 -dc"; D=`basename $i .tar.lz4`;;
  440. *.tar.lzma)
  441. PRG="lzma -dc"; D=`basename $i .tar.lzma`;;
  442. *.tar.lzo)
  443. PRG="lzop -dc"; D=`basename $i .tar.lzo`;;
  444. *.tar.xz)
  445. PRG="xz -dc"; D=`basename $i .tar.xz`;;
  446. *.txz)
  447. PRG="xz -dc"; D=`basename $i .txz`;;
  448. *.tar.zst)
  449. PRG="zstd -dc"; D=`basename $i .tar.zst`;;
  450. *.tzst)
  451. PRG="zstd -dc"; D=`basename $i .tzst`;;
  452. *.tar.F)
  453. PRG="freeze -dc"; D=`basename $i .tar.F`;;
  454. *)
  455. echo "Unsupported compression,"; exit 255;;
  456. esac
  457. if [ -n "$PRG" ]; then
  458. mkdir "$D" && $PRG $i | tar -C "$D" -xvf -
  459. else
  460. mkdir "$D" && tar -C "$D" -xvf "$i"
  461. fi
  462. done
  463. + t r & ! t t
  464. z Compress or uncompress (gzip) current file
  465. unset DECOMP
  466. unset DEPROG
  467. case %f in
  468. *.gz|*.[zZ])
  469. DEPROG=gzip; DECOMP=-d;;
  470. *)
  471. DEPROG=gzip; DECOMP="";;
  472. esac
  473. # Do *not* add quotes around $DECOMP!
  474. $DEPROG $DECOMP -v %f
  475. + t t
  476. z Compress or uncompress (gzip) tagged files
  477. for i in %t ; do
  478. unset DECOMP
  479. unset DEPROG
  480. case "$i" in
  481. *.gz|*.[zZ])
  482. DEPROG=gzip; DECOMP=-d;;
  483. *)
  484. DEPROG=gzip; DECOMP="";;
  485. esac
  486. $DEPROG $DECOMP -v "$i"
  487. done
  488. + t r & ! t t
  489. Z Compress or uncompress (bzip2) current file
  490. unset DECOMP
  491. unset DEPROG
  492. case %f in
  493. *.bz2)
  494. DEPROG=bzip2; DECOMP=-d;;
  495. *)
  496. DEPROG=bzip2; DECOMP="";;
  497. esac
  498. # Do *not* add quotes around $DECOMP!
  499. $DEPROG $DECOMP -v %f
  500. + t t
  501. Z Compress or uncompress (bzip2) tagged files
  502. for i in %t ; do
  503. unset DECOMP
  504. unset DEPROG
  505. case "$i" in
  506. *.bz2)
  507. DEPROG=bzip2; DECOMP=-d;;
  508. *)
  509. DEPROG=bzip2; DECOMP="";;
  510. esac
  511. $DEPROG $DECOMP -v "$i"
  512. done
  513. + t r & ! t t
  514. y Compress or uncompress (zstd) current file
  515. unset DECOMP
  516. unset DEPROG
  517. case %f in
  518. *.zst)
  519. DEPROG=zstd; DECOMP="-d --rm";;
  520. *)
  521. DEPROG=zstd; DECOMP="--rm";;
  522. esac
  523. # Do *not* add quotes around $DECOMP!
  524. $DEPROG $DECOMP -v %f
  525. + t t
  526. y Compress or uncompress (zstd) tagged files
  527. for i in %t ; do
  528. unset DECOMP
  529. unset DEPROG
  530. case "$i" in
  531. *.zst)
  532. DEPROG=zstd; DECOMP="-d --rm";;
  533. *)
  534. DEPROG=zstd; DECOMP="--rm";;
  535. esac
  536. $DEPROG $DECOMP -v "$i"
  537. done
  538. + t r & ! t t
  539. u Compress or uncompress (xz) current file
  540. unset DECOMP
  541. unset DEPROG
  542. case %f in
  543. *.xz)
  544. DEPROG=xz; DECOMP=-d;;
  545. *)
  546. DEPROG=xz; DECOMP="";;
  547. esac
  548. # Do *not* add quotes around $DECOMP!
  549. $DEPROG $DECOMP -v %f
  550. + t t
  551. u Compress or uncompress (xz) tagged files
  552. for i in %t ; do
  553. unset DECOMP
  554. unset DEPROG
  555. case "$i" in
  556. *.xz)
  557. DEPROG=xz; DECOMP=-d;;
  558. *)
  559. DEPROG=xz; DECOMP="";;
  560. esac
  561. $DEPROG $DECOMP -v "$i"
  562. done
  563. + t r & ! t t
  564. U Compress (xz using 7z) or uncompress (any) current file
  565. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  566. case %f in
  567. *.gz|*.[zZ]|*.bz2|*.xz|*.xz|*.7z|*.zst)
  568. ${P7ZIP} x %f && rm -vf %f;;
  569. *)
  570. ${P7ZIP} a -txz -m0=lzma2 -ms=on $COMPRESS_OPTS_7Z %f.xz %f && test -r %f.xz && rm -vf %f;;
  571. esac
  572. + t t
  573. U Compress (xz using 7z) or uncompress (any) tagged files
  574. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  575. for i in %t ; do
  576. unset DECOMP
  577. case "$i" in
  578. *.gz|*.[zZ]|*.bz2|*.xz|*.xz|*.7z|*.zst)
  579. ${P7ZIP} x "$i" && rm -vf "$i";;
  580. *)
  581. ${P7ZIP} a -txz -m0=lzma2 -ms=on $COMPRESS_OPTS_7Z "$i.xz" "$i" && test -r "$i.xz" && rm -vf "$i";;
  582. esac
  583. done
  584. + f \.gz$ | f \.tgz$ | f \.tpz$ | f \.Z$ | f \.z$ | f \.bz2$ & t r & ! t t
  585. c Convert gz<->bz2, tar.gz/tgz<->tar.bz2 current
  586. unset D
  587. unset EXT
  588. case %f in
  589. *.Z)
  590. EXT=Z;;
  591. *.bz2)
  592. EXT=bz2;;
  593. *.gz)
  594. EXT=gz;;
  595. *.tgz)
  596. EXT=tgz;;
  597. *.tpz)
  598. EXT=tpz;;
  599. *.z)
  600. EXT=z;;
  601. esac
  602. case "$EXT" in
  603. bz2|Z|gz|z)
  604. D="`basename %f ."$EXT"`";;
  605. tgz|tpz)
  606. D="`basename %f ."$EXT"`.tar";;
  607. esac
  608. if [ "$EXT" = "bz2" ]; then
  609. bunzip2 -v %f
  610. gzip -f9 -v "$D"
  611. else
  612. gunzip -v %f
  613. bzip2 -v "$D"
  614. fi
  615. + t t
  616. c Convert gz<->bz2, tar.gz/tgz<->tar.bz2 tagged files
  617. for i in %t ; do
  618. unset D
  619. unset EXT
  620. case "$i" in
  621. *.Z)
  622. EXT=Z;;
  623. *.bz2)
  624. EXT=bz2;;
  625. *.gz)
  626. EXT=gz;;
  627. *.tgz)
  628. EXT=tgz;;
  629. *.tpz)
  630. EXT=tpz;;
  631. *.z)
  632. EXT=z;;
  633. esac
  634. case "$EXT" in
  635. bz2|Z|gz|z)
  636. D=`basename "$i" ."$EXT"`;;
  637. tgz|tpz)
  638. D=`basename "$i" ."$EXT"`.tar;;
  639. esac
  640. if [ "$EXT" = "bz2" ]; then
  641. bunzip2 -v "$i"
  642. gzip -f9 -v "$D"
  643. else
  644. gunzip -v "$i"
  645. bzip2 -v "$D"
  646. fi
  647. done
  648. + ! t t
  649. j Convert any->xz (using 7z)
  650. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  651. i=%f
  652. case "$i" in
  653. *.Z|*.bz2|*.gz|*.z|*.Z|*.bz2|*.tar.rar|*.tar.7z|*.zst)
  654. EXT=xz;;
  655. *.tgz|*.tbz2|*.tzst|*.tpz)
  656. EXT=tar.xz;;
  657. *)
  658. echo "Unsupported compression."; exit 255;;
  659. esac
  660. ${P7ZIP} e -so "$i" | ${P7ZIP} a -si -txz -m0=lzma2 -ms=on $COMPRESS_OPTS_7Z "${i%.*}.$EXT" && [ -s "${i%.*}.$EXT" ] && rm -vf "${i}"
  661. + t t
  662. j Convert any->xz (using 7z)
  663. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  664. for i in %t ; do
  665. case "$i" in
  666. *.Z|*.bz2|*.gz|*.z|*.Z|*.bz2|*.tar.rar|*.tar.7z|*.zst)
  667. EXT=xz;;
  668. *.tgz|*.tbz2|*.tzst|*.tpz|*.txz)
  669. EXT=tar.xz;;
  670. *)
  671. echo "Unsupported compression."; exit 255;;
  672. esac
  673. ${P7ZIP} e -so "$i" | ${P7ZIP} a -si -txz -m0=lzma2 -ms=on $COMPRESS_OPTS_7Z "${i%.*}.$EXT" && [ -s "${i%.*}.$EXT" ] && rm -vf "${i}"
  674. done
  675. + ! t t
  676. J Convert any->zst (using 7z and zstd)
  677. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  678. i=%f
  679. case "$i" in
  680. *.Z|*.bz2|*.gz|*.z|*.Z|*.bz2|*.tar.rar|*.tar.7z|*.xz)
  681. EXT=zst;;
  682. *.tgz|*.tbz2|*.tzst|*.tpz|*.txz)
  683. EXT=tar.zst;;
  684. *)
  685. echo "Unsupported compression."; exit 255;;
  686. esac
  687. ${P7ZIP} e -so "$i" | zstd $COMPRESS_OPTS_ZSTD - -o "${i%.*}.$EXT" && [ -s "${i%.*}.$EXT" ] && rm -vf "${i}"
  688. + t t
  689. J Convert any->zst (using 7z and zstd)
  690. P7ZIP=`command -v 7zz` || P7ZIP=`command -v 7z` || P7ZIP=`command -v 7za`; test -z "${P7ZIP}" && echo "7zip not found, aborting..." && exit 255
  691. for i in %t ; do
  692. case "$i" in
  693. *.Z|*.bz2|*.gz|*.z|*.Z|*.bz2|*.tar.rar|*.tar.7z|*.xz)
  694. EXT=zst;;
  695. *.tgz|*.tbz2|*.tzst|*.tpz|*.txz)
  696. EXT=tar.zst;;
  697. *)
  698. echo "Unsupported compression."; exit 255;;
  699. esac
  700. ${P7ZIP} e -so "$i" | zstd $COMPRESS_OPTS_ZSTD - -o "${i%.*}.$EXT" && [ -s "${i%.*}.$EXT" ] && rm -vf "${i}"
  701. done
  702. + t t
  703. i Compare (mcdiff) tagged files or directories
  704. mcdiff %t
  705. + ! t t
  706. i Compare (mcdiff) opposite selected files
  707. if [ %d/%f = %D/%F ]; then
  708. echo "The two files must be different"
  709. exit 1
  710. fi
  711. mcdiff %d/%f %D/%F
  712. + ! t t
  713. s Calculate SHA256 checksum of the current file
  714. SHACMD=`command -v sha256sum` || SHACMD="shasum -a256"
  715. $SHACMD %f
  716. + t t
  717. s Calculate SHA256 checksum of the tagged files
  718. for i in %t ; do
  719. SHACMD=`command -v sha256sum` || SHACMD="shasum -a256"
  720. $SHACMD "$i"
  721. done
  722. + ! t t
  723. S Calculate SHA512 checksum of the current file
  724. SHACMD=`command -v sha512sum` || SHACMD="shasum -a512"
  725. $SHACMD %f
  726. + t t
  727. S Calculate SHA512 checksum of the tagged files
  728. for i in %t ; do
  729. SHACMD=`command -v sha512sum` || SHACMD="shasum -a512"
  730. $SHACMD "$i"
  731. done