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