[linux] pracovny adresar po opusteni mc

Peter Mann Peter.Mann na tuke.sk
Úterý Březen 23 06:26:26 CET 2004


On Tue, Mar 23, 2004 at 01:19:02AM +0100, Tomas Zatko wrote:
> Pri mdk som bol zvyknuty, ze ked sa v mc dostanem do
> /velmi/zahrabaneho/folderu
> a potom ukoncim mc, ze v tomto folderi zostanem.
> 
> Nikdy som sa nezamyslal ako toto "udelatko" funguje, ale teraz by sa mi 
> to vediet naramne zislo ;-)
> Debian Sarge

ako postupovat v takychto pripadoch:

pozri si /usr/share/doc/mc/README.Debian:

If you want to learn some interesting usage tips, you should read the
Midnight Commander FAQ (/usr/share/doc/mc/FAQ, also available through
the Debian doc-base interface).

takze pokracujeme na /usr/share/doc/mc/FAQ.gz (dal som hladat "dir")

a tam je:

6.1 How do I stay in the last directory when I exit Midnight Commander?

   See the description of the -P option in the Options section of the
   manual.

takze ideme dalej: man mc

       -P file, --printwd=file
              	Print the last working directory to the specified file.
		This option is not meant to be used directly.  Instead, 
		it's used from a special shell script that automatically 
		changes the current directory of the shell to the last 
		directory the Midnight Commander was  in.   Source  the
		file  /usr/share/mc/bin/mc.sh (bash and zsh users) or 
		/usr/share/mc/bin/mc.csh (tcsh users) respectively to 
		define mc as an alias to the appropriate shell script.


cat /usr/share/mc/bin/mc.sh
alias mc='. /usr/share/mc/bin/mc-wrapper.sh'


cat /usr/share/mc/bin/mc-wrapper.sh
MC_USER=`id | sed 's/[^(]*(//;s/).*//'`
MC_PWD_FILE="${TMPDIR-/tmp}/mc-$MC_USER/mc.pwd.$$"
/usr/bin/mc -P "$MC_PWD_FILE" "$@"

if test -r "$MC_PWD_FILE"; then
	MC_PWD="`cat $MC_PWD_FILE`"
	if test -n "$MC_PWD" && test -d "$MC_PWD"; then
		cd "$MC_PWD"
	fi
	unset MC_PWD
fi

rm -f "$MC_PWD_FILE"
unset MC_PWD_FILE


hotovo ;-))

-- 

5o   Peter.Mann at tuke.sk
     KLFMANiK ICQ 12491471
         PM2185-RIPE



Další informace o konferenci linux