3

On startup, I want to have a new tmux session created which inside of that session changes directory and executes a bash script. How do I do this?

Cheers,

Tom

tdubz
  • 41

1 Answers1

5

Create the following script, but adjust it to your needs:

#!/bin/bash

Create a new session named "newsess" and run a command inside the session

tmux new-session -d -s newsess tmux send-keys -t newsess "./path/to/myscript" Enter

Attach to session named "newsess"

tmux attach -t newsess

  • newsess is the name of the session
  • ./path/to/myscript is the full path of the script you want to run inside tmux.

Use any of the methods described here to run the above script on startup.

Artur Meinild
  • 26,018