Skip to content

Instantly share code, notes, and snippets.

@sooluh
Last active December 30, 2022 07:18
Show Gist options
  • Save sooluh/5795570b5c0e2fb6a3b14c6428338d32 to your computer and use it in GitHub Desktop.
Save sooluh/5795570b5c0e2fb6a3b14c6428338d32 to your computer and use it in GitHub Desktop.
Create a new tmux session and run the command
#!/bin/bash
# Change the value of the PATH variable (optional)
PATH="/root/.nvm/versions/node/v14.15.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
tmux new-session -d -s session_name -n window_name
tmux send-keys -t session_name:window_name "cd /to/your/path" Enter
tmux send-keys -t session_name:window_name "run command here" Enter
@sooluh
Copy link
Author

sooluh commented Dec 27, 2020

Example:

#!/bin/bash

PATH="/root/.nvm/versions/node/v14.15.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"

tmux new-session -d -s ionic -n mobile
tmux send-keys -t ionic:mobile "cd ~/my-ionic-project" Enter
tmux send-keys -t ionic:mobile "ionic serve --port=9602" Enter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment