Skip to content

Commit

Permalink
Normalize home directory in prompts to avoid display oddities (#12)
Browse files Browse the repository at this point in the history
* Normalize home directory in prompts.
* use simple concatenation instead of "file join" to avoid problems with leading slashes

Fixes #6
  • Loading branch information
bovine authored Feb 8, 2019
1 parent 18313d9 commit 93d4c60
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tclreadlineSetup.tcl.in
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,14 @@ namespace eval tclreadline {
set pwd "unable to get pwd"
}

if [info exists env(HOME)] {
regsub $env(HOME) $pwd "~" pwd
if {[info exists env(HOME)]} {
variable normalized_home
if {![info exists normalized_home]} {
set normalized_home [file normalize $env(HOME)]
}
if {[string equal -length [string length $normalized_home] $pwd $normalized_home]} {
set pwd "~[string range $pwd [string length $normalized_home] end]"
}
}
return "$prompt_string \[$pwd\] "
}
Expand Down

0 comments on commit 93d4c60

Please sign in to comment.