Posted to tcl by aspect at Sun Dec 29 07:23:07 GMT 2013view pretty
proc ::repl {{type "readline"}} { # finally start the enhanced REPL switch -exact $type { "linenoise" { # package require Tclx # proc trapint {} { # global sigint # puts "SIGINT" # incr sigint # } # signal trap SIGINT trapint package require linenoise while {1} { linenoise cmdloop -prompt1 {apply {{} { return "\033\[36mtclsh-[info patchlevel]\033\[0m \[\033\[34m[file tail [pwd]\033\[0m]\]\033\[31m % \033\[0m" }}} -prompt2 {apply {{} { return "[string repeat " " [string length "tclsh-[info patchlevel] \[[file tail [pwd]]\]"]]\033\[31m > \033\[0m" }}} -history yes } } "editline" { lappend ::auto_path /usr/local/share/eltcl package require eltclsh set ::el::prompt1 {subst -nov -noc "tclsh[info patchlevel] \[[pwd]\]% "} set ::el::prompt2 {list tclsh ...... >} interactive exit } "readline" { package require tclreadline ::tclreadline::Loop } "none" { } } }