August 05, 2003 - Tkcon comes with a resource file, named "tkcon.cfg" in Windows, to keep your configuration preferences. You can, among other things, choose which font face, size and colors you want to use.

TkCon will search for the resource file in "$env(HOME)/.tkconrc" (Unix), "$env(HOME)/tkcon.cfg" (Windows) or "$env(PREF_FOLDER)/tkcon.cfg" (Macintosh). On DOS machines, "$env(HOME)" usually refers to "C:\". The file might not exist yet if you have not made any configuration changes since installing tkcon.

An example configuration file should be found near the end of the "Getting started" documentation page, at:

ZB 2009-04-24 I've got a feeling, that ::tkcon::OPT(blinktime) doesn't work. Blinking is still the same, never mind the given time.

Go towards the end of the file and look for the line that reads:

 set ::tkcon::OPT(slaveeval) {

Everything past this line is run automatically at startup, and you can pack some handy goodies, like aliases and procs. Here are some of my tweaks. Please suggest others, preferably at the end of the page.

Joe Mistachkin - I wanted to have a large tkcon window positioned near the upper-left corner of the screen, I used:

 set tkcon::OPT(cols) 139; # YMMV, change these to suit your 
 set tkcon::OPT(rows) 43;  # screen resolution and taste.

 wm geometry $tkcon::PRIV(root) +6+6; # position near the upper-left corner

I'm not sure if this is the "proper" way to accomplish this; however I did not see any information on this in the official documentation.

I don't remember why this is useful:

 lappend auto_path .

lv - this line tells tkcon to look in the current working directory for libraries when doing a package require. That may be what you mean - but it might not be. - It is.

For Windows:

If Tkcon is called with one argument, assume it is a directory and cd to it.

If Tkcon is called with no arguments, cd to the desktop:

 if     {$argv != {}}   { cd $argv }    else    { cd c:/windows/desktop }

A handful of useful aliases:

 array set myAliasArray {
 x exit
 X exit
 p puts
 ww which
 .. {cd ..}
 hhr {history redo}
 bk {cd ..}
 getbind { bind . <Key> { puts "Key %k %K" } }
 h history
 cds {cd c:/windows/desktop}
 home {cd c:/cygwin/home/$env(USER)}
 cls clear
 cdcyg {cd c:/cygwin}
 config { c:/path/to/text.editor.exe C:/tkcon.cfg }
 gc { [ exec getclip ] }
 pc { [ exec putclip ] }

 foreach {key value} [ array get myAliasArray ] { 
        alias $key eval $value 

A tiny help system:

 set myHHList {if for switch foreach array list hh}

Usage: 'hh command'. If command is in list above, run the tiny help texts below. Otherwise, try to run 'command --help'. Strictly for newbies.

 alias helptext-hh eval { puts "HELP AVAILABLE FOR:"; foreach item $myHHList { puts $item } }
 # --------------------------------
 alias helptext-foreach puts {foreach item $list { command $item }}
 # --------------------------------
 alias helptext-for puts {for {set x 1} {$x < 10} {incr x} {
 puts $x
 }       can use break and continue}
 # --------------------------------
 alias helptext-if puts {if     {$x == 0}       {puts "X equals 0"}
 elseif {$x < 0}        {puts "X is less than 0"}
 else           {puts "X is greater than 0"}}
 # --------------------------------
 alias helptext-switch puts {switch [-exact] [-regexp] [-glob] pattern {
        value1 {body1}
        value2 {body2}
        valueN {bodyN}
 }      can use break and continue}
 # --------------------------------
 alias helptext-array puts {array exists = Verifica, e retorna 1, se o vetor existir. 
 array get = Retorna uma lista, elemento ímpar = nome (key) do elemento no vetor, elemento par = valor do elemento. 
 array names = Retorna uma lista com os nomes (keys) de cada elemento no vetor. 
 array set = Atribui a cada elemento no vetor, o valor correspondente ao existente na lista fornecida. 
 array size = Retorna o número de elementos no vetor. 
 array startsearch = Retorna um ponteiro para uma busca sequencial em um vetor. 
 array anymore = Verifica, e retorna 1, se ainda existirem elementos a serem pesquisados no vetor.
 array nextelement = Retorna o nome (key) do próximo elemento no vetor. 
 parray = Exibe os nomes (keys) e os valores de todos os elementos correspondentes ao pattern. print_r(array)

 set day(1) "Sunday"
 set day(2) "Monday"
 # --------------------------------
 proc hh {i}    {
        global myHHList
        if      { [ lsearch -exact $myHHList $i ] >= 0 }        {
                helptext-$i }   else    { exec $i --help }

Get version of programs. Usage: 'vv grep' or 'vv sed':

 proc vv {myProg}       { exec $myProg --version }

A quick bulk file renamer. Usage: 'rrename {matching regular expression} {replacement string}'. Applies to all files in current directory:

 proc rrename   {mySource myTarget}     {
        foreach i [ glob * ] { 
                if      { $i != {.:} }  { 
                        regsub -all $mySource "$i" $myTarget ii
                        if      { $i != $ii }   { file rename "$i" "$ii" }

The same as above, but this one will just print (simulate) the result:

 proc rrenamed  {mySource myTarget}     {
        foreach i [ glob * ] { 
                if      { $i != {.:} }  { 
                        regsub -all $mySource "$i" $myTarget ii
                        puts    "file rename from $i to $ii"
 # rrenamed means "rrename - debug"

17 Feb 2014 Eugene: on my laptop I have several versions of ActiveTcl installed (latest x86/x64 releases of 8.5.x and 8.6.x) and it helps to have the following in tkcon.cfg (it shows the current Tcl version and hardware platform in the status bar):

 proc getver {} {
   lassign [ list $::tcl_platform(os)\ $::tcl_platform(osVersion) unknown ] os arch
   if { [ array exists ::activestate::ActiveTcl ] } {
     lassign [ list $::activestate::ActiveTcl(product)\ $::activestate::ActiveTcl(release) $::activestate::ActiveTcl(arch) ] tcl arch
   } else {
     lassign [ list Tcl\ $::tcl_patchLevel $::tcl_platform(machine) ] tcl arch
   return "$tcl on $os ($arch)"
 proc addver {} {
   grid [ label $::tkcon::PRIV(statusbar).version -text [ getver ] -foreground darkmagenta ] -row 0 -column 2
   grid configure $::tkcon::PRIV(statusbar).cursor -column 3
 after idle {tkcon master addver}

KPV Here's a slightly more complicated version:

set ::tkcon::OPT(rows) 20
set ::tkcon::OPT(cols) 88
set ::tkcon::OPT(font) "Courier 12"
set ::tkcon::OPT(history) 300
set ::tkcon::OPT(autoload) {Tk Img}
set ::tkcon::OPT(calcmode) 1
set ::tkcon::OPT(maxlinelen) 500
set ::tkcon::OPT(expandorder) {Variable Procname Pathname}
set ::tkcon::OPT(slaveeval) {
    source ~/.wishrc
    wm protocol . WM_DELETE_WINDOW exit
    wm geom . +-1920+100
set ::tkcon::OPT(maineval) {
    wm geom . +20+850
    bind TkConsole <Control-p> [bind TkConsole <<TkCon_PreviousSearch>>]
    bind TkConsole <Up>        [bind TkConsole <<TkCon_PreviousSearch>>]
    bind TkConsole <Control-n> [bind TkConsole <<TkCon_NextSearch>>]
    bind TkConsole <Down>      [bind TkConsole <<TkCon_NextSearch>>]