Cecil Westerhof <
Ce...@decebal.nl> writes:
> I have it defined as:
> proc ::tclreadline::prompt1 {} {
> return [format "%s \[%s %s@%s:%s\]\n$ " \
> tclsh${::tcl_version} \
> [clock format [clock seconds] -format "%a, %b %T"] \
> $::tcl_platform(user) \
> [lindex [split [info hostname] "."] 0] \
> [pwd]]
> }
>
> It does mostly what I want. I would like to give the prompt a colour,
> but that is not very important.
> What is a bit more important is the current working directory. Instead
> of:
> /home/cecil
>
> I would prefer:
> ~
>
> And instead of:
> /home/cecil/Documents
>
> I would prefer:
> ~/Documents
>
> Is this possible, or should I use a substitution on the output of pwd?
I rewrote it as:
proc ::tclreadline::prompt1 {} {
set user $::tcl_platform(user)
set currentDir [regsub "^/home/${user}" [pwd] ~]
set dateTime [clock format [clock seconds] -format "%a, %e %b %T"]
set host [lindex [split [info hostname] "."] 0]
return [format "%s \[%s %s@%s:%s\]\n$ " \
tclsh${::tcl_version} \
${dateTime} \
${user} \
${host} \
${currentDir}]
}
If there is a better way: I am open for improvements.