Midnight Commander user menu


Forum: myDSL Extensions (deprecated)
Topic: Midnight Commander user menu
started by: mikshaw

Posted by mikshaw on Jan. 01 2005,18:59
This is a user menu for Midnight Commander which contains commands for working with archives and MyDSL extensions.  It can be used as /home/dsl/.mc/menu for use everywhere, or as /path/to/a/directory/.mc.menu for use in a particular directory.

Press F2 to bring up the menu.

DSL-specific:
If a *.tar.gz *.tgz or *.dsl file is selected, you will have the option to install using mydsl-load in the same manner as the MyDSL button in emelfm.
If a filelist is selected, you can create a MyDSL extension from it.  Currently the filelist needs to be one of the following:
files.txt
filelist.txt
list.txt
dsl.txt
More filenames can be added to this line:
+ f ^files.txt$ | f ^filelist.txt$ | f ^list.txt$ | f ^dsl.txt$
For example, if you tend to use 'mydsl.txt', the line would look like this:
+ f ^files.txt$ | f ^filelist.txt$ | f ^list.txt$ | f ^dsl.txt$ | f ^mydsl.txt$
The ^ means that's the beginning of the filename, $ means it's the end, so it wouldn't pick up on a file named 'files.txt.bak' or 'myfiles.txt'

The file list first needs to be manually edited to remove base directories, and file ownership should be checked before running.  This menu item is just a way to save having to type the tar/gzip/md5sum commands, and won't check the filelist for you.

Code Sample

shell_patterns=0
+ ! t t
@       Do something on the current file
       CMD=%{Enter command}
       $CMD %f

+ t t
@       Do something on the tagged files
       set %t; CMD=%{Enter command}
       while [ -n "$1" ]; do
         $CMD "$1"
         shift
       done

=+ f \.dsl$ | f \.tar\.gz$ | f \.tgz$ & t r
m       MyDSL
       mydsl-load %f

+ f ^files.txt$ | f ^filelist.txt$ | f ^list.txt$ | f ^dsl.txt$
M       Create a DSL extension from file list
       echo -n "Name of extension: "
       read dsl
       tar cvzf "$dsl" --numeric-owner --no-recursion -T %f && md5sum "$dsl" > "$dsl.md5.txt"

= t d
3       Compress the current subdirectory (tar.gz)
       Pwd=`basename "%d" /`
       echo -n "Name of the compressed file (without extension) [$Pwd]: "
       read tar
       if [ "$tar"x = x ]; then tar="$Pwd"; fi
       cd .. && \
       tar cf - "$Pwd" | gzip -f9 > "$tar.tar.gz" && \
       echo "../$tar.tar.gz created."

4       Compress the current subdirectory (tar.bz2)
       Pwd=`basename %d /`
       echo -n "Name of the compressed file (without extension) [$Pwd]: "
       read tar
       if [ "$tar"x = x ]; then tar="$Pwd"; fi
       cd .. && \
       tar cf - "$Pwd" | bzip2 -f > "$tar.tar.bz2" && \
       echo "../$tar.tar.bz2 created."

+ f \.tar\.gz$ | f \.tar\.z$ | f \.tgz$ | f \.tpz$ | f \.tar\.Z$| f \.tar\.bz2$ & t r
x       Extract the contents of a compressed tar file
       unset EXT
       case %f in
           *.tar.bz2) EXT=tar_bz2;;
       esac
       if [ "$EXT" = "tar_bz2" ]; then
         bunzip2 -c %f | tar xvf -
       else
         gzip -dc %f | tar xvf -
       fi

+ ! t t
y       Gzip or gunzip current file
       unset DECOMP
       case %f in
           *.gz) DECOMP=-d;;
           *.[zZ]) DECOMP=-d;;
       esac
       gzip $DECOMP -v %f

+ t t
Y       Gzip or gunzip tagged files
       for i in %t
       do
         unset DECOMP
         case $i in
           *.gz) DECOMP=-d;;
           *.[zZ]) DECOMP=-d;;
         esac
         gzip $DECOMP -v $i
       done

+ ! t t
b       Bzip2 or bunzip2 current file
       unset DECOMP
       case %f in
           *.bz2) DECOMP=-d;;
       esac
       bzip2 $DECOMP -v %f

+ t t
B       Bzip2 or bunzip2 tagged files
       for i in %t
       do
         unset DECOMP
         case $i in
           *.bz2) DECOMP=-d;;
         esac
         bzip2 $DECOMP -v $i
       done

+ f \.tar.gz$ | f \.tgz$ | f \.tpz$ | f \.tar.Z$ | f \.tar.z$ | f \.tar.bz2$ | f \.tar.F$ & t r & ! t t
z       Extract compressed tar file to subdirectory
       unset D
       set gzip -cd
       case %f in
         *.tar.gz) D="`basename %f .tar.gz`";;
         *.tgz)    D="`basename %f .tgz`";;
         *.tpz)    D="`basename %f .tpz`";;
         *.tar.Z)  D="`basename %f .tar.Z`";;
         *.tar.z)  D="`basename %f .tar.z`";;
         *.tar.bz2) D="`basename %f .tar.bz2`"; set bunzip2 -c;;
         *.tar.F) D="`basename %f .tar.F`"; set freeze -dc;
       esac
       mkdir $D; cd $D && ($1 $2 ../%f | tar xvf -)

+ t t
Z       Extract compressed tar files to subdirectories
       for i in %t
       do
         set gzip -dc
         unset D
         case $i in
           *.tar.gz)  D="`basename $i .tar.gz`";;
           *.tgz)     D="`basename $i .tgz`";;
           *.tpz)     D="`basename $i .tpz`";;
           *.tar.Z)   D="`basename $i .tar.Z`";;
           *.tar.z)   D="`basename $i .tar.z`";;
           *.tar.F)   D="`basename $i .tar.F`"; set freeze -dc;;
           *.tar.bz2) D="`basename $i .tar.bz2`"; set bunzip2 -c;;
         esac
         mkdir $D; (cd $D && $1 $2 ../$i | tar xvf -)
       done

+ f \.gz$ | f \.tgz$ | f \.tpz$ | f \.Z$ | f \.z$ | f \.bz2$ & t r & ! t t
c       Convert gz<->bz2, tar.gz<->tar.bz2 & tgz->tar.bz2
       unset D
       case %f in
           *.tgz)      EXT=tgz;;
           *.tpz)      EXT=tpz;;
           *.Z)        EXT=Z;;
           *.z)        EXT=z;;
           *.gz)       EXT=gz;;
           *.bz2)      EXT=bz2;;
       esac
       case $EXT in
         tgz|tpz)      D="`basename %f .$EXT`.tar";;
         gz|Z|z)       D="`basename %f .$EXT`";;
         bz2)          D="`basename %f .bz2`";;
       esac
       if [ "$EXT" = "bz2" ]; then
           bunzip2 -v %f; gzip -f9 -v $D
       else
           gunzip -v %f; bzip2 -v $D
       fi

+ t t
C       Convert gz<->bz2, tar.gz<->tar.bz2 & tgz->tar.bz2
       set %t
       while [ -n "$1" ]
       do
         unset D
         case $1 in
           *.tgz)      EXT=tgz;;
           *.tpz)      EXT=tpz;;
           *.Z)        EXT=Z;;
           *.z)        EXT=z;;
           *.gz)       EXT=gz;;
           *.bz2)      EXT=bz2;;
         esac
         case $EXT in
             tgz)    D="`basename $1 .tgz`.tar";;
             tpz)    D="`basename $1 .tpz`.tar";;
             gz|Z|z) D="`basename $1 .$EXT`";;
             bz2)    D="`basename $1 .bz2`";;
         esac
         if [ "$EXT" = "bz2" ]; then
           bunzip2 -v $1
           gzip -f9 -v $D
         else
           gunzip -v $1
           bzip2 -v $D
         fi
         shift
       done

+ t r & ! t t
a       Append file to opposite
       cat %f >>%D/%f

+ t t
A       Append files to opposite files
       set %t
       while [ -n "$1" ]; do
         cat $1 >>%D/$1
         shift
       done

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.