mc.menu.in 12 KB

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