INNER CODE UNIT · Python

append_to_bash_history

gorilla-llm/gorilla-cli · go_cli.py:67

def append_to_bash_history(selected_command):
    try:
        with open(os.path.expanduser("~/.bash_history"), "a") as history_file:
            history_file.write(selected_command + '\n')
    except Exception as e:
        pass




def prefill_shell_cmd(cmd):
    # Inspired from 
    stdin = 0
    # Save TTY attributes for stdin
    oldattr = termios.tcgetattr(stdin)
    # Create new attributes to fake input
    newattr = termios.tcgetattr(stdin)
    # Disable echo in stdin -> only inject cmd in stdin queue (with TIOCSTI)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…