A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
/* Copyright 2026 Marimo. All rights reserved. */
import { useChromeActions } from "../editor/chrome/state";
import { useTerminalActions } from "./state";
/**
* Hook for sending commands to the terminal programmatically.
* This will:
* 1. Open the terminal if it's not already open
* 2. Wait for the terminal to be connected
* 3. Send the command text to the terminal
*
* @example
* ```tsx
* function CopyButton({ command }: { command: string }) {
* const { sendCommand } = useTerminalCommands();
*
* return (
* <button onClick={() => sendCommand(command)}>
* Copy to Terminal
* </button>
* );
* }
* ```
*/
export function useTerminalCommands() {
const { addCommand } = useTerminalActions();
const { openApplication } = useChromeActions();
const sendCommand = (text: string) => {
// First, ensure the terminal is open
openApplication("terminal");
// Add the command to the queue
addCommand(text);
};
return {
sendCommand,
};
}