mc.menu 7.8 KB

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