tkcon(1)
๐ tkcon(1) โ the Tk console glow-up ๐
okay bestie, so this is tkcon, from the General Commands Manual section (that's section 1, iykyk โ the one for actual runnable commands ๐). buckle up, she's a long one and she's iconic.
โจ NAME โจ
tkcon โ a Tk console replacement ๐
๐ธ SYNOPSIS ๐ธ
tkcon [{option value | tcl_script} ...]
๐ฆ DESCRIPTION ๐ฆ
okay so, TkCon? she's a replacement for the standard console that ships with Tk. like, on Windows/Mac that default console exists, but also she works on Unix too, no cap. and honestly? the console itself gives you so many more features than the standard one, it's not even a comparison ๐ .
TkCon works on every platform where Tcl/Tk is available โ literally all of them. and her whole purpose in life? she's meant primarily to help you out when you're working with all the little teeny tiny details inside Tcl and Tk. the way that Unix users finally get the GUI console that Mac and Windows Tk just... hands you by default? yeah. that's the vibe. main character energy fr fr ๐ซถ
tkcon [{option value | tcl_script} ...]
๐ OPTIONS ๐
so here's the thing bestie, with one exception: command line arguments get handled after the TkCon resource file is sourced, but before the slave interpreter or the TkCon user interface is initialized. so like, timing matters, noted ๐
the one exception is -rcfile โ she gets handled right before she would be sourced, so you can specify any alternate file you want. queen behavior honestly ๐
and lowkey important: command line arguments get passed to each new console and will be evaluated by each one of them. like, every single one. so if you don't want that happening, you have to say:
tkcon main set argv {}; tkcon main set argc 0
and for all these options? any unique substring is allowed. abbreviate away bestie โจ
-argv(also--) โ makes TkCon stop evaluating arguments and set the remaining args to beargv/argc(with--prepended). and this carries over for any further consoles. this one is meant only for wrapping TkCon around programs that require their own arguments. niche but essential ๐-color-<color> colorโ sets the requested color type to the specified color for tkcon. for the recognized<color>names, go peek attkconrc(5)๐-eval tcl_script(also-mainor-e) โ a Tcl script to eval in each main interpreter. this gets evaluated after the resource file is loaded and the slave interpreter is created. and yes, multiple-evalswitches will be recognized, in order ๐-exec slavenameโ sets the named slave that tkcon operates in. in general this is only useful if you set it to""(empty), which tells tkcon to avoid the multi-interpreter model entirely and just operate in the main environment. when it's empty, any further arguments will only be used in the first tkcon console and not passed onto further new consoles. super useful when you're using tkcon as a console for extended wish executables that don't load their commands into slave interpreters ๐ซถ-font fontโ sets the font that tkcon uses for its text windows. and if this isn't a fixed width font? tkcon will override it. she has standards ๐-nontcl TCL_BOOLEANโ sets::tkcon::OPT(nontcl)toTCL_BOOLEAN(seetkconrc(5)). you need this when attaching to non-Tcl interpreters ๐-package package_name(also-load) โ packages to automatically load into the slave interpreters (i.e."Tk") ๐-rcfile filenameโ specify an alternate tkcon resource file name ๐ธ-root widgetnameโ makes the named widget the root name of all consoles (i.e..tkcon) ๐-slave tcl_scriptโ a Tcl script to eval in each slave interpreter. this will append the one specified in the tkcon resource file, if any ๐
๐ KEY BINDINGS ๐
okay so most of these bindings are the same as for the text widget, periodt. but some have been modified to make sure the integrity of the console is maintained (she's protective of herself, respect it ๐ ). others got added just to make the console more useful. only the modified or new bindings are listed here, so don't come for me about the ones that aren't mentioned ๐
Control-xorCut(on Sparc5 keyboards) โ Cut โ๏ธControl-corCopy(on Sparc5 keyboards) โ Copy ๐Control-vorPaste(on Sparc5 keyboards) โ Paste ๐ฅInsertโ Insert. (duh.) ๐Upโ goes up one level in the commands line history when the cursor is on the prompt line, otherwise it moves through the buffer โฌ๏ธDownโ goes down one level in the commands line history when the cursor is on the last line of the buffer, otherwise it moves through the buffer โฌ๏ธControl-pโ goes up one level in the commands line history ๐ผControl-nโ goes down one level in the commands line history ๐ฝTabโ tries to expand file path names, then variable names, then proc names. she's thorough ๐Escapeโ tries to expand file path names ๐Control-Pโ tries to expand procedure names. the procedure names will be those that are actually in the attached interpreter (unlessnontclis specified, in which case it always does the lookup in the default slave interpreter) ๐Control-Vโ tries to expand variable names (those returned by[info vars]). its search behavior is like that for procedure names ๐ReturnorEnterโ evaluates the current command line if it's a complete command, otherwise it just goes to a new line. she's not gonna run your half-finished nonsense bestie ๐Control-aโ go to the beginning of the current command line โฎ๏ธControl-lโ clear the entire console buffer ๐งนControl-rโ searches backwards in the history for any command that contains the string in the current command line. repeatable to search farther back. and the matching substring of the found command will blink โจControl-sโ as above, but searches forward (only useful if you searched too far back, oops ๐)Control-tโ transposes characters ๐Control-uโ clears the current command line ๐งผControl-zโ saves the current command line in a buffer that can be retrieved with anotherControl-z. if the current command line is empty, then any saved command is retrieved without being overwritten. otherwise? the current contents get swapped with what's in the saved command buffer. it's giving clipboard but make it mysterious ๐Control-Key-1โ attaches console to the console's slave interpreter 1๏ธโฃControl-Key-2โ attaches console to the console's master interpreter 2๏ธโฃControl-Key-3โ attaches console to main TkCon interpreter 3๏ธโฃControl-Aโ pops up the"About"dialog ๐ซถControl-Nโ creates a new console. each console has separate state, including its own widget hierarchy (it's a slave interpreter) ๐Control-qโ close the current console OR quit the program (depends on the value of::tkcon::TKCON(slaveexit)) ๐คControl-wโ closes the current console. closing the main console will exit the program (something has to control all the slaves...) ๐
TkCon also has electric bracing (similar to that in emacs, bestie, we love a crossover). she'll highlight matching pairs of {}'s, []'s, ()'s and ""'s โจ
for the first three โ if there's no matching left element for the right, then it blinks the entire current command line. for the double quote? if there's no proper match then it just blinks the current double quote character. and yes she does properly recognize most escaping (except escaped escapes ๐ญ), but she does not look for commenting. and honestly? why would you interactively put comments in? exactly. no notes ๐
๐ซ COMMANDS ๐ซ
ok bestie so TkCon introduces a bunch of brand-new procedures to make you more productive and/or to bring back functionality that you're used to from native environments but that Tcl lowkey lost. There are also a few redefined procedures in the mix. Here's a non-comprehensive list โ meaning it's giving highlights, not the whole syllabus:
alias ?sourceCmd targetCmd ?arg arg ...??โ the simple alias mechanism, fr fr. Heads up: it will overwrite existing commands, no hesitation, no apology ๐. Call it with no args and it hands you the current aliases. Also note that TkCon makes some aliases for you (in slaves) โ do not delete those ones, bestie, they're load-bearing.clear ?percentage?โ clears the text widget. Same energy as the<Control-l>binding, except this one lets you pass a percentage of the buffer to clear (1-100, and100is the default). Partial clear, iconic behavior โจdir ?-all? ?-full? ?-long? ?pattern pattern ...?โ the cheap-and-cheerful way to get directory listings. Uses glob style pattern matching. No cap.dump type ?-nocomplain? ?-filter pattern? ?--? pattern ?pattern ...?โ lets you spit out state information about the interpreter in a form that's both Tcl readable and human readable. Obsessed. Seedump(3tk)for the details.echo ?arg arg ...?โ concatenates the args and spits the result straight to the console (stdout). Simple. Clean. Slays.edit ?-type type? ?-find str? ?-attach interp? argโ opens an editor with the data from arg. The optional type argument can be one of:proc,varorfile. Forprocorvar, arg may be a pattern. Chef's kiss ๐idebug command ?args?โ interactive debugging command. Seeidebug(3tk)for details.lremove ?-all? ?-regexp -glob? list itemsโ removes one or more items from a list and returns the new list. Specify-alland it removes all instances of each item in the list. Specify-regexpor-globand it interprets each item in the items list as a regexp or glob pattern to match against. Pattern matching? We love to see it ๐lessโ aliased toedit.lsโ aliased todir -full.moreโ aliased toedit.observe type ?args?โ gives you passive runtime debugging output for variables and commands. Seeobserve(3tk)for details.puts (same options as always)โ redefined so the output goes into TkCon instead. Same options as always, bestie, no surprises there.tkcon method ?args?โ the multi-purpose command. Seetkcon(3tk)for details.tclindexโ convenience proc to update the"tclIndex"file (controlled by the-indexswitch) and/or the"pkgIndex.tcl"file (controlled by the-packageswitch) in the named directories, based on the given pattern for files. Full signature:
tclindex ?-extensions patternlist? ?-index TCL_BOOLEAN? ?-package TCL_BOOLEAN? ?dir1 dir2 ...?
It defaults to creating the "tclIndex" but not the "pkgIndex.tcl" file, with the directory defaulting to [pwd]. The extension defaults to *.tcl, with *.[info sharelibextension] added when -package is true.
unalias cmdโ unaliases command. Bye bestie ๐what stringโ thewhatcommand identifies the word given in string in the Tcl environment and returns a list of types that it was recognized as. Possible types are:alias,procedure,command,array variable,scalar variable,directory,file,widget, andexecutable. It's used by the proceduresdumpandwhich. Detective energy ๐which commandโ like thewhichcommand of Unix shells, this tells you if a particular command is known, and if so, whether it's internal or external to the interpreter. If it's an internal command and there's a slot inauto_indexfor it, it tells you the file thatauto_indexwould load. Now, this does not necessarily mean that that's where the file came from โ but if it weren't in the interpreter previously, then that's where the command was found. Semantics matter, iykyk.
There are also several procedures that I use as helpers that some of you may find helpful in your coding (i.e. expanding pathnames). Feel free to lift them from the code โ but do assign proper attribution, please and thank you ๐ซถ
๐ EXAMLPES ๐
(yes that's the spelling, we keep it, it's part of the lore ๐)
Some examples of tkcon command line startup situations, because a vibe check in code form is helpful:
megawish /usr/bin/tkcon -exec "" -root .tkcon mainfile.tcl
Use tkcon as a console for your megawish application. You can avoid starting the line with megawish if that is the default wish that TkCon would use. The -root ensures that tkcon will not conflict with the application root window.
tkcon -font "Courier 12" -load Tk
Use the courier font for TkCon and always load Tk in slave interpreters at startup.
tkcon -rcfile ~/.wishrc -color-bg white
Use the ~/.wishrc file as the resource file, and a white background for TkCon's text widgets.
๐ FILES ๐
TkCon will search for a resource file in "~/.tkconrc".
TkCon never sources the "~/.wishrc" file. Periodt.
The resource file is sourced by each new instance of the console. An example resource file is provided in tkconrc(5).
๐ SEE ALSO ๐
dump(3tk), idebug(3tk), observe(3tk), text(3tk), tkcon(3tk), tkconrc(5)
๐ KEYWORDS ๐
Tk, console
๐ COPYRIGHT ๐
Copyright (c) Jeffrey Hobbs (jeff at hobbs.org)
and that's a wrap, bestie ๐ that was TkCon, version 2.5, section tkcon(1) โ go forth and console responsibly, you absolute icon ๐ฆโจ
๐ฆ where this page comes from
- debian bookworm: tkcon 2:2.7.11-1
- debian trixie: tkcon 2:2.7.11-6
- ubuntu jammy: tkcon 2:2.7.10-2
- ubuntu noble: tkcon 2:2.7.11-1
- ubuntu resolute: tkcon 2:2.7.11-6
- ubuntu stonking: tkcon 2:2.7.11-6
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms