diff options
-rwxr-xr-x | mc | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -9,9 +9,26 @@ MC="/usr/bin/mc" INI="$HOME/.config/mc/ini" CONF="`readlink $INI || echo $INI`" +# Get the current window name +# Thanks http://www.shelldorado.com/scripts/cmds/xtitle +function mc_window_name { + if [ ! -z "$WINDOWID" ]; then + xprop -id $WINDOWID | grep ^WM_NAME | sed 's/.*=[ "]*\([^"]*\)["]*$/\1/' + fi +} + # Dispatch if [ ! -z "$DISPLAY" ]; then + WINDOWNAME="`mc_window_name`" TERM=xterm-256color $MC $* + NEWWINDOWNAME="`mc_window_name`" + + # Restore window name as mc forgets to do it + if [ "$WINDOWNAME" != "$NEWWINDOWNAME" ]; then + if echo $NEWWINDOWNAME | grep -q '^mc \['; then + xtitle $WINDOWNAME + fi + fi else $MC $* fi |