question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Executing a command doesn't work with zsh

See original GitHub issue

Executing a command doesn’t work with zsh. In zsh a new line is added to the command line, but it’s not executed. A manual press of Enter is necessary to execute.

Details

  • Browser and browser version: Chrome 103
  • OS version: Ubuntu 20.04
  • xterm.js version: 4.19.0 (what is shipped with ttyd 1.6.3)

Steps to reproduce

Executing a command seems to only work with bash, not zsh:

window.term.paste('ls\n'); # bash only
window.term.paste('ls\r\n'); # bash only
window.term.paste('ls\r'); # bash only
window.term.write('ls\n'); # neither works
window.term.write('ls\r\n'); # neither works
window.term.write('ls\r'); # neither works

Any idea how this can be achieved with any shell?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jerchcommented, Sep 10, 2022

@Jeremy-Boyle

What you are looking for, is to write to the datasink you are also forwarding term.onData(write_to_datasink) too. You just need to do write_to_datasink('ls\r'), should work with all shell types.

Just call your onData function with the command you want and your done. No need for term.paste or additional keyboard libs on top.

0reactions
Jeremy-Boylecommented, Sep 10, 2022

@wuestkamp https://github.com/tsl0922/ttyd/issues/620#issuecomment-789693717

Works for zsh

import "keysim"

terminal.paste(command);

// use keyshim to send enter key
var input = document.querySelector('textarea');
var keyboard = Keysim.Keyboard.US_ENGLISH;
keyboard.dispatchEventsForAction("enter", input);
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix Zsh Command Not Found Error on macOS [5 Ways]
Zsh Command Not Found FAQs · Step 1. Open the .zshrc file with the command nano /.zshrc. · Step 2. Add the following...
Read more >
in mac always getting zsh: command not found: - Stack Overflow
To permanently fix it, you shall go to .zshrc file which is in your root directory. You can do: · make sure the...
Read more >
How to Fix "Zsh command not found" error in Linux or macOS
Step1 - Open a terminal and make sure, you are on the zsh prompt. If not then type zsh and press enter. Step2...
Read more >
[Fixed] Mac Command Not Found Error in Terminal: Zsh & Bash
When Terminal says "command not found", it means that the command you entered isn't in your search path. This can occur due to...
Read more >
How to fix the "zsh command not found" error | codedamn news
Solution 4 – Make sure the command is accessible and on $PATH. Most of the time it happens that the command is not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found