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

Invoke actions from command line #413

Closed
mrzv opened this issue Apr 29, 2021 · 8 comments
Closed

Invoke actions from command line #413

mrzv opened this issue Apr 29, 2021 · 8 comments
Assignees
Labels
hacktoberfest For the hacktoberfest month help wanted Extra attention is needed

Comments

@mrzv
Copy link

mrzv commented Apr 29, 2021

I can't quite tell from browsing existing issues if the following is on the roadmap or not. Tmux has very useful functionality, where it is possible to open new windows (tabs in zellij) by running tmux new-window within a tmux window. It would be great if zellij supported the same. (Thee are other commands in tmux; new-window is the one I'm missing at the moment.)

This request is different from #284, unless I completely misunderstand that one.

@mrzv
Copy link
Author

mrzv commented Apr 30, 2021

Just wanted to add that the useful command is not just tmux new-window, but tmux new-window 'command to run with arguments'. E.g., tmux new-window 'ls -l'.

@a-kenji
Copy link
Contributor

a-kenji commented Apr 30, 2021

Thanks for taking the time and creating this issue!
It is definitely something that we want and it is very good to have an actual issue on that.

@imsnif imsnif added hacktoberfest For the hacktoberfest month help wanted Extra attention is needed labels Sep 25, 2021
@sharkmoos
Copy link

Second this. To add to it, the ability to split windows via a command rather than a key binding is very useful. tmux splitw 'ls -l'

@a-kenji
Copy link
Contributor

a-kenji commented Jun 15, 2022

This is now implemented on the main branch,
it is not in a release yet.

We would be happy for people trying this feature out and getting feedback prior
to a release.

@a-kenji a-kenji closed this as completed Jun 15, 2022
@mrzv
Copy link
Author

mrzv commented Jun 15, 2022

So how does one run a command in a new tab? NewTab: creates a new tab, and Run: ... runs a command in a new pane.

Also the action syntax is not very user-friendly. Run:, in particular, is going to be difficult to use.

@a-kenji
Copy link
Contributor

a-kenji commented Jun 15, 2022

It is just, as if you would bind the NewTab action to the configuration https://zellij.dev/documentation/actions#newtab-tablayout :

Open htop in a new tab:

zj action "NewTab: {run: {command: {cmd: htop}}}"

Also the action syntax is not very user-friendly. Run:, in particular, is going to be difficult to use.

Yes, we are aware of that, that will be addressed once we move to kdl.

I will quote from #1265 :

So if someone wants to improve the action parsing here, should implement #771.

@mrzv
Copy link
Author

mrzv commented Jun 15, 2022

Open htop in a new tab:

zj action "NewTab: {run: {command: {cmd: htop}}}"

That does indeed work, except I don't understand how you got it from that documentation page.

I've never seen KDL; thanks for the pointer. I don't understand enough of it to see how it would let you change zj action "NewTab: {run: {command: {cmd: htop}}}" to zj action NewTab -c htop or something simple like that. But that's Ok; I'll wait and see what it looks like. As long as the syntax issue is on your radar, it's all good.

@a-kenji
Copy link
Contributor

a-kenji commented Jun 15, 2022

We didn't document it directly yet, since it is not released yet.

You can read more here:
#1265
and here:
https://github.com/zellij-org/zellij/blob/main/CHANGELOG.md#unreleased

But actions have already quite a few examples:

        - action: [
          NewTab: {
  name: "a new tab",
  parts: [
    {direction: Vertical, parts: [ pane_name: "testing", pane_name: "building" ]},
    {pane_name: "I should have focus", focus: true},
  ],},
        ]
          key: [ Char: '7',]

This will build a NewTab with the described layout.

You can transfer this knowledge because it is yaml to a single line,
for example:

 zellij action "NewTab: {direction: Vertical, parts: [{run: {command: {cmd: htop}}}, parts: [run: {command: {cmd: htop}}, run: {command: {cmd: htop}}]]}"

As long as the syntax issue is on your radar, it's all good.

Yes it is on our radar. Kdl is made in order to specify commands easily. We can omit the keys that are needed for yaml to function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest For the hacktoberfest month help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants