Skip to content

Instantly share code, notes, and snippets.

@Sebb767
Last active October 4, 2016 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sebb767/5f5e1fed832fe75e12f11fbe52b87539 to your computer and use it in GitHub Desktop.
Save Sebb767/5f5e1fed832fe75e12f11fbe52b87539 to your computer and use it in GitHub Desktop.
Use mate-terminal as replacement for xterm

Introduction

This little script below will overwrite xterm and use mate-terminal instead, for applications ignoring that xterm sucks. It's written for use with monodevelop, but it should work with little to no edit with any other application.

Installation

If you have xterm installed beforehand, uninstall it now or a package manager update will overwrite this script. To install it, simply copy the script to /usr/bin and rename it xterm. Then chmod +x /usr/bin/xterm and you're done.

Notes

There's a log in /tmp/xterm.log in case you need to debug something.

#!/bin/bash
param=""
tempfile="$(mktemp --suffix '-mono-run')"
echo "Tempfile is $tempfile" >> /tmp/xterm.log
echo "Started with parameters" > /tmp/xterm.log
# iterate over each param, fixing any incompatibilities
while test ${#} -gt 0; do
echo "(p) $1" >> /tmp/xterm.log
if [[ "$1" == "-c" ]]; then
# found the execute command
# we need to put this into a temporary script since escaping doesn't seem to work
shift
echo '#!/bin/bash' > $tempfile
echo "$1" >> $tempfile
chmod +x $tempfile
param="$param -e $tempfile"
elif [[ "$1" == "-title" ]]; then # the title parameter has two dashes with mate-terminal
param="$param --title"
elif [[ "$1" != "bash" ]] && [[ "$1" != "-e" ]]; then
param="$param \"$1\""
fi
shift
done
echo >> /tmp/xterm.log
echo -- new parameter string -- >> /tmp/xterm.log
echo >> /tmp/xterm.log
echo "$param" >> /tmp/xterm.log
# start mate-terminal
DISPLAY=:0 /usr/bin/mate-terminal --disable-factory $param
rm $tempfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment