Instantly share code, notes, and snippets.
-
Star
(0)
0
You must be signed in to star a gist -
Fork
(0)
0
You must be signed in to fork a gist
-
Save WorldException/da800ac16c7224c57614eca7f8324ca6 to your computer and use it in GitHub Desktop.
User menu file for Midnight Commander
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
= 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 .. && \ | |
nice -n 17 tar cvf - "$Pwd" | pigz -1 -f > "$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 .. && \ | |
nice -n 17 tar cvf - "$Pwd" | pbzip2 -v -2 -l -f > "$tar.tar.bz2" && \ | |
echo "../$tar.tar.bz2 created." | |
5 Compress the current subdirectory (tar.7z) | |
Pwd=`basename %d /` | |
echo -n "Name of the compressed file (without extension) [$Pwd]: " | |
read tar | |
if [ "$tar"x = x ]; then tar="$Pwd"; fi | |
cd .. && \ | |
nice -n 17 tar cvf - "$Pwd" | 7za a -si "$tar.tar.7z" && \ | |
echo "../$tar.tar.7z created." | |
+ 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 | |
+ t r & ! t t | |
d Delete file if a copy exists in the other directory. | |
if [ "%d" = "%D" ]; then | |
echo "The two directories must be different." | |
exit 1 | |
fi | |
if [ -f %D/%f ]; then # if two of them, then | |
if cmp -s %D/%f %f; then | |
rm %f && echo "%f: DELETED." | |
else | |
echo "%f and %D/%f differ: NOT deleted." | |
echo -n "Press RETURN " | |
read key | |
fi | |
else | |
echo "%f: No copy in %D/%f: NOT deleted." | |
fi | |
+ t t | |
D Delete tagged files if a copy exists in the other directory. | |
if [ "%d" = "%D" ]; then | |
echo "The two directores must be different." | |
exit 1 | |
fi | |
for i in %t | |
do | |
if [ -f "%D/$i" ]; then | |
SUM1="`sum $i`" | |
SUM2="`sum %D/$i`" | |
if [ "$SUM1" = "$SUM2" ]; then | |
rm "$i" && echo "${i}: DELETED." | |
else | |
echo "$i and %D/$i differ: NOT deleted." | |
fi | |
else | |
echo "%i has no copy in %D: NOT deleted." | |
fi | |
done | |
= t r | |
+ ! t t | |
r Copy file to remote host | |
echo -n "To which host?: " | |
read Host | |
echo -n "To which directory on $Host?: " | |
read Dir | |
rcp -p %f "${Host}:$Dir" | |
+ t t | |
R Copy files to remote host (no error checking) | |
echo -n "Copy files to which host?: " | |
read Host | |
echo -n "To which directory on $Host? :" | |
read Dir | |
rcp -pr %u "${Host}:$Dir" | |
=+ 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 | |
x Extract the contents of a compressed tar file | |
unset PRG | |
case %f in | |
*.tar.bz2) | |
PRG="bunzip2 -c" | |
;; | |
*.tar.gz|*.tar.z|*.tgz|*.tpz|*.tar.Z) | |
PRG="pigz -dc" | |
;; | |
*.tar.lzma) | |
PRG="lzma -dc" | |
;; | |
*.tar.lz) | |
PRG="lzip -dc" | |
;; | |
*.tar.xz) | |
PRG="xz -dc" | |
;; | |
*.tar.7z) | |
PRG="7za e -so" | |
;; | |
*) | |
exit 1 | |
;; | |
esac | |
nice -n 17 $PRG %f | tar xvf - | |
= t r | |
+ ! t t | |
y Gzip or gunzip current file | |
unset DECOMP | |
case %f in | |
*.gz) DECOMP=-d;; | |
*.[zZ]) DECOMP=-d;; | |
esac | |
nice -n 17 pigz $DECOMP -v -1 %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 | |
nice -n 17 pigz $DECOMP -v -1 "$i" | |
done | |
+ ! t t | |
b Bzip2 or bunzip2 current file | |
unset DECOMP | |
case %f in | |
*.bz2) DECOMP=-d;; | |
esac | |
nice -n 17 pbzip2 $DECOMP -2 -v %f | |
+ t t | |
B Bzip2 or bunzip2 tagged files | |
for i in %t | |
do | |
unset DECOMP | |
case "$i" in | |
*.bz2) DECOMP=-d;; | |
esac | |
nice -n 17 pbzip2 $DECOMP -2 -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 pigz -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 | nice -n 17 tar xvf -) | |
+ t t | |
Z Extract compressed tar files to subdirectories | |
for i in %t | |
do | |
set pigz -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" | nice -n 17 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 | |
unset EXT | |
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 | |
nice -n 17 bunzip2 -v %f ; nice -n 17 pigz -vf1 -v "$D" | |
else | |
nice -n 17 unpigz -v %f ; nice -n 17 pbzip2 -v "$D" | |
fi | |
+ t t | |
C Convert gz<->bz2, tar.gz<->tar.bz2 & tgz->tar.bz2 | |
set %t | |
while [ -n "$1" ] | |
do | |
unset D | |
unset EXT | |
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 | |
nice -n 17 bunzip2 -v "$1" | |
nice -n 17 pigz -vf1 -v "$D" | |
else | |
nice -n 17 unpigz -v "$1" | |
nice -n 17 pbzip2 -v "$D" | |
fi | |
shift | |
done | |
+ x /usr/bin/open | x /usr/local/bin/open & x /bin/sh | |
o Open next a free console | |
open -s -- sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment