#!/bin/bash # # Wrapper for Midnight Commander # # Parameters BASENAME="`basename $0`" 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 # Fix configuration # # These settings vary from screen size to screen size and # might change mc's dotfiles whenever it's run on a different # screen configuration. # # If $INI is a link, $CONF will be the link destination. # That's important because `sed -i` usually breaks the linking. # Delete left_panel_size config if grep -q "^left_panel_size=.*$" $CONF; then #sed -i '/^left_panel_size=.*$/,+1 d' $CONF sed -i '/^left_panel_size=.*$/ d' $CONF fi # Delete top_panel_size config and the following blank line if grep -q "^top_panel_size=.*$" $CONF; then sed -i '/^top_panel_size=.*$/,+1 d' $CONF fi # Delete all empty lines from config #sed -i '/^$/d' $CONF