##// END OF EJS Templates
term title now shows 2 directory levels
vivainio -
Show More
@@ -5,7 +5,7 b' General purpose utilities.'
5 This is a grab-bag of stuff I find useful in most programs I write. Some of
5 This is a grab-bag of stuff I find useful in most programs I write. Some of
6 these things are also convenient when working at the command line.
6 these things are also convenient when working at the command line.
7
7
8 $Id: genutils.py 2872 2007-11-25 17:58:05Z fperez $"""
8 $Id: genutils.py 2888 2007-12-12 17:20:42Z vivainio $"""
9
9
10 #*****************************************************************************
10 #*****************************************************************************
11 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
11 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
@@ -303,15 +303,21 b" def system(cmd,verbose=0,debug=0,header=''):"
303
303
304 def abbrev_cwd():
304 def abbrev_cwd():
305 """ Return abbreviated version of cwd, e.g. d:mydir """
305 """ Return abbreviated version of cwd, e.g. d:mydir """
306 cwd = os.getcwd()
306 cwd = os.getcwd().replace('\\','/')
307 drivepart = ''
307 drivepart = ''
308 tail = cwd
308 if sys.platform == 'win32':
309 if sys.platform == 'win32':
309 if len(cwd) < 4:
310 if len(cwd) < 4:
310 return cwd
311 return cwd
311 drivepart = os.path.splitdrive(cwd)[0]
312 drivepart,tail = os.path.splitdrive(cwd)
313
314
315 parts = tail.split('/')
316 if len(parts) > 2:
317 tail = '/'.join(parts[-2:])
318
312 return (drivepart + (
319 return (drivepart + (
313 cwd == '/' and '/' or \
320 cwd == '/' and '/' or tail))
314 os.path.basename(cwd)))
315
321
316
322
317 # This function is used by ipython in a lot of places to make system calls.
323 # This function is used by ipython in a lot of places to make system calls.
General Comments 0
You need to be logged in to leave comments. Login now