Results 1 to 4 of 4

Thread: gnu screen startup automation

  1. #1
    Join Date
    May 2009
    Location
    Courtenay, BC, Canada
    Beans
    1,661

    gnu screen startup automation

    I was wondering if there was a way to specify commands to run on a new window in screen, such as the motd in a regular terminal session. simply adding a command causes screen to run it and then terminate
    Last edited by HiImTye; June 8th, 2013 at 11:11 AM.

  2. #2
    Join Date
    Jun 2006
    Location
    Knoxville, TN (USA)
    Beans
    24
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: gnu screen startup automation

    Try the example described in the accepted StackOverflow answer here. Basically you put the startup command you want in ~/.screenrc, as you seem to have tried. However a bash command alone will quickly exit, hence the need for something extra.

    If you want to start a screen session with a customized command, then:

    screen -c ~/.screenrc-custom
    Last edited by hardmath; May 25th, 2013 at 01:47 PM. Reason: syntax to use custom configuration

  3. #3
    Join Date
    May 2009
    Location
    Courtenay, BC, Canada
    Beans
    1,661

    Re: gnu screen startup automation

    it didn't work, just terminated as expected
    this also didn't work in .screenrc
    Code:
    screen -D -R -S tye
    screen -S tye -X exec ~/Launchers/checkUpdates
    results in
    Code:
    invalid option -D
    invalid option -R
    invalid option -S
    cannot exec 'tye'

  4. #4
    Join Date
    May 2009
    Location
    Courtenay, BC, Canada
    Beans
    1,661

    Re: gnu screen startup automation

    I switched to tmux, but I solved it by adding
    Code:
    # -- tmux section --
    # check if we're in it
    if [ -n "$TMUX" ]; then
     # yes, run our automation
     alias exit="history -c; exit"
     checkUpdates
    else
     alias exit="history -c; if [ -f $HOME/.bash_history ]; then rm $HOME/.bash_history; fi; if [ -f $HOME/.lesshst ]; then rm $HOME/.lesshst; fi; exit"
     w0="$(ps -ef | grep tmux | grep -v grep)"
     # check if tmux is running
     if [ -n "$w0" ]; then
      # yes, attach
      tmux -u attach
     else
      # no, start a new session
      tmux -u
     fi 
    fi
    to
    Code:
    $HOME/.bashrc
    I suspect that it could work similarly for screen.
    Last edited by HiImTye; August 15th, 2013 at 10:17 AM. Reason: updated to newest

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •