shell -${SHELL}
caption always "%n(%t) %= %{b}@%H[%l] : %{r}%c:%s"
termcapinfo xterm ti@:te@
termcap  xterm 'AF=\E[3%dm:AB=\E[4%dm'
terminfo xterm 'AF=\E[3%p1%dm:AB=\E[4%p1%dm'
startup_message off

screen -t server 0 rails s
screen -t spork 1 bundle exec spork
screen -t dev_log tail -f ./log/test.log

Pressing Ctrl+C in any of the screen windows above destroys it. I would like to have subshell for every so if I press Ctrl+C than I just exit to that subshell.

Right now I'm running screen and creating all windows above manually, renaming them and it works great. I can terminate any program on any window, do something else and run it again. What I want to achieve is to have that set-up to run with just one command.

migrated from serverfault.com Apr 4 '14 at 1:24

This question came from our site for system and network administrators.

  • a shell exit when ctrl + D not C crtl C quit the running app – Kiwy Apr 4 '14 at 11:59
  • ctrl+C closes the app that's running in the window and screen closes that window than too – pawel7318 Apr 4 '14 at 12:02
  • what is your default shell ? – Kiwy Apr 4 '14 at 13:52

How about instead of a subshell, just open a new one when your app finishes?

screen -t htop bash -i -c "htop && bash"

I decided to create another related question How to keep Bash running after command execution? to just forget about big picture and focus on the main problem. Worked as intended and finally there were presented 3 ways to achieve the goal:

  1. workaround which was not bad
  2. portable (POSIX)
  3. simple

and I choose to use 3rd one that way:


/bin/bash -i <<<"$*; exec </dev/tty"


screen -t server 1 ${HOME}/.run_screen rails s
screen -t spork 2 ${HOME}/.run_screen bundle exec spork
screen -t dev_log 3 ${HOME}/.run_screen tail -f ./log/development.log
screen -t test_log 4 ${HOME}/.run_screen tail -f ./log/test.log
screen -t bash 0  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.