Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
tmux: pull config file after session starts
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
1clue
Advocate
Advocate


Joined: 05 Feb 2006
Posts: 2569

PostPosted: Fri Oct 24, 2014 2:30 am    Post subject: tmux: pull config file after session starts Reply with quote

Hi,

I want to do the equivalent of this:
Code:

tmux attach <name> || (tmux create-session <name>;{wait for session to init};C-b:source-file ~/.tmuxes/<name>)


So here's the deal:
I have several different terminal scenarios. Frequently I'm developing on several interconnected projects and need to bounce from one to the other and keep command history.

I have a config file like this:

Code:

rename-session "myproject"
select-window -t :0
rename-window 'foo'
send-keys -t :0 "cd foo;c" C-m
new-window -t :1 -c "bar" -n "bar"
new-window -t :2 -c "bamf" -n "bamf"
new-window -t :3 -c "biff" -n "biff"
# and so on
select-window -t :0


The problem is, if I put these commands into the .tmux.conf file it says session not available, because when that file is read there is no session yet.

So what I want is to write a script which:

  1. starts tmux trying to bind to the named session if it exists. If success, then exit 0.
  2. start tmux with a new session.
  3. tell the running tmux to source-file <name>


Does somebody know how to, from the command line, source-file a second file like that?

Thanks.
Back to top
View user's profile Send private message
Ottre
Tux's lil' helper
Tux's lil' helper


Joined: 23 Dec 2012
Posts: 129

PostPosted: Sun Nov 02, 2014 1:14 am    Post subject: Re: tmux: pull config file after session starts Reply with quote

1clue wrote:
Frequently I'm developing on several interconnected projects and need to bounce from one to the other and keep command history.


The tmux-resurrect plugin can save and restore your session - windows you have open and your bash history.

Make ~/.tmux/resurrect a symlink, write an eselect module for it, and you can juggle multiple sessions.
Back to top
View user's profile Send private message
1clue
Advocate
Advocate


Joined: 05 Feb 2006
Posts: 2569

PostPosted: Mon Nov 03, 2014 1:35 am    Post subject: Reply with quote

I'm doing something like this:

Code:

tmux -f ~/tmuxes.conf


where tmuxes.conf is something like:
Code:

set -g utf8
set-window-option -g utf8 on

new-session -d -s "foo" -n "nine-db"
send-keys  -t ced:0  "cd $HOME/ws/98/ced/nine-db;clear" C-m
new-window -t ced:1  -c "$HOME/ws/98/ced/angle-grinder" -n "grndr"
new-window -t ced:2  -c "$HOME/ws/98/ced/rally"         -n "rally"
...
select-window -t ced:0

new-session -s "bar" -n "nine-db"
send-keys  -t thapps:0 "cd $HOME/ws/trunk/head/nine-db;clear" C-m
new-window -t thapps:1 -c "$HOME/ws/trunk/head/rcm"              -n "rcm"
new-window -t thapps:2 -c "$HOME/ws/trunk/head/ar-api"           -n "arapi"
...
select-window -t thapps:0

new-session -s "thplugins" -n "nine-db"
send-keys  -t thplugins:0 "cd $HOME/ws/trunk/head/nine-db;clear" C-m
new-window -t thplugins:1  -c "$HOME/ws/trunk/head/angle-grinder"    -n "grndr"
new-window -t thplugins:2  -c "$HOME/ws/trunk/head/rally"            -n "rally"
...
select-window -t thplugins:0


The problem is, I wind up with the current session which starts after the config file is finished, and it's sitting there. I have to exit and then tmux a to get to my sessions.

I've figured out how to move between sessions easily enough.

So I guess the killers now are:

  1. How to get my colors back?
  2. How to get rid of that hanging session?
  3. If I rerun my ~/tmuxes.conf file, I get every window in each session refreshed, except for the window 0 which is the default window. It would be nice to have it restore the window 0 of each session.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum