Navigate directories with MC

Paul Westell pwestell at shawlink.ca
Fri Feb 8 23:38:22 UTC 2019


Gilberto F da Silva via mc wrote on 02/08/2019 09:33 AM:
>      Since when I started using Linux around the 2000s I use mc. I can
>      not use Linux if mc is not installed on it. I'm having a hard time
>      using mc in Debian 9.x. I browse the directories and when I leave
>      the mc I go back to the directory where I called mc. In Slackware,
>      mc behaves differently. When I leave the mc I stay in the last
>      visited directory.


Slackware has two scripts that accomplish the directory change. Two versions 
are supplied for each, for Bash and for C-Shell.

Permissions should be 755.

Both are written with no shebang and have a trailing line. I'm not sure if 
Debian still defaults to something other than Bash, you may have to add a 
shebang calling Bash (#! /bin/bash) to make these work on a Debian system.


The first is 'mc.sh' which located in "/etc/profile.d" This directory contains 
the Slackware login scripts. Debian may place these scripts somewhere else.
   This simply defines an alias, I find it convenient to add mc switches here 
rather than the command line.


The second is 'mc-wrapper.sh' located in "/usr/share/mc/bin/"
   This is how mc is set to remember the new directory on exit. MC used to 
remember which pane was active on exit, but this capacity was removed for some 
reason. MC now opens always with the left pane active, swapping panes if the 
right pane was active on exit.



  ------- BEGIN '/etc/profile.d/mc.sh' -------
alias mc='. /usr/share/mc/bin/mc-wrapper.sh'

  ------- END -------



  ------- BEGIN "mc.sh" with my switches -------
alias mc='. /usr/share/mc/bin/mc-wrapper.sh -d -X'

  ------- END -------



  ------- BEGIN '/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
unset MC_USER

  ------- END -------


________________________________________________
Paul

  ... on an island, somewhere in the Pacific ...



More information about the mc mailing list