#!/bin/sh # RenameMacTerminalTab.sh # Fri May 1 00:23:32 PDT 2009 # Chieh Cheng # http://www.CynosureX.com/ # GNU General Public License (GPL) Version 2, June 1991 scriptName=`basename "$0"` name=`basename "$0" ".sh"` function getTempFile () { local parentID=${PPID} local tmpFile="/tmp/${scriptName}.${parentID}.tmp" echo "${tmpFile}" } function renameTab () { local title="$1" # local executable="/bin/bash" local executable="/usr/X11/bin/xlogo" local tmpFile=`getTempFile` cp "${executable}" "/tmp/${title}" "/tmp/${title}" -render -shape -iconic -geometry 1x1 & local childID=`ps | grep -v "grep" | grep "/tmp/${title}" | Token.sh 1` echo "${childID}" > "${tmpFile}" rm "/tmp/${title}" } function usage () { echo " Usage: ${scriptName} \"title\"" } if [ $# -eq 1 ] then title="$1" tmpFile=`getTempFile` if [ -f "${tmpFile}" ] then id=`cat "${tmpFile}"` result=`ps | grep -v grep | grep -c "${id}"` rm "${tmpFile}" if [ "${result}" -gt 0 ] then kill "${id}" fi fi renameTab "${title}" else usage fi