title: Creating Sessions and Screens 1 tags: tmux # To Create A Session ```bash tmux new-session -s turnip tmux new-session -d -s cityscape # start detached ``` # To Create A Window ```bash tmux new-window -n -t tmux new-window -n -t : ``` ## Explicit Window Number To avoid the ``` create window failed: index 2 in use ``` error use an explicit window number: ```bash tmux new-window -n -t : ``` # Example This is a random script from my pi3 which starts up some services written in Python. * One receives UDP packets and sends wakeonlan packets (I haven't succeeded sending them from Windows machines via command line tools, so resorted to sending UDP to my pi3). * One provides a HTTP interface for sending Wakeonlan packets. This enables me to wake devices from my mobile via a web browser. It also, for Linux targets, allows to sleep and shutdown via ssh. * The other is a process which manages multiple mpd (Music Player Daemon) instances around my LAN. This script is a `@reboot` entry in my pi3's crontab. ```bash #!/bin/bash start_wol_all() { ( cd ~/wol tmux new-session -d -s wol sleep 1 tmux new-window -n mpdmgr_http -t wol:1 p mpdmgr_http.py sleep 1 tmux new-window -n wolsrv_http -t wol:2 p wolsrv_http.py sleep 1 tmux new-window -n wolsrv -t wol:3 p wolsrv.py ) } start_wol_all ```