How to set up tmux so that it starts up with specified windows opened?
Join Stack Overflow to learn, share knowledge, and build your career.
|
You can write a small shell script that launches tmux with the required programs. I have the following in a shell script that I call dev-tmux. A dev environment:
So everytime I want to launch my favorite dev environment I can just do
|
|||||||||||||
|
|
You can source different sessions from your
And then format the sessions as you require:
This would open 2 windows, the second of which would be named foo/bar and would be split vertically in half (50%) with foo running above bar. Focus would be in window 2 (foo/bar), top pane (foo). You can then start your preferred tmux session (in this case, session1) with PrefixShifts |
|||||||||||||||||||||
|
|
Use tmuxinator - it allows you to have multiple sessions configured, and you can choose which one to launch at any given time. You can launch commands in particular windows or panes and give titles to windows. Here is an example use with developing Django applications. Sample config file:
See the README at the above link for a full explanation. |
|||||||||
|
|
I was trying to create a complex grid of panes and had to deal with switching and splitting panes over and over again. Here are my learnings:
Gets you started with a new session. To split it horizontal or vertical use
Creates 3 panes, like this:
To run commands in that panes, just add them with the
And the resulting session should look like that.
Now I tried to again sub-divide the bottom left pane, so switching either back using
Does that. Basicly knowing your way around with
Hope that helps |
|||||
|
|
have a look @ https://github.com/remiprev/teamocil you can specify your structure using YAML
|
|||
|
|
session1
create an alias in .bashrc
|
||||
|
|
|
From my "get.all" script, which I invoke each morning to run a bunch of subsequent "get.XXX" jobs to refresh the software that I track. Some of them are auto-quitting. Others require more interaction once the get has finished (like asking to build emacs).
|
|||
|
|
|
If you just want to split screen on 2 panes (say horizontally), you can run this command (no tmux or shell scripts required):
You screen will look like this:
|
|||
|
|
|
First i had the approach from @jasonwryan but if you have more then 2 configs, it can get confusing. So i created an alias function:
In Update: The purpose of "$2" after the |
||||
|
|
|
This works for me. Creating 5 windows with the given names and auto selecting to the
|
|||
|
|
|
And this is how I do it:
I have one file for each of my project. Also you can group them to have some for work some for hobby projects. Also you can move it to |
|||
|
|
|
You should specify it in your tmux config file (
(opens one session with 2 windows with mocp launched in first and mutt in second, and another detached session with 3 empty windows). |
|||||
|
|
I've create this script. It does not need tmuxinator, ruby or others. It is just a bash script, configurable: A file named config should contains something like this:
and the bash code should be:
|
|||||
|
|
tmuxp support JSON or YAML session configuration and a python API. A simple tmuxp configuration file to create a new session in YAML syntax is:
|
|||
|
|
|
The plugin tmux-continuum will auto save your tmux session and load it the next time tmux starts, should be easier to setup than some of the custom script solutions here.
To save your session on demand you can use the tmux-resurrect plugin. tmux-resurrect is also required to run tmux-continuum
|
|||
|
|
|
I just tried using all the ideas on this page and I didn't like any of them. I just wanted a solution that started tmux with a specific set of windows when my terminal opened. I also wanted it to be idempotent, i.e. opening a new terminal window takes over the tmux session from the previous one. The above solutions often tend to open multiple tmux sessions and I want just one. First, I added this to my
then I added the following to my
now every time I start a terminal or start tmux or whatever, I either reattach to my existing desired setup (the session named |
|||
|
|
|
There is a tmux plugin for this. Check out tmux-resurrect
|
||||
|
|