Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
midnight commander doesn't stay in directory
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Linubie
Guru
Guru


Joined: 11 Jun 2004
Posts: 381

PostPosted: Fri Oct 11, 2024 1:21 pm    Post subject: midnight commander doesn't stay in directory Reply with quote

I've added
Code:
alias mc='. /usr/libexec/mc/mc-wrapper.sh'

to /etc/bash/bashrc

opening KDE Konsole and execute:

Code:
alias mc='. /usr/libexec/mc/mc-wrapper.sh'


and then
Code:
mc

neither works.

I need to change the directories with cd.
_________________
Mircosoft software is like having sex with a stranger, you always have to be careful not to get infected with something...
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22495

PostPosted: Fri Oct 11, 2024 3:29 pm    Post subject: Reply with quote

From the output you provided, it looks like the alias mc should be invoked. What do you see that makes you think it did not work?
Back to top
View user's profile Send private message
Banana
Moderator
Moderator


Joined: 21 May 2004
Posts: 1674
Location: Germany

PostPosted: Fri Oct 11, 2024 5:54 pm    Post subject: Reply with quote

The current stable ebuild has this:

Code:
elog "To enable exiting to latest working directory,"
elog "put this into your ~/.bashrc:"
elog ". ${EPREFIX}/usr/libexec/mc/mc.sh"


So yours look different, old or even wrong.
_________________
Forum Guidelines

PFL - Portage file list - find which package a file or command belongs to.
My delta-labs.org snippets do expire
Back to top
View user's profile Send private message
Linubie
Guru
Guru


Joined: 11 Jun 2004
Posts: 381

PostPosted: Fri Oct 11, 2024 5:55 pm    Post subject: Reply with quote

Well opening mc, changing directories and quit mc I am in the same directory, in that I began before starting mc ;O)
Let's say I started mc in directory /usr change the directory within mc to /etc and after quiting mc I am still in /usr instead of /etc.
This is what /usr/libexec/mc/mc-wrapper.sh should accomplish.
_________________
Mircosoft software is like having sex with a stranger, you always have to be careful not to get infected with something...
Back to top
View user's profile Send private message
Linubie
Guru
Guru


Joined: 11 Jun 2004
Posts: 381

PostPosted: Fri Oct 11, 2024 6:05 pm    Post subject: Reply with quote

deleting
Code:
alias mc='. /usr/libexec/mc/mc-wrapper.sh'   

from /etc/bash/bashrc

and adding

Code:
. /usr/libexec/mc/mc.sh


to ~/.bashrc

neither works for me

edit: And I restarted the PC ;O)
_________________
Mircosoft software is like having sex with a stranger, you always have to be careful not to get infected with something...
Back to top
View user's profile Send private message
flexibeast
Guru
Guru


Joined: 04 Apr 2022
Posts: 407
Location: Naarm/Melbourne, Australia

PostPosted: Fri Oct 11, 2024 10:54 pm    Post subject: Reply with quote

Looking at the source of /usr/libexec/mc/mc-wrapper.sh:

Code:
MC_USER=`whoami`
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 "$MC_PWD" != "$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


what are the contents of `${TMPDIR-/tmp}/mc-$MC_USER/mc.pwd.$$` when mc is running?
_________________
https://wiki.gentoo.org/wiki/User:Flexibeast
Back to top
View user's profile Send private message
Banana
Moderator
Moderator


Joined: 21 May 2004
Posts: 1674
Location: Germany

PostPosted: Sat Oct 12, 2024 7:32 am    Post subject: Reply with quote

After looking into the files /usr/libexec/mc/mc.sh does set alias mc='. /usr/libexec/mc/mc-wrapper.sh' and checks for plain shell.

Another questions:
What shell do you use?
Is your ~/.bashrc sourced/executed?
_________________
Forum Guidelines

PFL - Portage file list - find which package a file or command belongs to.
My delta-labs.org snippets do expire
Back to top
View user's profile Send private message
spica
Guru
Guru


Joined: 04 Jun 2021
Posts: 325

PostPosted: Sat Oct 12, 2024 9:01 am    Post subject: Reply with quote

Linubie wrote:
I started mc in directory /usr change the directory within mc to /etc and after quiting mc I am still in /usr instead of /etc.

Does this command create /tmp/mc_was_invoked_in_this_dir.txt ? backslash is to make sure it is not an alias
Code:
\mc -P /tmp/mc_was_invoked_in_this_dir.txt

What version of mc is installed? I observe the version app-misc/mc-4.8.30-r2 does not create the file, but app-misc/mc-4.8.32 does
Back to top
View user's profile Send private message
Linubie
Guru
Guru


Joined: 11 Jun 2004
Posts: 381

PostPosted: Sat Oct 12, 2024 9:31 am    Post subject: Reply with quote

Banana wrote:
After looking into the files /usr/libexec/mc/mc.sh does set alias mc='. /usr/libexec/mc/mc-wrapper.sh' and checks for plain shell.

Another questions:
What shell do you use?
Is your ~/.bashrc sourced/executed?


KDE Konsole - /bin/bash
Code:
ls ~/.bashrc
-rw-r--r-- 1 darfwas darfwas 575 11. Okt 19:58 /home/darfwas/.bashrc

Code:
cat ~/.bashrc
# /etc/skel/.bashrc
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output.  So make sure this doesn't display
# anything or bad things will happen !


# Test for an interactive shell.  There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.
if [[ $- != *i* ]] ; then
        # Shell is non-interactive.  Be done now!
        return
fi


# Put your fun stuff here.
. /usr/libexec/mc/mc.sh


Code:
\mc -P /tmp/mc_was_invoked_in_this_dir.txt

Code:

ls /tmp/mc_was_invoked_in_this_dir.txt
-rw------- 1 darfwas darfwas 4 12. Okt 11:26 /tmp/mc_was_invoked_in_this_dir.txt

_________________
Mircosoft software is like having sex with a stranger, you always have to be careful not to get infected with something...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum