Skip to content

Conversation

@frenautvh
Copy link

Hello,

This PR introduces a "sendCommand" method to invoke commands programmatically, here is a sample usage :

import { useEffect, useRef } from "react";
import { ReactTerminal, type ReactTerminalHandle } from "react-terminal";

const commands = {
  cd: (directory: string) => `changed path to ${directory}`
};

function App() {
  const termRef = useRef<ReactTerminalHandle>(null)

  useEffect(() => {
    setTimeout(() => {
      termRef.current?.sendCommand("cd foo")
    }, 3000)
  }, [])

  return (
    <ReactTerminal
      commands={commands}
      welcomeMessage="hello world"
      ref={termRef}
    />
  );
}

export default App;

I also noticed that the typing was not correctly exported on ReactTerminal component, this PR should also fix this issue.

Signed-off-by: Florian Renaut <florian.renaut@corp.ovh.com>
@frenautvh
Copy link
Author

this PR should fix #333

@frenautvh
Copy link
Author

Hi @bony2023, just wanted to kindly follow up on this PR. Please let me know if there’s anything I can do to help move it forward. Thanks for your time and for maintaining this project! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant