Show More
@@ -1,7 +1,7 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """Magic functions for InteractiveShell. |
|
2 | """Magic functions for InteractiveShell. | |
3 |
|
3 | |||
4 |
$Id: Magic.py 26 |
|
4 | $Id: Magic.py 2659 2007-08-22 20:21:07Z vivainio $""" | |
5 |
|
5 | |||
6 | #***************************************************************************** |
|
6 | #***************************************************************************** | |
7 | # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and |
|
7 | # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and | |
@@ -2496,9 +2496,7 b' Defaulting color scheme to \'NoColor\'"""' | |||||
2496 | os.chdir(os.path.expanduser(ps)) |
|
2496 | os.chdir(os.path.expanduser(ps)) | |
2497 | if self.shell.rc.term_title: |
|
2497 | if self.shell.rc.term_title: | |
2498 | #print 'set term title:',self.shell.rc.term_title # dbg |
|
2498 | #print 'set term title:',self.shell.rc.term_title # dbg | |
2499 |
ttitle = |
|
2499 | ttitle = 'IPy ' + abbrev_cwd() | |
2500 | os.getcwd() == '/' and '/' or \ |
|
|||
2501 | os.path.basename(os.getcwd()))) |
|
|||
2502 | platutils.set_term_title(ttitle) |
|
2500 | platutils.set_term_title(ttitle) | |
2503 | except OSError: |
|
2501 | except OSError: | |
2504 | print sys.exc_info()[1] |
|
2502 | print sys.exc_info()[1] | |
@@ -2511,7 +2509,7 b' Defaulting color scheme to \'NoColor\'"""' | |||||
2511 | else: |
|
2509 | else: | |
2512 | os.chdir(self.shell.home_dir) |
|
2510 | os.chdir(self.shell.home_dir) | |
2513 | if self.shell.rc.term_title: |
|
2511 | if self.shell.rc.term_title: | |
2514 |
platutils.set_term_title("IPy |
|
2512 | platutils.set_term_title("IPy ~") | |
2515 | cwd = os.getcwd() |
|
2513 | cwd = os.getcwd() | |
2516 | dhist = self.shell.user_ns['_dh'] |
|
2514 | dhist = self.shell.user_ns['_dh'] | |
2517 | dhist.append(cwd) |
|
2515 | dhist.append(cwd) |
@@ -2,7 +2,7 b'' | |||||
2 | """ |
|
2 | """ | |
3 | Classes for handling input/output prompts. |
|
3 | Classes for handling input/output prompts. | |
4 |
|
4 | |||
5 |
$Id: Prompts.py 26 |
|
5 | $Id: Prompts.py 2659 2007-08-22 20:21:07Z vivainio $""" | |
6 |
|
6 | |||
7 | #***************************************************************************** |
|
7 | #***************************************************************************** | |
8 | # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu> |
|
8 | # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu> | |
@@ -309,10 +309,15 b' class BasePrompt(object):' | |||||
309 | $HOME is always replaced with '~'. |
|
309 | $HOME is always replaced with '~'. | |
310 | If depth==0, the full path is returned.""" |
|
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 | if '~' in cwd and len(cwd) == depth+1: |
|
314 | if '~' in cwd and len(cwd) == depth+1: | |
314 | depth += 1 |
|
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 | if out: |
|
321 | if out: | |
317 | return out |
|
322 | return out | |
318 | else: |
|
323 | else: |
@@ -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 26 |
|
8 | $Id: genutils.py 2659 2007-08-22 20:21:07Z 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> | |
@@ -300,6 +300,19 b" def system(cmd,verbose=0,debug=0,header=''):" | |||||
300 | if not debug: stat = os.system(cmd) |
|
300 | if not debug: stat = os.system(cmd) | |
301 | return stat |
|
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 | # This function is used by ipython in a lot of places to make system calls. |
|
316 | # This function is used by ipython in a lot of places to make system calls. | |
304 | # We need it to be slightly different under win32, due to the vagaries of |
|
317 | # We need it to be slightly different under win32, due to the vagaries of | |
305 | # 'network shares'. A win32 override is below. |
|
318 | # 'network shares'. A win32 override is below. | |
@@ -326,9 +339,9 b" def shell(cmd,verbose=0,debug=0,header=''):" | |||||
326 | sys.stdout.flush() |
|
339 | sys.stdout.flush() | |
327 |
|
340 | |||
328 | if not debug: |
|
341 | if not debug: | |
329 |
platutils.set_term_title("IPy |
|
342 | platutils.set_term_title("IPy " + cmd) | |
330 | os.system(cmd) |
|
343 | os.system(cmd) | |
331 |
platutils.set_term_title("IPy |
|
344 | platutils.set_term_title("IPy " + abbrev_cwd()) | |
332 |
|
345 | |||
333 | # override shell() for win32 to deal with network shares |
|
346 | # override shell() for win32 to deal with network shares | |
334 | if os.name in ('nt','dos'): |
|
347 | if os.name in ('nt','dos'): |
@@ -13,6 +13,10 b'' | |||||
13 | * clearcmd.py: shadow history compression & erasing |
|
13 | * clearcmd.py: shadow history compression & erasing | |
14 |
|
14 | |||
15 | * envpersist.py, history.py: %env (sh profile only), %hist completers |
|
15 | * envpersist.py, history.py: %env (sh profile only), %hist completers | |
|
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). | |||
16 |
|
20 | |||
17 | 2007-08-21 Ville Vainio <vivainio@gmail.com> |
|
21 | 2007-08-21 Ville Vainio <vivainio@gmail.com> | |
18 |
|
22 |
General Comments 0
You need to be logged in to leave comments.
Login now