Skip to content
Snippets Groups Projects
Commit a905be22 authored by Rich Lane's avatar Rich Lane
Browse files

persistent command history

Saves readline history to ~/.mininet_history.
parent 8f5f38c6
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,8 @@
from select import poll, POLLIN
import sys
import time
import os
import atexit
from mininet.log import info, output, error
from mininet.term import makeTerms, runX11
......@@ -52,6 +54,18 @@ def __init__( self, mininet, stdin=sys.stdin, script=None ):
self.inputFile = script
Cmd.__init__( self )
info( '*** Starting CLI:\n' )
# Setup history if readline is available
try:
import readline
except ImportError:
pass
else:
history_path = os.path.expanduser('~/.mininet_history')
if os.path.isfile(history_path):
readline.read_history_file(history_path)
atexit.register(lambda: readline.write_history_file(history_path))
if self.inputFile:
self.do_source( self.inputFile )
return
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment