##// END OF EJS Templates
prompt and set_term_title now include drive letter and / characters on win32
vivainio -
Show More
@@ -1,7 +1,7 b''
1 1 # -*- coding: utf-8 -*-
2 2 """Magic functions for InteractiveShell.
3 3
4 $Id: Magic.py 2649 2007-08-21 18:19:20Z vivainio $"""
4 $Id: Magic.py 2659 2007-08-22 20:21:07Z vivainio $"""
5 5
6 6 #*****************************************************************************
7 7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
@@ -2496,9 +2496,7 b' Defaulting color scheme to \'NoColor\'"""'
2496 2496 os.chdir(os.path.expanduser(ps))
2497 2497 if self.shell.rc.term_title:
2498 2498 #print 'set term title:',self.shell.rc.term_title # dbg
2499 ttitle = ("IPy:" + (
2500 os.getcwd() == '/' and '/' or \
2501 os.path.basename(os.getcwd())))
2499 ttitle = 'IPy ' + abbrev_cwd()
2502 2500 platutils.set_term_title(ttitle)
2503 2501 except OSError:
2504 2502 print sys.exc_info()[1]
@@ -2511,7 +2509,7 b' Defaulting color scheme to \'NoColor\'"""'
2511 2509 else:
2512 2510 os.chdir(self.shell.home_dir)
2513 2511 if self.shell.rc.term_title:
2514 platutils.set_term_title("IPy:~")
2512 platutils.set_term_title("IPy ~")
2515 2513 cwd = os.getcwd()
2516 2514 dhist = self.shell.user_ns['_dh']
2517 2515 dhist.append(cwd)
@@ -2,7 +2,7 b''
2 2 """
3 3 Classes for handling input/output prompts.
4 4
5 $Id: Prompts.py 2601 2007-08-10 07:01:29Z fperez $"""
5 $Id: Prompts.py 2659 2007-08-22 20:21:07Z vivainio $"""
6 6
7 7 #*****************************************************************************
8 8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
@@ -309,10 +309,15 b' class BasePrompt(object):'
309 309 $HOME is always replaced with '~'.
310 310 If depth==0, the full path is returned."""
311 311
312 cwd = os.getcwd().replace(HOME,"~").split(os.sep)
312 full_cwd = os.getcwd()
313 cwd = full_cwd.replace(HOME,"~").split(os.sep)
313 314 if '~' in cwd and len(cwd) == depth+1:
314 315 depth += 1
315 out = os.sep.join(cwd[-depth:])
316 drivepart = ''
317 if sys.platform == 'win32' and len(cwd) > depth:
318 drivepart = os.path.splitdrive(full_cwd)[0]
319 out = drivepart + '/'.join(cwd[-depth:])
320
316 321 if out:
317 322 return out
318 323 else:
@@ -5,7 +5,7 b' General purpose utilities.'
5 5 This is a grab-bag of stuff I find useful in most programs I write. Some of
6 6 these things are also convenient when working at the command line.
7 7
8 $Id: genutils.py 2602 2007-08-12 22:45:38Z fperez $"""
8 $Id: genutils.py 2659 2007-08-22 20:21:07Z vivainio $"""
9 9
10 10 #*****************************************************************************
11 11 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
@@ -300,6 +300,19 b" def system(cmd,verbose=0,debug=0,header=''):"
300 300 if not debug: stat = os.system(cmd)
301 301 return stat
302 302
303 def abbrev_cwd():
304 """ Return abbreviated version of cwd, e.g. d:mydir """
305 cwd = os.getcwd()
306 drivepart = ''
307 if sys.platform == 'win32':
308 if len(cwd) < 4:
309 return cwd
310 drivepart = os.path.splitdrive(cwd)[0]
311 return (drivepart + (
312 cwd == '/' and '/' or \
313 os.path.basename(cwd)))
314
315
303 316 # This function is used by ipython in a lot of places to make system calls.
304 317 # We need it to be slightly different under win32, due to the vagaries of
305 318 # 'network shares'. A win32 override is below.
@@ -326,9 +339,9 b" def shell(cmd,verbose=0,debug=0,header=''):"
326 339 sys.stdout.flush()
327 340
328 341 if not debug:
329 platutils.set_term_title("IPy:" + cmd)
342 platutils.set_term_title("IPy " + cmd)
330 343 os.system(cmd)
331 platutils.set_term_title("IPy:" + os.path.basename(os.getcwd()))
344 platutils.set_term_title("IPy " + abbrev_cwd())
332 345
333 346 # override shell() for win32 to deal with network shares
334 347 if os.name in ('nt','dos'):
@@ -14,6 +14,10 b''
14 14
15 15 * envpersist.py, history.py: %env (sh profile only), %hist completers
16 16
17 * genutils.py, Prompts.py, Magic.py: win32 - prompt (with \yDEPTH) and
18 term title now include the drive letter, and always use / instead of
19 os.sep (as per recommended approach for win32 ipython in general).
20
17 21 2007-08-21 Ville Vainio <vivainio@gmail.com>
18 22
19 23 * ipmaker.py: finding ipythonrc-PROF now skips ipy_profile_PROF.
General Comments 0
You need to be logged in to leave comments. Login now