This page is meant to collect command prompts for
Pure-tcl readline2.
namespace eval ::TclReadLine::prompts {}
proc ::TclReadLine::prompts::user-at-host {} {
return $::tcl_platform(user)@[info hostname]
}
proc ::TclReadLine::prompts::shorten-path {path} {
set splitPath [file split $path]
set result {}
foreach fragment [lrange $splitPath 0 end-1] {
lappend result [string index $fragment 0]
}
return [file join {*}$result [lindex $splitPath end]]
}
# Looks like this:
# tclsh-8.6.3 [Downloads] %
set ::TclReadLine::prompts::path {tclsh[info patchlevel] \[[pwd]\]% }
# Looks like the above but with color.
set ::TclReadLine::prompts::pathColor {\033\[36mtclsh-[info patchlevel]\033\[0m \[\033\[34m[file tail [pwd]\033\[0m]\]\033\[31m % \033\[0m}
# A fish shell-style prompt with a clock.
# Looks like this:
# 14:49:52 user@host /h/d/Downloads>
set ::TclReadLine::prompts::fish {[clock format [clock seconds] -format {%H:%M:%S}] [::TclReadLine::prompts::user-at-host] [::TclReadLine::prompts::shorten-path [pwd]]> }
set ::TclReadLine::PROMPT $::TclReadLine::prompts::path