def add( self, key: str, command: str, contexts: typing.Sequence[str], help="" ) -> None: """ Add a key to the key map. """ self._check_contexts(contexts) for b in self.bindings: if b.key == key and b.command.strip() == command.strip(): b.contexts = sorted(list(set(b.contexts + contexts))) if help: b.help = help self.bind(b) break else: self.remove(key, contexts) b = Binding(key=key, command=command, contexts=contexts, help=help) self.bindings.append(b) self.bind(b) signals.keybindings_change.send(self)
def add_command(self, command: str) -> None: if not command.strip(): return self.history.append(command) if ctx.options.command_history: with self.history_file.open("a") as f: f.write(f"{command}\n") f.close() self.set_filter('')
def add_command(self, command: str) -> None: if not command.strip(): return self.history.append(command) if ctx.options.command_history: try: with self.history_file.open("a") as f: f.write(f"{command}\n") except Exception as e: ctx.log.alert(f"Failed writing to {self.history_file}: {e}") self.set_filter('')