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