Skip to content

Instantly share code, notes, and snippets.

@MeganerdNL
Last active September 14, 2026 18:27
Show Gist options
  • Select an option

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

Select an option

Save MeganerdNL/fffc136f90e4e851d96a847f3e4fd74b 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 (homebrew version)
## mc-wrapper script to exit in the last active directory of Midnight Commander for the fish shell (homebrew version)
## Place in: ~/.config/fish/functions/mc-wrapper-homebrew-fish.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"
set mcversion $(ls -v /var/home/linuxbrew/.linuxbrew/Cellar/midnight-commander | tail -1)
/home/linuxbrew/.linuxbrew/Cellar/midnight-commander/$mcversion/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