mc.menu 9.3 KB

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