mc.menu.in 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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. + ! t t
  24. @ Do something on the current file
  25. CMD=%{Enter command}
  26. $CMD %f
  27. + t t
  28. @ Do something on the tagged files
  29. CMD=%{Enter command}
  30. for i in %t ; do
  31. $CMD "$i"
  32. done
  33. 0 Edit a bug report and send it to root
  34. I=`mktemp "${MC_TMPDIR:-/tmp}/mail.XXXXXX"` || exit 1
  35. ${EDITOR-vi} "$I"
  36. test -r "$I" && mail root < "$I"
  37. rm -f "$I"
  38. =+ f \.1$ | f \.3$ | f \.4$ | f \.5$ | f \.6$ | f \.7$ | f \.8$ | f \.man$ & t r
  39. 1 Display the file with roff -man
  40. %view{ascii,nroff} roff @MAN_FLAGS@ @MANDOC@ %f
  41. 2 Call the info hypertext browser
  42. info
  43. = t d
  44. 3 Compress the current subdirectory (tar.gz)
  45. Pwd=`basename %d /`
  46. echo -n "Name of the compressed file (without extension) [$Pwd]: "
  47. read tar
  48. [ "$tar"x = x ] && tar="$Pwd"
  49. cd .. && \
  50. tar cf - "$Pwd" | gzip -f9 > "$tar.tar.gz" && \
  51. echo "../$tar.tar.gz created."
  52. 4 Compress the current subdirectory (tar.bz2)
  53. Pwd=`basename %d /`
  54. echo -n "Name of the compressed file (without extension) [$Pwd]: "
  55. read tar
  56. [ "$tar"x = x ] && tar="$Pwd"
  57. cd .. && \
  58. tar cf - "$Pwd" | bzip2 -f > "$tar.tar.bz2" && \
  59. echo "../$tar.tar.bz2 created."
  60. 5 Compress the current subdirectory (tar.7z)
  61. Pwd=`basename %d /`
  62. echo -n "Name of the compressed file (without extension) [$Pwd]: "
  63. read tar
  64. [ "$tar"x = x ] && tar="$Pwd"
  65. cd .. && \
  66. tar cf - "$Pwd" | 7za a -si "$tar.tar.7z" && \
  67. echo "../$tar.tar.7z created."
  68. 6 Compress the current subdirectory (tar.xz)
  69. Pwd=`basename %d /`
  70. echo -n "Name of the compressed file (without extension) [$Pwd]: "
  71. read tar
  72. [ "$tar"x = x ] && tar="$Pwd"
  73. cd .. && \
  74. tar cf - "$Pwd" | xz -f > "$tar.tar.xz" && \
  75. echo "../$tar.tar.xz created."
  76. 7 Compress the current subdirectory (tar.zst)
  77. Pwd=`basename %d /`
  78. echo -n "Name of the compressed file (without extension) [$Pwd]: "
  79. read tar
  80. [ "$tar"x = x ] && tar="$Pwd"
  81. cd .. && \
  82. tar cf - "$Pwd" | zstd -f > "$tar.tar.zst" && \
  83. echo "../$tar.tar.zst created."
  84. 8 Compress the current subdirectory (tar.lzo)
  85. Pwd=`basename %d /`
  86. echo -n "Name of the compressed file (without extension) [$Pwd]: "
  87. read tar
  88. [ "$tar"x = x ] && tar="$Pwd"
  89. cd .. && \
  90. tar cf - "$Pwd" | lzop -f > "$tar.tar.lzo" && \
  91. echo "../$tar.tar.lzo created."
  92. = f \.c$ & t r
  93. + f \.c$ & t r & ! t t
  94. c Compile and link current .c file
  95. make "`basename %f .c`" 2>/dev/null || cc -O -o "`basename %f .c`" %f
  96. + t r & ! t t
  97. a Append file to opposite
  98. cat %f >> %D/%f
  99. + t t
  100. A Append files to opposite files
  101. for i in %t ; do
  102. cat "$i" >> %D/"$i"
  103. done
  104. + t r & ! t t
  105. d Delete file if a copy exists in the other directory.
  106. if [ %d = %D ]; then
  107. echo "The two directories must be different."
  108. exit 1
  109. fi
  110. if [ -f %D/%f ]; then # if two of them, then
  111. if cmp -s %D/%f %f; then
  112. rm %f && echo %f": DELETED."
  113. else
  114. echo %f" and "%D/%f" differ: NOT deleted."
  115. echo -n "Press RETURN "
  116. read key
  117. fi
  118. else
  119. echo %f": No copy in "%D/%f": NOT deleted."
  120. fi
  121. + t t
  122. D Delete tagged files if a copy exists in the other directory.
  123. if [ %d = %D ]; then
  124. echo "The two directories must be different."
  125. exit 1
  126. fi
  127. for i in %t ; do
  128. if [ -f %D/"$i" ]; then
  129. SUM1=`sum "$i"`
  130. SUM2=`sum %D/"$i"`
  131. if [ "$SUM1" = "$SUM2" ]; then
  132. rm "$i" && echo "${i}: DELETED."
  133. else
  134. echo "$i and "%D"/$i differ: NOT deleted."
  135. fi
  136. else
  137. echo "$i has no copy in "%D": NOT deleted."
  138. fi
  139. done
  140. m View manual page
  141. MAN=%{Enter manual name}
  142. %view{ascii,nroff} MANROFFOPT='@MAN_FLAGS@' MAN_KEEP_FORMATTING=1 man -P cat "$MAN"
  143. = f \.gz$ & t r
  144. + ! t t
  145. n Inspect gzip'ed newsbatch file
  146. dd if=%f bs=1 skip=12 | zcat | ${PAGER-more}
  147. # assuming the cunbatch header is 12 bytes long.
  148. = t r &
  149. + ! t t
  150. h Strip headers from current newsarticle
  151. CHECK=`awk '{print $1 ; exit}' %f` 2>/dev/null
  152. case "$CHECK" in
  153. Newsgroups:|Path:)
  154. I=`mktemp "${MC_TMPDIR:-/tmp}/news.XXXXXX"` || exit 1
  155. cp %f "$I" && sed '/^'"$CHECK"' /,/^$/d' "$I" > %f
  156. [ "$?" = "0" ] && rm "$I"
  157. echo %f": header removed."
  158. ;;
  159. *)
  160. echo %f" is not a news article."
  161. ;;
  162. esac
  163. + t t
  164. H Strip headers from the marked newsarticles
  165. for i in %t ; do
  166. CHECK=`awk '{print $1 ; exit}' "$i"` 2>/dev/null
  167. WFILE=`mktemp "${MC_TMPDIR:-/tmp}/news.XXXXXX"` || exit 1
  168. case "$CHECK" in
  169. Newsgroups:|Path:)
  170. cp "$i" "$WFILE" && sed '/^'"$CHECK"' /,/^$/d' "$WFILE" > "$i"
  171. if [ "$?" = "0" ]; then
  172. rm "$WFILE"; echo "$i header removed. OK."
  173. else
  174. echo "Oops! Please check $i against $WFILE."
  175. fi
  176. ;;
  177. *)
  178. echo "$i skipped: Not a news article."
  179. ;;
  180. esac
  181. done
  182. = t r
  183. + ! t t
  184. r Copy file to remote host
  185. echo -n "To which host?: "
  186. read Host
  187. echo -n "To which directory on $Host?: "
  188. read Dir
  189. rcp -p %f "${Host}:${Dir}"
  190. + t t
  191. R Copy files to remote host (no error checking)
  192. echo -n "Copy files to which host?: "
  193. read Host
  194. echo -n "To which directory on $Host? :"
  195. read Dir
  196. rcp -pr %u "${Host}:${Dir}"
  197. = f \.tex$ & t r
  198. + f \.tex$ & t r & ! t t
  199. t Run latex on file and show it with xdvi
  200. latex %f && xdvi "`basename %f .tex`".dvi
  201. =+ f ^part | f ^Part | f uue & t r
  202. + t t
  203. U Uudecode marked news articles (needs work)
  204. (
  205. for i in %t ; do # strip headers
  206. FIRST=`awk '{print $1 ; exit}' "$i"`
  207. cat "$i" | sed '/^'"$FIRST"' /,/^$/d'
  208. done
  209. ) | sed '/^$/d' | sed -n '/^begin 6/,/^end$/p' | uudecode
  210. if [ "$?" != "0" ]; then
  211. echo "Cannot decode "%t"."
  212. fi
  213. echo "Please test the output file before deleting anything."
  214. =+ 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 \.tar\.zst | f \.tar\.Z$ | f \.tar\.bz2$ & t rl
  215. x Extract the contents of a compressed tar file
  216. unset PRG
  217. case %f in
  218. *.tar.7z) PRG="7za e -so";;
  219. *.tar.bz2) PRG="bunzip2 -c";;
  220. *.tar.gz|*.tar.z|*.tgz|*.tpz|*.tar.Z) PRG="gzip -dc";;
  221. *.tar.lz) PRG="lzip -dc";;
  222. *.tar.lz4) PRG="lz4 -dc";;
  223. *.tar.lzma) PRG="lzma -dc";;
  224. *.tar.lzo) PRG="lzop -dc";;
  225. *.tar.xz) PRG="xz -dc";;
  226. *.tar.zst) PRG="zstd -dc";;
  227. *) exit 1;;
  228. esac
  229. $PRG %f | tar xvf -
  230. = t r
  231. + ! t t
  232. y Gzip or gunzip current file
  233. unset DECOMP
  234. case %f in
  235. *.gz|*.[zZ]) DECOMP=-d;;
  236. esac
  237. # Do *not* add quotes around $DECOMP!
  238. gzip $DECOMP -v %f
  239. + t t
  240. Y Gzip or gunzip tagged files
  241. for i in %t ; do
  242. unset DECOMP
  243. case "$i" in
  244. *.gz|*.[zZ]) DECOMP=-d;;
  245. esac
  246. gzip $DECOMP -v "$i"
  247. done
  248. + ! t t
  249. b Bzip2 or bunzip2 current file
  250. unset DECOMP
  251. case %f in
  252. *.bz2) DECOMP=-d;;
  253. esac
  254. bzip2 $DECOMP -v %f
  255. + t t
  256. B Bzip2 or bunzip2 tagged files
  257. for i in %t ; do
  258. unset DECOMP
  259. case "$i" in
  260. *.bz2) DECOMP=-d;;
  261. esac
  262. bzip2 $DECOMP -v "$i"
  263. done
  264. + f \.tar.gz$ | f \.tgz$ | f \.tpz$ | f \.tar.Z$ | f \.tar.z$ | f \.tar.bz2$ | f \.tar.F$ & t r & ! t t
  265. z Extract compressed tar file to subdirectory
  266. unset D
  267. set gzip -cd
  268. case %f in
  269. *.tar.F) D=`basename %f .tar.F`; set freeze -dc;;
  270. *.tar.Z) D=`basename %f .tar.Z`;;
  271. *.tar.bz2) D=`basename %f .tar.bz2`; set bunzip2 -c;;
  272. *.tar.gz) D=`basename %f .tar.gz`;;
  273. *.tar.z) D=`basename %f .tar.z`;;
  274. *.tgz) D=`basename %f .tgz`;;
  275. *.tpz) D=`basename %f .tpz`;;
  276. esac
  277. mkdir "$D"; cd "$D" && ("$1" "$2" ../%f | tar xvf -)
  278. + t t
  279. Z Extract compressed tar files to subdirectories
  280. for i in %t ; do
  281. set gzip -dc
  282. unset D
  283. case "$i" in
  284. *.tar.F) D=`basename "$i" .tar.F`; set freeze -dc;;
  285. *.tar.Z) D=`basename "$i" .tar.Z`;;
  286. *.tar.bz2) D=`basename "$i" .tar.bz2`; set bunzip2 -c;;
  287. *.tar.gz) D=`basename "$i" .tar.gz`;;
  288. *.tar.z) D=`basename "$i" .tar.z`;;
  289. *.tgz) D=`basename "$i" .tgz`;;
  290. *.tpz) D=`basename "$i" .tpz`;;
  291. esac
  292. mkdir "$D"; (cd "$D" && "$1" "$2" "../$i" | tar xvf -)
  293. done
  294. + f \.gz$ | f \.tgz$ | f \.tpz$ | f \.Z$ | f \.z$ | f \.bz2$ & t r & ! t t
  295. c Convert gz<->bz2, tar.gz<->tar.bz2 & tgz->tar.bz2
  296. unset D
  297. unset EXT
  298. case %f in
  299. *.Z) EXT=Z;;
  300. *.bz2) EXT=bz2;;
  301. *.gz) EXT=gz;;
  302. *.tgz) EXT=tgz;;
  303. *.tpz) EXT=tpz;;
  304. *.z) EXT=z;;
  305. esac
  306. case "$EXT" in
  307. bz2|Z|gz|z) D=`basename %f ."$EXT"`;;
  308. tgz|tpz) D=`basename %f ."$EXT"`.tar;;
  309. esac
  310. if [ "$EXT" = "bz2" ]; then
  311. bunzip2 -v %f
  312. gzip -f9 -v "$D"
  313. else
  314. gunzip -v %f
  315. bzip2 -v "$D"
  316. fi
  317. + t t
  318. C Convert gz<->bz2, tar.gz<->tar.bz2 & tgz->tar.bz2
  319. for i in %t ; do
  320. unset D
  321. unset EXT
  322. case "$i" in
  323. *.Z) EXT=Z;;
  324. *.bz2) EXT=bz2;;
  325. *.gz) EXT=gz;;
  326. *.tgz) EXT=tgz;;
  327. *.tpz) EXT=tpz;;
  328. *.z) EXT=z;;
  329. esac
  330. case "$EXT" in
  331. bz2|Z|gz|z) D=`basename "$i" ."$EXT"`;;
  332. tgz|tpz) D=`basename "$i" ."$EXT"`.tar;;
  333. esac
  334. if [ "$EXT" = "bz2" ]; then
  335. bunzip2 -v "$i"
  336. gzip -f9 -v "$D"
  337. else
  338. gunzip -v "$i"
  339. bzip2 -v "$D"
  340. fi
  341. done
  342. + x /usr/bin/open | x /usr/local/bin/open & x /bin/sh
  343. o Open next a free console
  344. open -s -- sh