Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
#!/bin/sh
# TCmd - like a part of LuaCmd, but in Tcl/Tk.
# Official location: <http://angg.twu.net/DAVINCI/tcmd.tcl.html>.
# See also:          <http://angg.twu.net/davinci.html>.
#
# LuaCmd has a "debug" window that looks like this:
#
#   http://www.tecgraf.puc-rio.br/luacmd/debug.gif
#
# This program implements a window like that, to which we
# can send commands like:
#   
#   setfile "tests/fib.lua";   # set the file being displayed
#   setvars "n = 4\nN = 0\n";  # set the text in the "variables" window
#   setline 5;                 # set the line that is highlighted as current
# 
# Initially, communication with this window is unidirectional, and
# done only through a file+signal mechanism like the one in eegchannel
# (see <http://angg.twu.net/eev-current/anim/channels.anim.html>).If
# tcmd is running and we run this from a shell,
#
#   echo setfile ~/usrc/lua-5.1.2/test/fib.lua > /tmp/ee.tcmd.tcl
#   kill -USR2 $(cat /tmp/ee.tcmd.pid)
#   echo setline 5 > /tmp/ee.tcmd.tcl
#   kill -USR2 $(cat /tmp/ee.tcmd.pid)
#   echo setline 6 > /tmp/ee.tcmd.tcl
#   kill -USR2 $(cat /tmp/ee.tcmd.pid)
#
# We get something like this screenshot:
#   ...

# A standard hack to let the expect binary be anywhere in the PATH.
# See: (find-man "1 tclsh" "#!")
# The next line restarts using expect. \
#exec expect "$0" -- "$@"
#package require Tk

# The next line restarts using wish. \
exec wish "$0" -- "$@"
package require Expect

# Utility functions.
# Copied from: (find-angg "TCL/inc.tcl")
#
proc writefile {fname s} {
  set f [open $fname w]; puts -nonewline $f $s; close $f
}
proc readfile {fname} {
  set f [open $fname r]; set s [read $f]; close $f
  return $s
}

# The SIGUSR2 part.
# Requires Expect - because of "trap" and "pid".
# Based on: (find-eev "eegchannel")
#
proc pidfile {} { return /tmp/ee.tcmd.pid }
proc tclfile {} { return /tmp/ee.tcmd.tcl }
writefile [pidfile] "[pid]\n"
trap {source [tclfile]} USR2

# The GUI part.
# Requires Tk, for obvious reasons.
# (find-angg "LATEX/diaglib.014")
# (find-man "3tk pack")
# (find-man "3tk pack" "-side side")
# (find-man "3tk text")
# (find-man "3tk text" "\nINDICES\n")
# (find-man "3tk text" "pathName insert")
# (find-man "3tk text" "pathName delete")
# (find-man "3tk text" "\nTAGS\n")
# (find-man "3tk text" "pathName tag configure tagName")
# (find-man "3tk text" "pathName tag remove tagName")
# (find-man "3tk text" "pathName tag add tagName")
#
text .prog -width 40 -height 45
frame .right
text .right.vars -width 20 -height 15
pack .right.vars
pack .prog .right -expand yes -fill both -side left
.prog tag configure CURRENT -background orange
#
proc setfile {fname} {
  .prog delete 1.0 end
  .prog insert 1.0 [readfile $fname]
  wm title . "TCmd: [file tail $fname]"
}
proc setline {n} {
  .prog tag remove CURRENT 1.0 end
  if {$n!=""} {
    .prog tag add CURRENT $n.0 [expr $n+1].0
  }
}
proc setvars {str} {
  .right.vars delete 1.0 end
  .right.vars insert 1.0 $str
}