diff --git a/twander.py b/twander.py index 3f1e116..f9e2efd 100755 --- a/twander.py +++ b/twander.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "twander" -RCSID = "$Id: twander.py,v 3.222 2007/01/11 00:15:18 tundra Exp $" +RCSID = "$Id: twander.py,v 3.223 2007/01/11 06:43:10 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -335,6 +335,7 @@ KB = 1024 # 1 KB constant MB = KB * KB # 1 MB constant GB = MB * KB # 1 GB constant +HOMEDIRMARKER = '~' # Shortcut string used to indicate home directory NUMFUNCKEY = 12 # Number of function keys NUMPROGMEM = 12 # Number of program memories POLLINT = 250 # Interval (ms) the poll routine should run @@ -414,7 +415,9 @@ STARTDIR = os.path.abspath("." + os.sep) # Home directory -HOME = os.getenv("HOME") or STARTDIR + +ENVHOME = os.getenv("HOME") +HOME = ENVHOME or STARTDIR # Get hostname @@ -2614,7 +2617,23 @@ # user get's *really* deeply nested in a file system. # This keeps the other stuff of interest visible on the titlebar - CurrentDir = UI.CurrentDir + # First, find out if current directory is descendant of this + # user's home directory. If so, substitute a shortcut to + # save titlebar space. + + CurrentDir = os.path.realpath(UI.CurrentDir) + envhome = os.path.realpath(ENVHOME) + if CurrentDir.startswith(envhome): + CurrentDir = CurrentDir.replace(envhome, HOMEDIRMARKER) + else: + CurrentDir = UI.CurrentDir + + # And make sure whatever we ended up with has an ending + # separator character. + + if CurrentDir[-1] != PSEP: + CurrentDir += PSEP + pathlen = len(CurrentDir) if pathlen > TTLMAXDIR: CurrentDir = TTLDIR2LONG + CurrentDir[pathlen-TTLMAXDIR:]