##// END OF EJS Templates
compress 'head' of dhist on store
vivainio -
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 2423 2007-06-11 16:47:22Z vivainio $"""
4 $Id: Magic.py 2425 2007-06-11 17:07:21Z 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
@@ -66,6 +66,20 b' def on_off(tag):'
66
66
67 class Bunch: pass
67 class Bunch: pass
68
68
69 def compress_dhist(dh):
70 head, tail = dh[:-10], dh[-10:]
71
72 newhead = []
73 done = set()
74 for h in head:
75 if h in done:
76 continue
77 newhead.append(h)
78 done.add(h)
79
80 return newhead + tail
81
82
69 #***************************************************************************
83 #***************************************************************************
70 # Main class implementing Magic functionality
84 # Main class implementing Magic functionality
71 class Magic:
85 class Magic:
@@ -2463,7 +2477,11 b' Defaulting color scheme to \'NoColor\'"""'
2463 except OSError:
2477 except OSError:
2464 print sys.exc_info()[1]
2478 print sys.exc_info()[1]
2465 else:
2479 else:
2466 self.shell.user_ns['_dh'].append(os.getcwd())
2480 cwd = os.getcwd()
2481 dhist = self.shell.user_ns['_dh']
2482 dhist.append(cwd)
2483 self.db['dhist'] = compress_dhist(dhist[-100:])
2484
2467 else:
2485 else:
2468 os.chdir(self.shell.home_dir)
2486 os.chdir(self.shell.home_dir)
2469 if self.shell.rc.term_title:
2487 if self.shell.rc.term_title:
General Comments 0
You need to be logged in to leave comments. Login now