Is it possible to start the mc-wrapper with sudo and still use the last selected directory on the console when quitting sudo mc
(requirement number 4)? My default alias looks like this.
alias mc='EDITOR="${EDITOR-mcedit}" . /usr/lib/mc/mc-wrapper.sh'
Some errors (for the Googlers)
sudo: mc: command not found
sudo: .: command not found # "." == "source"
My requirements
- Ubuntu 18.04.1.
- The alias should work with and without sudo call.
- If possible, a single alias for
mc
in/etc/bash.bashrc
for all users. - The directory you changed to with
sudo mc
should be "preserved" after closing the Midnight Commander. This means that you will not be in the same directory as you startedsudo mc
(provided it is not the same directory).
Optional requirements
- See if the alias was started with super powers.
- See if the alias was started with sudo.
- If the alias
mc
was started without super powers or sudo, ask if the programmc
should still be started with sudo rights. - If the question is answered No, use my default alias.
- In all other cases, the first four requirements should be met.
- The editor (e.g.
mcedit
orvi
) withinmc
should be selectable via another alias likemcvi
(forvi
) without code duplication. - Arguments should be passed on to the program, like
sudo mc /opt/ /mnt/