+ (let* ((pwd (eshell/pwd)) (npwd (length pwd))
+ (home (expand-file-name "~")) (nhome (length home)))
+ (if (and (>= npwd nhome)
+ (or (= nhome npwd)
+ (= (elt pwd nhome) ?/)
+ (string= (substring pwd 0 nhome) home)))
+ (concat "~" (substring pwd (length home)))
+ pwd))