0

I’m trying to make a Bash script that opens tmux and runs a few lines of commands and then detach it so I end up in my terminal after it’s done. How do I solve it? Tried everything.

≈#!/bin/bash
cd ~/data
mkdir $1

This is what I got so far. When running my Bash script I type in:

myScript folder_name https://myurl.com

And now I wanna start a tmux session and run:

screamingfrogseospider  \
--crawl $2  \
--headless  \
--save-crawl  \
--output-folder ~/data/$1  \
--timestamped-output \

But how do I make a script that opens up tmux and runs these lines and closes also runs tmux detached so I end up in my terminal window?

mattb
  • 2,787
  • 2
  • 6
  • 20
  • What research did you do? Did you research how to start tmux with a custom command on this forum? What did the research resulted in? – KamilCuk May 06 '21 at 06:43
  • 1
    it resulted in I have no idea what i´m doing and thats why i asked for help =). Can get it to open tmux but not add the commands I need to do in the new tmux session. – Sonlard Berglund May 06 '21 at 06:52
  • 6
    https://stackoverflow.com/questions/34769672/how-to-create-a-layout-and-run-commands-in-at-tmux-launch https://stackoverflow.com/questions/5609192/how-to-set-up-tmux-so-that-it-starts-up-with-specified-windows-opened https://stackoverflow.com/questions/21892254/start-tmux-with-command-specify-configuration-file https://unix.stackexchange.com/questions/443569/start-tmux-and-execute-a-set-of-commands-on-boot https://superuser.com/questions/492266/run-or-send-a-command-to-a-tmux-pane-in-a-running-tmux-session – KamilCuk May 06 '21 at 06:57
  • `tmux attach`, `tmux detach` will help you – mattb May 06 '21 at 08:07
  • the problem is that if i run tmux attach inmy bash file the rest av dthe scripts don´t run. – Sonlard Berglund May 11 '21 at 11:05

0 Answers0