August 05, 2003 - [Tkcon] comes with a tkcon.cfg file, to keep your configuration preferences. You can, among other things, choose which font face, size and colors you want to use. 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. ---- I don't remember why this is useful: lappend auto_path . ---- 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 . { 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" ---- [Beginning Tcl] - [Arts and crafts of Tcl-Tk programming]