Last active
September 14, 2026 18:27
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## 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