Decent interactive TCL shell - tcl

Is there anything like the iPython notebook for TCL?
Or at the very least, a shell that lets me use ctrl-f, ctrl-b, ctrl-a etc. without filling the shell with ^B etc.

Have a look at tkcon
I like rlwrap tclsh -- see if your OS's package repository has it, or get it from github

Related

Why does configuration.nix compile while nix-shell uses a prebuilt binary?

I'm using NixOS as the distro on WSL (via the excellent setup provided by Trundle: https://github.com/Trundle/NixOS-WSL) and I'd like to install the racket package. If I run nix-shell -p racket, it dutifully downloads (or uses the previously downloaded) the pre-built binary and I can use it just fine. But if I add racket to the environment.systemPackages list in configuration.nix and try to nixos-rebuild test, it starts trying to build things from source. It fails when it gets to gtk (presumably because WSL2 doesn't yet support graphical applications).
Why the difference in behavior? Is there a way I can convince NixOS to use the pre-built racket when filling out the systemPackages? Happy to post my configuration.nix if it would help the diagnosis, though it's really not much of a departure from Trundle's.

Install Tcl tk binaries in Buildroot

I want to have tclsh binary in my root file system generated by Buildroot.
In buildroot, we can (from menuconfig) go to Interpreter languages and scripting -> then choose tcl
But this will install tcl8.6 packages (opt0.4, http1.0). The tcl shell itself is not implemented in the generated file system.
Does anyone know how to enable tclsh in Buildroot
Thanks in Advance
You will have to tell buildroot not to remove tclsh from your build. This can be achieved by setting BR2_PACKAGE_TCL_SHLIB_ONLY=n after having run make menuconfig.
See also https://git.busybox.net/buildroot/tree/package/tcl/tcl.mk#n51.

How to use the left and right arrow keys in the tclsh interactive shell (Ubuntu 14.04)?

Why can't I use the left and right arrow keys (actually, the same goes for the up and down keys as well) to move about the line I'm currently on in the tclsh interactive shell? If I try to press either one, I get a bunch of abracadabra instead of moving back and forth. This is not all that convenient when, for example, you make a typo, but you can't move the cursor back to change it. You have to use the backspace key to erase all the stuff that you've typed after the place where the typo is located thereby destroying all your work. Is it possible to fix this, quite frankly, buggy behaviour?
The behaviour isn't buggy. It is inconvenient yes.
To get editing in a shell, usually the GNU readline library is used. If a program doesn't use that library, you don't have that feature.
For tclsh there are licensing reasons (GPL vs. BSD style Tcl license), which make it inconvenient to add readline support directly to tclsh for all those platforms where readline is not part of the operating system (nearly everything but Linux).
You can use the Ubuntu rlwrap package to still get the editing you want.
Install rlwrap:
sudo apt-get install rlwrap
And use it to run tclsh with command line editing:
rlwrap -c tclsh
Another option would be to use the Tk based shell tkcon, which provides a bit more options as a Tcl shell, its available as a ubuntu package too.
Expanding my own answer: You can also build and use tclreadline, as a package in your .tclshrc.
You can use the the generic rlwrap as suggested by schlenk, or you can use tclreadline:
Install tclreadline (e.g. with the following command for debian/ubuntu):
sudo apt install tclreadline
Automatically load it by adding it to your ~/.tclshrc:
if {$tcl_interactive} {
package require tclreadline
::tclreadline::Loop
}
Using tclreadline does not only provide the basic editing features but also includes tab completion, which rlwrap can't do due to it's generic nature.

tcl error "can't find package struct::tree "

I tried to use the tree package for TCL but I'm unable to find any documentation at all. When trying to run the examples from http://tcllib.sourceforge.net/doc/struct_tree.html, i get the error
can't find package struct::tree
Can anyone tell me how to include it in tcl 8.5?
The struct::tree package is part of Tcllib.
If you are using ActiveTcl, doing a teacup update (possibly with elevated permissions, depending on how you installed) will download a copy. I don't know whether all Linuxes have Tcllib done as an appropriate system package, but Debian does. Otherwise, there's a download link in on the main Tcllib page; Tcllib works just fine as a bunch of .tcl files that you include with your application code.

Send Text to REPL Using SublimeREPL and Sublime Text 2

I'm having trouble getting started with SublimeREPL. I have a python program, and can start a python interpreter inside of SublimeText2.
However, I would like to use either the Eval In Repl and Transfer to Repl features, but they don't seem to do anything. How do I associate a repl with my file in sublime text 2 so these will work?
History
To be honest eval for python never worked reliably. It was plagued with strange compilation errors (mainly caused by whitespace/blank lines) and dozens of unnecessary ">>> " prompts showing up during evaluation.
My attempt to fix it using temporary files was only moderately successful and broke down completely with the ability to run remote Pythons over ssh: http://www.youtube.com/watch?v=zodAqBvKQm0
Now
However it seems that I've finally cracked it :) (with a surprisingly short solution that feels hacky but AFAICT should be orders of magnitude more reliable than the previous one, link for the curious: https://github.com/wuub/SublimeREPL/blob/master/text_transfer.py#L43)
Howto
Install SublimeREPL 1.2.0 (released +- 10 minutes ago)
Run Python REPL (any one you wish, w/ or w/o virtualenv)
Focus a file you wish to evaluate
Tools -> SublimeREPL -> Eval in REPL -> File or [Ctrl+, f]
Play with other options (line evaluation should be useful, you only need one cursor in each line you wish to eval, try [Ctrl+Alt+<down-arrow>])
...
Profit! :)
I had the same problem, namely SublimeREPL wouldn't evaluate a file or selected lines. Amazingly this worked:
Remove REPL (Preferences-> Package Control -> Remove package)
Quit and restart Sublime Text
Install REPL (Preferences-> Package Control -> Install package)
Quit and restart Sublime Text
Voila!