Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Anomalocaridid opened this issue Jun 19, 2021 · 18 comments
Closed

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

Anomalocaridid opened this issue Jun 19, 2021 · 18 comments
Labels
enhancement New feature or request fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds. multiplexer

Comments

@Anomalocaridid
Copy link
Contributor

Anomalocaridid commented Jun 19, 2021

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
Copy link

so this is not yet supported, right

@wez
Copy link
Owner

wez commented Oct 17, 2021

so this is not yet supported, right

Correct, this enhancement request is still open!

wez added a commit that referenced this issue Jan 17, 2022
@wez wez added the fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds. label Jan 17, 2022
@wez
Copy link
Owner

wez commented Jan 17, 2022

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.

@wez wez closed this as completed Feb 4, 2022
@xiangpeng2008
Copy link

xiangpeng2008 commented May 8, 2022

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
Copy link

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
Copy link
Owner

wez commented May 9, 2022

@xiangpeng2008: please open a separate issue!

@xiangpeng2008
Copy link

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
Copy link

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

@wez
Copy link
Owner

wez commented May 10, 2022

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
Copy link

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
Copy link
Owner

wez commented May 10, 2022

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

@xiangpeng2008
Copy link

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
Copy link

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
Copy link

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
Copy link

xiangpeng2008 commented May 11, 2022

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
Copy link
Contributor

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
Copy link
Owner

wez commented May 25, 2022

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

@github-actions
Copy link

github-actions bot commented Feb 4, 2023

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds. multiplexer
Projects
None yet
Development

No branches or pull requests

4 participants