Python readline.set_completion_display_matches_hook() Examples
The following are 3
code examples of readline.set_completion_display_matches_hook().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
readline
, or try the search function
.
Example #1
Source File: shell.py From koadic with Apache License 2.0 | 6 votes |
def get_command(self, prompt, auto_complete_fn=None, basefile_fn=None): try: if auto_complete_fn != None: import readline readline.set_completer_delims(' \t\n;/') readline.parse_and_bind("tab: complete") readline.set_completer(auto_complete_fn) # readline.set_completion_display_matches_hook(basefile_fn) except: pass # python3 changes raw input name if sys.version_info[0] == 3: raw_input = input else: raw_input = __builtins__['raw_input'] cmd = raw_input("%s" % prompt) return cmd.strip()
Example #2
Source File: powerstager.py From powerstager with MIT License | 5 votes |
def __init__(self, lhost, lport): self.server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.lhost = lhost self.lport = lport self.framework = Framework(self.send_command, self.check_command, self.get_response) self.command_definition = {} self.credentials = [] self.fast_load = False self.prompt = "" self.os_target = None # Define command behavior self.command_definition["Local-Invoke"] = lambda x: self.psh_Local_Invoke(x[len("Local-Invoke"):].strip()) self.command_definition["Local-Import-Module"] = lambda x: self.psh_Local_Invoke(x[len("Local-Import-Module"):].strip(), True) self.command_definition["Local-Set-Width"] = lambda x: self.psh_Local_Set_Width(x[len("Local-Set-Width"):].strip()) self.command_definition["Local-Upload"] = lambda x: self.psh_Local_Upload(x[len("Local-Upload"):].strip()) self.command_definition["Local-Download"] = lambda x: self.psh_Local_Download(x[len("Local-Download"):].strip()) self.command_definition["Local-Download-Commands"] = lambda x: self.psh_Local_Download_Commands() self.command_definition["Local-Enumerate-System"] = lambda x: self.psh_Local_Enumerate_System() self.command_definition["Local-Check-Status"] = lambda x: self.psh_Local_Check_Status() self.command_definition["Local-Spawn-Meterpreter"] = lambda x: self.psh_Local_Spawn_Shell(conf_name.METERPRETER) self.command_definition["Local-Spawn-Reverse-Shell"] = lambda x: self.psh_Local_Spawn_Shell(conf_name.REVERSE_SHELL) self.command_definition["Local-Credential-Create"] = lambda x: self.psh_Local_Credential(True) self.command_definition["Local-Credential-List"] = lambda x: self.psh_Local_Credential() self.command_definition["clear"] = lambda x: self.psh_Local_Clear() # Define autocomplete readline.parse_and_bind("tab: complete") readline.set_completer(self.cmd_complete) readline.set_completion_display_matches_hook(self.cmd_match_display_hook) readline.set_completer_delims("")
Example #3
Source File: cli.py From zstack-utility with Apache License 2.0 | 4 votes |
def __init__(self, options): """ Constructor """ readline.parse_and_bind("tab: complete") readline.set_completer(self.complete) readline.set_completion_display_matches_hook(self.completer_print) try: readline.read_history_file(CLI_HISTORY) except IOError: pass readline.set_history_length(CLI_MAX_CMD_HISTORY) if not os.path.isdir(CLI_RESULT_HISTORY_FOLDER): linux.rm_dir_force(os.path.dirname(CLI_RESULT_HISTORY_FOLDER)) os.system('mkdir -p %s' % os.path.dirname(CLI_RESULT_HISTORY_FOLDER)) try: self.hd = filedb.FileDB(CLI_RESULT_HISTORY_KEY, is_abs_path=True) except: linux.rm_dir_force(CLI_RESULT_HISTORY_KEY) self.hd = filedb.FileDB(CLI_RESULT_HISTORY_KEY, is_abs_path=True) print "\nRead history file: %s error. Has recreate it.\n" % CLI_RESULT_HISTORY_KEY self.start_key = 'start_key' self.last_key = 'last_key' self.cli_cmd_func = {'help': self.show_help, 'history': self.show_help, 'more': self.show_more, 'quit': sys.exit, 'exit': sys.exit, 'save': self.save_json_to_file} self.cli_cmd = self.cli_cmd_func.keys() self.raw_words_db = self._parse_api_name(inventory.api_names) self.words_db = list(self.raw_words_db) self.words_db.extend(self.cli_cmd) self.words = list(self.words_db) self.is_cmd = False self.curr_pattern = None self.matching_words = None self.api_class_params = {} self.build_api_parameters() self.api = None self.account_name = None self.user_name = None self.session_uuid = None if os.path.exists(SESSION_FILE): try: with open(SESSION_FILE, 'r') as session_file_reader: self.session_uuid = session_file_reader.readline().rstrip() self.account_name = session_file_reader.readline().rstrip() self.user_name = session_file_reader.readline().rstrip() except EOFError: pass self.hostname = options.host self.port = options.port self.no_secure = options.no_secure self.api = api.Api(host=self.hostname, port=self.port)