Skip to content

Instantly share code, notes, and snippets.

@azlan
Created December 26, 2024 11:07
Show Gist options
  • Save azlan/00a0f729eaa09d67bc7677b6818ef498 to your computer and use it in GitHub Desktop.
Save azlan/00a0f729eaa09d67bc7677b6818ef498 to your computer and use it in GitHub Desktop.
How to make Midnight Commander exit to its current directory - Fish Shell
# copy to ~/.config/fish/functions/
function mc
if not test -d "/tmp/mc-$USER"
mkdir -p "/tmp/mc-$USER"
end
set SHELL_PID %self
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