Skip to content

Instantly share code, notes, and snippets.

@MeganerdNL
Last active January 23, 2026 12:46
Show Gist options
  • Select an option

  • Save MeganerdNL/3b965572427514a3548e23159d8e4c7e to your computer and use it in GitHub Desktop.

Select an option

Save MeganerdNL/3b965572427514a3548e23159d8e4c7e to your computer and use it in GitHub Desktop.
mc-wrapper script to exit in the last active directory of Midnight Commander for the fish shell. Place in: ~/.config/fish/functions/mc.fish
## Original author: Arkadiusz Halicki (https://github.com/halicki)
## Adjusted with help from: Azlan Mukhtar (https://github.com/azlan)
function mc
set SHELL_PID %self
if not test -d "/tmp/mc-$USER"
mkdir -p "/tmp/mc-$USER"
end
set MC_PWD_FILE "/tmp/mc-$USER/mc.pwd.$SHELL_PID"
/usr/bin/mc -P $MC_PWD_FILE $argv
if test -r $MC_PWD_FILE
set MC_PWD (cat $MC_PWD_FILE)
if test -n "$MC_PWD"
and test -d "$MC_PWD"
cd (cat $MC_PWD_FILE)
end
rm $MC_PWD_FILE
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment