wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
17.28k stars 781 forks source link

Send text to a wezterm pane given its id from the command line #888

Closed Anomalocaridid closed 2 years ago

Anomalocaridid commented 3 years ago

Is your feature request related to a problem? Please describe. No.

Describe the solution you'd like I would like the ability to send text to a wezterm pane, given its window, tab, and pane ids, like a window created with wezterm start and running an interactive program like a shell in order to execute the text as a command or enter it as some other input.

Describe alternatives you've considered I am unaware of any alternatives that give a similar functionality.

Additional context I created a plugin for the text editor Kakoune that aims to provide integration with WezTerm that is similar to the integration that Kakoune provides with other terminal emulators and terminal multiplexers by default. This would allow me to add functionality that is currently missing when compared with the default terminal integration.

xiangpeng2008 commented 3 years ago

so this is not yet supported, right

wez commented 3 years ago

so this is not yet supported, right

Correct, this enhancement request is still open!

wez commented 2 years ago

In the nightly build available within 30 mins of this comment being posted, you can do:

wezterm cli send-text "hello"

or:

echo something | wezterm cli send-text

See wezterm cli send-text --help for more information.

xiangpeng2008 commented 2 years ago

hi @wez how to get the pane-id ? When I do wezterm cli list, I got only 1 record, is this expected ? I opened 2 tabs and multiples panes after ssh from windows 10 to centos 7 ( https://wezfurlong.org/wezterm/ssh.html ) image

xiangpeng2008 commented 2 years ago

When I tested without ssh on mac, I got 2 records by just opening a new tab.

Screenshot 2022-05-08 at 10 08 17 PM
wez commented 2 years ago

@xiangpeng2008: please open a separate issue!

xiangpeng2008 commented 2 years ago

btw, how could I send a enter or break-line key ? for example, I want pane 0 to execute echo hello, but wezterm cli send-text --pane-id 0 "echo hello\n" doesn't do the job, it just shows image

xiangpeng2008 commented 2 years ago

also is there an easy way to know the pane id of specific pane ?

wez commented 2 years ago

wezterm sets the WEZTERM_PANE environment variable to the pane id when it launches a pane. The CLI will use that as the pane id if you don't explicitly specify it.

xiangpeng2008 commented 2 years ago

btw, how could I send a enter or break-line key ? for example, I want pane 0 to execute echo hello, but wezterm cli send-text --pane-id 0 "echo hello\n" doesn't do the job, it just shows image

hi @wez , do you have an idea to send an enter key ?

wez commented 2 years ago

echo -e "hello\n" | wezterm cli send-text is probably the easiest way

xiangpeng2008 commented 2 years ago

sorry when I said "enter" I wanted to let my command to be executed, but when I do

echo -e "echo hello\n" | wezterm cli send-text --pane-id 0

The command is not executed, but just have line break after.

Screenshot 2022-05-10 at 11 13 05 PM
xiangpeng2008 commented 2 years ago

same for a python session

echo -e "print(1)\n" | wezterm cli send-text --pane-id 0
Screenshot 2022-05-10 at 11 14 20 PM
xiangpeng2008 commented 2 years ago

btw, is it possible to get current wezterm window id , and wezterm pane id ? image I didn't seem to see them in the env

xiangpeng2008 commented 2 years ago

sorry when I said "enter" I wanted to let my command to be executed, but when I do

echo -e "echo hello\n" | wezterm cli send-text --pane-id 0

The command is not executed, but just have line break after. Screenshot 2022-05-10 at 11 13 05 PM

fyi this issue only happens for mac, when I connect from windows 10 to centos 7,

echo -e "echo hello\necho world" | wezterm cli send-text --pane-id 7

\n could serve as enter image

MuhammedZakir commented 2 years ago

Remember you're sending "text" as if you're pasting it. This will be different than "typing". This can be easily seen in Vim.

About newline: try \r or \r\n.

wez commented 2 years ago

385f3c99d3b2311fde1ed494d0d3d327ebdca28b adds a --no-paste flag to wezterm cli send-text

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.