2

The bash/screen scenario:

screen -dmS sessionname -c /path/to/screenrc

the /path/to/screenrc contains for example

screen -t windowtitle1 bash --init-file /path/to/window1.bashinit
screen -t windowtitle2 bash --init-file /path/to/window2.bashinit
screen -t windowtitle3 bash --init-file /path/to/window3.bashinit

e.g. it

  • starts a screen session in detached mode
  • the screen execute the defined screenrc
  • from the screenrc
    • starts 3 different interactive bash windows
    • and each the bash executes the content of the defined init-file
    • and after executing them, the bash continue in interactive mode (!)

So, at the end I got

  • an detached screen session
  • with a 3x running bash in interactive mode
  • and each of them already executed some commands (defined in their init-file)

How to achieve the same functionality with the tcsh?

2 Answers 2

3

You don't need to force tcsh to do the work that screen can do for you instead. Simply start your 3 windows:

cat <<\! >/path/to/screenrc
screen -t windowtitle1 tcsh
screen -t windowtitle2 tcsh
screen -t windowtitle3 tcsh
!
screen -dmS sessionname -c /path/to/screenrc

then stuff (ie "type") the init command into each window:

screen -p windowtitle1 -X stuff 'source /path/to/window1.tcshinit\n'
screen -p windowtitle2 -X stuff 'source /path/to/window2.tcshinit\n'
screen -p windowtitle3 -X stuff 'source /path/to/window3.tcshinit\n'
2
  • This is great. Just instead of the \n i must use ^M (CTRL-V CTRL-M), otherwise i just got in the window: source /path/to/window1.tcshinit\n (with the literal \n) and the source command isn't executed.
    – clt60
    Oct 19, 2015 at 10:37
  • ok, good to know. I tried \n and \r and they both seemed to work. I'm not sure why they don't for you, perhaps different versions of the tools.
    – meuh
    Oct 19, 2015 at 11:47
1

As far as I know you can't, not directly anyway.

What you can do is create win1.tcsh, win2.tcsh, etc. with the contents:

echo Starting win1
setenv WINDOW 1
exec tcsh

Invoke that as tcsh -c 'source win1.tcsh', and in your tcshrc do something like:

if ( $WINDOW == "1" ); then
   # My custom commands...
endif

You must log in to answer this question.

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