stepb / urxvt-tabbedex

Tabbed plugin for rxvt-unicode with many enhancements
75 stars 54 forks source link

Create multiple tabs and run a command in each tab? #42

Open kariotay opened 9 years ago

kariotay commented 9 years ago

A similar request was made here:

Start a number of preset tabs running a comand https://github.com/stepb/urxvt-tabbedex/issues/12

I'd like to know if it's possible to create a new tab, and send a command to the tab. Any command -- ls, vim, emacs, etc.

For example, if you want to automate your setup and not have to create the terminals by hand every time you log in, you could create a perl extension using tabbedex's functionality.

This is the basic idea:

$new_tab_one = tabs->create_new_tab('vim_tab', ...); # create a new 'tab' object
$new_tab_two = tabs->create_new_tab('emacs_tab', ...); # create a new 'tab' object

$cmd_a = ... # the command could be anything: ls, vim, a shell script, etc.
$cmd_b = ... # the command could be anything: ls, vim, a shell script, etc.

$new_tab_one->send_command($cmd_a); # send the command to the tab
$new_tab_two->send_command($cmd_b); # send the command to the tab

It would be useful to be able to do this, and it seems like a feature that would be a great enhancement to the functionality of tabbedex.

mina86 commented 8 years ago

Check out https://github.com/mina86/urxvt-tabbedex/tree/experimental branch. It has an experimental feature which allows you to get custom commands in subsequent tabs. The feature to run multiple tabs at start-up is missing though.

Lourens-Rich commented 7 years ago

@mina86, why you don't merge this changes to master branch?

mina86 commented 7 years ago

It’s only partial solution and more importantly I haven’t tested and thought it through just yet. In particular, while environment variable does the job, maybe there’s some better way of achieving the same result? Some more generic way for tab’s content to get information from tabbedex.

mina86 commented 6 years ago

I’ve pushed a feature where new-tab-command resource accepts multiple values. This way one can specify different command for different tabs with:

URxvt.tabbedex.new-tab-command: \
    -e /usr/bin/irssi \n\
    -c echo /var/log/syslog:; exec tail -f /var/log/syslog \n\
    clear

The feature is available at https://github.com/mina86/urxvt-tabbedex/tree/experimental and with it, I’ll probably deprecate the $URXVT_TAB approach (even though it’s still present in the branch). Testing and feedback welcome!

mina86 commented 6 years ago

I’ve ended up going with a bit different approach but one which lets you achieve result similar to what I’ve described above. See https://github.com/mina86/urxvt-tabbedex/blob/master/command-runner.sample which describes how different commands can be achieved.

There still is no way to start multiple tabs at once though.