lib/mcconfig/history.c: fix comments.
[midnight-commander.git] / misc / mc.menu.in
blobc491858f56c50342792f21f65e13e76a74f0b7d0
1 shell_patterns=0
3 ##############################################################################
4 #   %%  The % character
5 #   %f  The current file (if non-local vfs, file will be copied locally and
6 #                         %f will be full path to it)
7 #   %p  The current file
8 #   %d  The current working directory
9 #   %s  "Selected files"; the tagged files if any, otherwise the current file
10 #   %t  Tagged files
11 #   %u  Tagged files (and they are untagged on return from expand_format)
12 #   %view Runs the commands and pipes standard output to the view command
13 #   If %view is immediately followed by '{', recognize keywords
14 #   ascii, hex, nroff and unform
16 #   If the format letter is in uppercase, it refers to the other panel
18 #   With a number followed the % character you can turn quoting on (default)
19 #   and off. For example:
20 #   %f    quote expanded macro
21 #   %1f   ditto
22 #   %0f   don't quote expanded macro
23 ##############################################################################
25 + ! t t
26 @       Do something on the current file
27         CMD=%{Enter command}
28         $CMD %f
30 + t t
31 @       Do something on the tagged files
32         CMD=%{Enter command}
33         for i in %t ; do
34             $CMD "$i"
35         done
37 0       Edit a bug report and send it to root
38         I=`mktemp "${MC_TMPDIR:-/tmp}/mail.XXXXXX"` || exit 1
39         ${EDITOR-vi} "$I"
40         test -r "$I" && mail root < "$I"
41         rm -f "$I"
43 =+ f \.1$ | f \.3$ | f \.4$ | f \.5$ | f \.6$ | f \.7$ | f \.8$ | f \.man$ & t r
44 1       Display the file with roff -man
45         %view{ascii,nroff} roff @MAN_FLAGS@ @MANDOC@ %f
47 2       Call the info hypertext browser
48         info
50 = t d
51 3       Compress the current subdirectory (tar.gz)
52         Pwd=`basename %d /`
53         echo -n "Name of the compressed file (without extension) [$Pwd]: "
54         read tar
55         [ "$tar"x = x ] && tar="$Pwd"
56         cd .. && \
57         tar cf - "$Pwd" | gzip -f9 > "$tar.tar.gz" && \
58         echo "../$tar.tar.gz created."
60 4       Compress the current subdirectory (tar.bz2)
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" | bzip2 -f > "$tar.tar.bz2" && \
67         echo "../$tar.tar.bz2 created."
69 5       Compress the current subdirectory (tar.7z)
70         Pwd=`basename %d /`
71         echo -n "Name of the compressed file (without extension) [$Pwd]: "
72         read tar
73         [ "$tar"x = x ] && tar="$Pwd"
74         cd .. && \
75         tar cf - "$Pwd" | 7za a -si "$tar.tar.7z" && \
76         echo "../$tar.tar.7z created."
78 6       Compress the current subdirectory (tar.xz)
79         Pwd=`basename %d /`
80         echo -n "Name of the compressed file (without extension) [$Pwd]: "
81         read tar
82         [ "$tar"x = x ] && tar="$Pwd"
83         cd .. && \
84         tar cf - "$Pwd" | xz -f > "$tar.tar.xz" && \
85         echo "../$tar.tar.xz created."
87 7       Compress the current subdirectory (tar.zst)
88         Pwd=`basename %d /`
89         echo -n "Name of the compressed file (without extension) [$Pwd]: "
90         read tar
91         [ "$tar"x = x ] && tar="$Pwd"
92         cd .. && \
93         tar cf - "$Pwd" | zstd -f > "$tar.tar.zst" && \
94         echo "../$tar.tar.zst created."
96 = f \.c$ & t r
97 + f \.c$ & t r & ! t t
98 c       Compile and link current .c file
99         make "`basename %f .c`" 2>/dev/null || cc -O -o "`basename %f .c`" %f
101 + t r & ! t t
102 a       Append file to opposite
103         cat %f >> %D/%f
105 + t t
106 A       Append files to opposite files
107         for i in %t ; do
108             cat "$i" >> %D/"$i"
109         done
111 + t r & ! t t
112 d       Delete file if a copy exists in the other directory.
113         if [ %d = %D ]; then
114             echo "The two directories must be different."
115             exit 1
116         fi
117         if [ -f %D/%f ]; then        # if two of them, then
118             if cmp -s %D/%f %f; then
119                 rm %f && echo %f": DELETED."
120             else
121                 echo %f" and "%D/%f" differ: NOT deleted."
122                 echo -n "Press RETURN "
123                 read key
124             fi
125         else
126             echo %f": No copy in "%D/%f": NOT deleted."
127         fi
129 + t t
130 D       Delete tagged files if a copy exists in the other directory.
131         if [ %d = %D ]; then
132             echo "The two directories must be different."
133             exit 1
134         fi
135         for i in %t ; do
136             if [ -f %D/"$i" ]; then
137                 SUM1=`sum "$i"`
138                 SUM2=`sum %D/"$i"`
139                 if [ "$SUM1" = "$SUM2" ]; then
140                     rm "$i" && echo "${i}: DELETED."
141                 else
142                     echo "$i and "%D"/$i differ: NOT deleted."
143                 fi
144             else
145                 echo "$i has no copy in "%D": NOT deleted."
146             fi
147         done
149 m       View manual page
150         MAN=%{Enter manual name}
151         %view{ascii,nroff} MANROFFOPT='@MAN_FLAGS@' MAN_KEEP_FORMATTING=1 man -P cat "$MAN"
153 = f \.gz$ & t r
154 + ! t t
155 n       Inspect gzip'ed newsbatch file
156         dd if=%f bs=1 skip=12 | zcat | ${PAGER-more}
157         # assuming the cunbatch header is 12 bytes long.
159 = t r &
160 + ! t t
161 h       Strip headers from current newsarticle
162         CHECK=`awk '{print $1 ; exit}' %f` 2>/dev/null
163         case "$CHECK" in
164             Newsgroups:|Path:)
165                 I=`mktemp "${MC_TMPDIR:-/tmp}/news.XXXXXX"` || exit 1
166                 cp %f "$I" && sed '/^'"$CHECK"' /,/^$/d' "$I" > %f
167                 [ "$?" = "0" ] && rm "$I"
168                 echo %f": header removed."
169                 ;;
170             *)
171                 echo %f" is not a news article."
172                 ;;
173         esac
175 + t t
176 H       Strip headers from the marked newsarticles
177         for i in %t ; do
178             CHECK=`awk '{print $1 ; exit}' "$i"` 2>/dev/null
179             WFILE=`mktemp "${MC_TMPDIR:-/tmp}/news.XXXXXX"` || exit 1
180             case "$CHECK" in
181                 Newsgroups:|Path:)
182                     cp "$i" "$WFILE" && sed '/^'"$CHECK"' /,/^$/d' "$WFILE" > "$i"
183                     if [ "$?" = "0" ]; then
184                         rm "$WFILE"; echo "$i header removed. OK."
185                     else
186                         echo "Oops! Please check $i against $WFILE."
187                     fi
188                     ;;
189                 *)
190                     echo "$i skipped: Not a news article."
191                     ;;
192             esac
193         done
195 = t r
196 + ! t t
197 r       Copy file to remote host
198         echo -n "To which host?: "
199         read Host
200         echo -n "To which directory on $Host?: "
201         read Dir
202         rcp -p %f "${Host}:${Dir}"
204 + t t
205 R       Copy files to remote host (no error checking)
206         echo -n "Copy files to which host?: "
207         read Host
208         echo -n "To which directory on $Host? :"
209         read Dir
210         rcp -pr %u "${Host}:${Dir}"
212 = f \.tex$ & t r
213 + f \.tex$ & t r & ! t t
214 t       Run latex on file and show it with xdvi
215         latex %f && xdvi "`basename %f .tex`".dvi
217 =+ f ^part | f ^Part | f uue & t r
218 + t t
219 U       Uudecode marked news articles (needs work)
220         (
221             for i in %t ; do # strip headers
222                 FIRST=`awk '{print $1 ; exit}' "$i"`
223                 cat "$i" | sed '/^'"$FIRST"' /,/^$/d'
224             done
225         ) | sed '/^$/d' | sed -n '/^begin 6/,/^end$/p' | uudecode
226         if [ "$?" != "0" ]; then
227             echo "Cannot decode "%t"."
228         fi
229         echo "Please test the output file before deleting anything."
231 =+ 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 rl
232 x       Extract the contents of a compressed tar file
233         unset PRG
234         case %f in
235             *.tar.7z)   PRG="7za e -so";;
236             *.tar.bz2)  PRG="bunzip2 -c";;
237             *.tar.gz|*.tar.z|*.tgz|*.tpz|*.tar.Z) PRG="gzip -dc";;
238             *.tar.lz)   PRG="lzip -dc";;
239             *.tar.lz4)  PRG="lz4 -dc";;
240             *.tar.lzma) PRG="lzma -dc";;
241             *.tar.xz)   PRG="xz -dc";;
242             *.tar.zst)  PRG="zstd -dc";;
243             *)          exit 1;;
244         esac
245         $PRG %f | tar xvf -
247 = t r
248 + ! t t
249 y       Gzip or gunzip current file
250         unset DECOMP
251         case %f in
252             *.gz|*.[zZ]) DECOMP=-d;;
253         esac
254         # Do *not* add quotes around $DECOMP!
255         gzip $DECOMP -v %f
257 + t t
258 Y       Gzip or gunzip tagged files
259         for i in %t ; do
260             unset DECOMP
261             case "$i" in
262                 *.gz|*.[zZ]) DECOMP=-d;;
263             esac
264             gzip $DECOMP -v "$i"
265         done
267 + ! t t
268 b       Bzip2 or bunzip2 current file
269         unset DECOMP
270         case %f in
271             *.bz2) DECOMP=-d;;
272         esac
273         bzip2 $DECOMP -v %f
275 + t t
276 B       Bzip2 or bunzip2 tagged files
277         for i in %t ; do
278             unset DECOMP
279             case "$i" in
280                 *.bz2) DECOMP=-d;;
281             esac
282             bzip2 $DECOMP -v "$i"
283         done
285 + f \.tar.gz$ | f \.tgz$ | f \.tpz$ | f \.tar.Z$ | f \.tar.z$ | f \.tar.bz2$ | f \.tar.F$ & t r & ! t t
286 z       Extract compressed tar file to subdirectory
287         unset D
288         set gzip -cd
289         case %f in
290             *.tar.F)   D=`basename %f .tar.F`; set freeze -dc;;
291             *.tar.Z)   D=`basename %f .tar.Z`;;
292             *.tar.bz2) D=`basename %f .tar.bz2`; set bunzip2 -c;;
293             *.tar.gz)  D=`basename %f .tar.gz`;;
294             *.tar.z)   D=`basename %f .tar.z`;;
295             *.tgz)     D=`basename %f .tgz`;;
296             *.tpz)     D=`basename %f .tpz`;;
297         esac
298         mkdir "$D"; cd "$D" && ("$1" "$2" ../%f | tar xvf -)
300 + t t
301 Z       Extract compressed tar files to subdirectories
302         for i in %t ; do
303             set gzip -dc
304             unset D
305             case "$i" in
306                 *.tar.F)   D=`basename "$i" .tar.F`; set freeze -dc;;
307                 *.tar.Z)   D=`basename "$i" .tar.Z`;;
308                 *.tar.bz2) D=`basename "$i" .tar.bz2`; set bunzip2 -c;;
309                 *.tar.gz)  D=`basename "$i" .tar.gz`;;
310                 *.tar.z)   D=`basename "$i" .tar.z`;;
311                 *.tgz)     D=`basename "$i" .tgz`;;
312                 *.tpz)     D=`basename "$i" .tpz`;;
313           esac
314           mkdir "$D"; (cd "$D" && "$1" "$2" "../$i" | tar xvf -)
315         done
317 + f \.gz$ | f \.tgz$ | f \.tpz$ | f \.Z$ | f \.z$ | f \.bz2$ & t r & ! t t
318 c       Convert gz<->bz2, tar.gz<->tar.bz2 & tgz->tar.bz2
319         unset D
320         unset EXT
321         case %f in
322             *.Z)   EXT=Z;;
323             *.bz2) EXT=bz2;;
324             *.gz)  EXT=gz;;
325             *.tgz) EXT=tgz;;
326             *.tpz) EXT=tpz;;
327             *.z)   EXT=z;;
328         esac
329         case "$EXT" in
330             bz2|Z|gz|z) D=`basename %f ."$EXT"`;;
331             tgz|tpz)    D=`basename %f ."$EXT"`.tar;;
332         esac
333         if [ "$EXT" = "bz2" ]; then
334             bunzip2 -v %f
335             gzip -f9 -v "$D"
336         else
337             gunzip -v %f
338             bzip2 -v "$D"
339         fi
341 + t t
342 C       Convert gz<->bz2, tar.gz<->tar.bz2 & tgz->tar.bz2
343         for i in %t ; do
344             unset D
345             unset EXT
346             case "$i" in
347                 *.Z)   EXT=Z;;
348                 *.bz2) EXT=bz2;;
349                 *.gz)  EXT=gz;;
350                 *.tgz) EXT=tgz;;
351                 *.tpz) EXT=tpz;;
352                 *.z)   EXT=z;;
353             esac
354             case "$EXT" in
355                 bz2|Z|gz|z) D=`basename "$i" ."$EXT"`;;
356                 tgz|tpz)    D=`basename "$i" ."$EXT"`.tar;;
357             esac
358             if [ "$EXT" = "bz2" ]; then
359                 bunzip2 -v "$i"
360                 gzip -f9 -v "$D"
361             else
362                 gunzip -v "$i"
363                 bzip2 -v "$D"
364             fi
365         done
367 + x /usr/bin/open | x /usr/local/bin/open & x /bin/sh
368 o       Open next a free console
369         open -s -- sh