3

I am using .byobu/windows to start up some screen sessions, and I'm trying to start a script that will exit to an interactive shell once it has completed. Is this possible?

I've tried:

screen -t test /bin/bash -i /path/to/script
screen -t test /bin/bash - /path/to/script

I realize I could just add a /bin/bash to the end of the script, but I don't want that as a solution for when I run the script in a shell...

1
  • What does the script you want to run before the command prompt do?
    – Bananguin
    Commented Aug 14, 2013 at 5:02

3 Answers 3

2

If it's important to use the same shell use the --rcfile flag.

$ cat test.bashrc 
ls
PS1='TEST \$'
$ screen -t test bash --rcfile test.bashrc -i
a.file  b.file  test.bashrc
TEST $

If your .bashrc is setting the environment, be sure to source it.

2

The only reasonable way that I've found to run a command, leaving the output and an interactive shell behind within screen is to use the 'stuff' command to execute the command:

screen -t title1 bash
stuff 'ls /tmp^M'  # in vim type control-v control-m to insert the return at the end
1

If possible, just start two commands.

screen -t test /bin/bash /path/to/script; /bin/bash

If you are only able to start one command, try this:

/bin/bash -c 'screen -t test /bin/bash /path/to/script; /bin/bash'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .