roxterm icon indicating copy to clipboard operation
roxterm copied to clipboard

Running a command at tab startup

Open patrickmslatteryvt opened this issue 6 years ago • 3 comments

I'm trying to figure out how to modify the session default file to run a command at startup that I use to set my environment:

Here is what I have currently in my startup file: ~/.config/roxterm.sourceforge.net/UserSessions/Default

<roxterm_session id='Default'>
  <window geometry='189x49+26+23'
      title_template='%s' font='Monospace 11'
      title_template_locked='0'
      title='pslattery@think440: ~' role='(null)'
      shortcut_scheme='Default' show_menubar='1'
      always_show_tabs='1' tab_pos='2'
      show_add_tab_btn='1'
      disable_menu_shortcuts='0' disable_tab_shortcuts='0'
      maximised='0' fullscreen='0' zoom='1.000000'>
    <tab profile='Default'
        colour_scheme='Nocturne' cwd='/home/pslattery'
        title_template='%s' window_title='pslattery@think440: ~'
        title_template_locked='0' current='1'>
      <command argc='1'>
        <arg s='/usr/bin/zsh' />
      </command>
    </tab>
  </window>
</roxterm_session>

What I really what to do is run a zsh alias ai have defined on startup of the tab and that alias will setup my Kubernetes environment. I'm imagining it's something like:

      <command argc='2'>
        <arg s='/usr/bin/zsh' />
        <arg s='setup_env_cust_x' />
      </command>

I have this for a dozen tabs in reality, the above is just an example of one tab.

patrickmslatteryvt avatar Mar 08 '19 17:03 patrickmslatteryvt

That should work, although the shell is probably running the setup script then exiting, and I would guess what you're trying to do is make it run the script in place of, or in addition, to .zshrc. Does it work if you add the -i option?

realh avatar Mar 08 '19 18:03 realh

What I'm trying to do is bring up a dozen tabs each running a zsh shell and run a different alias/script in each so as to give each access to a different Kubernetes cluster. I need each tab/shell to remain up.

I tried the following as a simple experiment:

      <command argc='2'>
        <arg s='/usr/bin/zsh' />
        <arg s='usr/bin/uptime' />
      </command>

This should give me a tab running zsh that initially spits out the system uptime. But when I save this and restart ROXTerm it just gives me a normal zsh tab as if the second arg was never there.

Where would I add the -i option? Is there a place where the possible args of the UserSessions file is documented? Thanks

patrickmslatteryvt avatar Mar 08 '19 18:03 patrickmslatteryvt

The -i option is for zsh, so try: <command argc='2'> <arg s='/usr/bin/zsh' /> <arg s='-i' /> <arg s='/usr/bin/uptime' /> </command>

If you pass a script to a shell it normally exits after the script, and roxterm's default behaviour is to close the tab. -i forces the shell to be interactive, but the man page doesn't say what happens if you try to use it in addition to passing a command. If it doesn't do what you want, and your setup scripts work mainly by setting up environment variables, maybe you could alter them to make sure they export all those variables then end by launching an interactive/login shell with no other arguments.

realh avatar Mar 08 '19 20:03 realh