Set limit on command history length
This commit is contained in:
+3
-1
@@ -77,13 +77,15 @@ class CLI( Cmd ):
|
|||||||
return
|
return
|
||||||
cls.readlineInited = True
|
cls.readlineInited = True
|
||||||
try:
|
try:
|
||||||
from readline import read_history_file, write_history_file
|
from readline import ( read_history_file, write_history_file,
|
||||||
|
set_history_length )
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
history_path = os.path.expanduser( '~/.mininet_history' )
|
history_path = os.path.expanduser( '~/.mininet_history' )
|
||||||
if os.path.isfile( history_path ):
|
if os.path.isfile( history_path ):
|
||||||
read_history_file( history_path )
|
read_history_file( history_path )
|
||||||
|
set_history_length( 1000 )
|
||||||
atexit.register( lambda: write_history_file( history_path ) )
|
atexit.register( lambda: write_history_file( history_path ) )
|
||||||
|
|
||||||
def run( self ):
|
def run( self ):
|
||||||
|
|||||||
Reference in New Issue
Block a user