How to know when mc is running in a terminal

Mike Smithson mdooligan at gmail.com
Mon Nov 10 21:21:25 UTC 2014


Thanks frank. The answer was in front of my nose the whole time.

Environment variable MC_TMPDIR can be used to know that you're being
called from mc. For some reason MC_SID disappears but MC_TMPDIR does
not.

I needed something more specific than just knowing whether I'm
in pts or not. I want to know if it's mc's F4 EDIT command calling, or
at least being called from a terminal with mc running in it.

if [ -n "$DISPLAY" -a -n "$MC_TMPDIR" ]; then
     # we're being called from mc in XWindow terminal
     do_something_odd
fi


On Mon, 10 Nov 2014 02:06:26 -0800, frank <y199mp1505 at gmail.com> wrote:

>
>
> On 10/11/2014 01:25, Mike Smithson wrote:
>> how can a script know whether it is being
>> called from F4 in mc or just a terminal?
>
> Try the shell command 'tty'. In the Linux console it will reply e.g.  
> /dev/tty1. In a graphic terminal the reply will be /dev/pts/0.
>



-- 
Peace and Cheer



More information about the mc mailing list