]> git.alrj.org Git - zsh.d.git/blob - wrappers/mc-wrapper
Add a wrapper for mc to stay in current directory upon exit
[zsh.d.git] / wrappers / mc-wrapper
1 MC_USER=`whoami`
2 MC_PWD_FILE="${TMPDIR-/tmp}/mc-$MC_USER/mc.pwd.$$"
3 /usr/bin/mc -P "$MC_PWD_FILE" "$@"
4
5 if test -r "$MC_PWD_FILE"; then
6         MC_PWD="`cat "$MC_PWD_FILE"`"
7         if test -n "$MC_PWD" && test "$MC_PWD" != "$PWD" && test -d "$MC_PWD"; then
8                 cd "$MC_PWD"
9         fi
10         unset MC_PWD
11 fi
12
13 rm -f "$MC_PWD_FILE"
14 unset MC_PWD_FILE
15 unset MC_USER
16