aboutsummaryrefslogtreecommitdiff
path: root/jim-rlprompt-1.0.tcl
diff options
context:
space:
mode:
authorantirez <antirez>2005-04-05 11:51:17 +0000
committerantirez <antirez>2005-04-05 11:51:17 +0000
commit0b5ec7f323c8eb15c7b2055616c7b7af1e5afd3d (patch)
tree9353a8d64b2a6c1c9b560d0feae191435de66c68 /jim-rlprompt-1.0.tcl
parenta96abb6e891079e1e2dadcebee354fc72ed7d9bf (diff)
downloadjimtcl-0b5ec7f323c8eb15c7b2055616c7b7af1e5afd3d.zip
jimtcl-0b5ec7f323c8eb15c7b2055616c7b7af1e5afd3d.tar.gz
jimtcl-0b5ec7f323c8eb15c7b2055616c7b7af1e5afd3d.tar.bz2
.jimrc support (or jimrc.tcl). Minimal readline extension, just enough
to allow to the pure-Jim rlprompt extension to provide a readline-aware interactive shell with history.
Diffstat (limited to 'jim-rlprompt-1.0.tcl')
-rw-r--r--jim-rlprompt-1.0.tcl31
1 files changed, 31 insertions, 0 deletions
diff --git a/jim-rlprompt-1.0.tcl b/jim-rlprompt-1.0.tcl
new file mode 100644
index 0000000..4b353fe
--- /dev/null
+++ b/jim-rlprompt-1.0.tcl
@@ -0,0 +1,31 @@
+# Readline-based interactive shell for Jim
+# Copyright(C) 2005 Salvatore Sanfilippo <antirez@invece.org>
+#
+# In order to automatically have readline-editing features
+# put this in your $HOME/.jimrc
+#
+# if {$jim_interactive} {
+# if {[catch {package require rlprompt}] == 0} {
+# rlprompt.shell
+# }
+# }
+
+package require readline
+package provide rlprompt 1.0
+
+proc rlprompt.shell {} {
+ puts "Readline shell loaded"
+ puts "Welcome to Jim [info version]!"
+ set prompt ". "
+ while 1 {
+ set line [readline.readline $prompt]
+ if {[string length $line] == 0} {
+ continue
+ }
+ readline.addhistory $line
+ set errCode [catch {uplevel #1 $line} err]
+ if {$err ne {}} {
+ puts $err
+ }
+ }
+}