Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option "tmux_detached" for detach client #284

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/tmuxinator/assets/sample.yml
Expand Up @@ -21,6 +21,9 @@ root: ~/
# Specifies (by name or index) which window will be selected on project startup. If not set, the first window is used.
# startup_window: logs

# for option to start detached
# tmux_detached: true

windows:
- editor:
layout: main-vertical
Expand Down
2 changes: 2 additions & 0 deletions lib/tmuxinator/assets/template.erb
Expand Up @@ -60,8 +60,10 @@ if [ "$?" -eq 1 ]; then
<%= tmux %> select-window -t <%= startup_window %>
fi

<% unless detached? %>
if [ -z "$TMUX" ]; then
<%= tmux %> -u attach-session -t <%= name %>
else
<%= tmux %> -u switch-client -t <%= name %>
fi
<%- end -%>
4 changes: 4 additions & 0 deletions lib/tmuxinator/project.rb
Expand Up @@ -43,6 +43,10 @@ def pre
end
end

def detached?
yaml["tmux_detached"]
end

def pre_window
if rbenv?
"rbenv shell #{yaml["rbenv"]}"
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/sample.yml
Expand Up @@ -7,6 +7,7 @@ socket_name: foo # Remove to use default socket
pre: sudo /etc/rc.d/mysqld start # Runs before everything
pre_window: rbenv shell 2.0.0-p247 # Runs in each tab and pane
tmux_options: -f ~/.tmux.mac.conf # Pass arguments to tmux
tmux_detached: false
windows:
- editor:
pre:
Expand Down
25 changes: 25 additions & 0 deletions spec/lib/tmuxinator/project_spec.rb
Expand Up @@ -328,4 +328,29 @@
end
end
end

describe "#detached?" do
subject(:detached) { project.detached? }

context "tmux_detached is true in yaml" do
before { project.yaml["tmux_detached"] = true }

it "returns true" do
expect(detached).to be_truthy
end
end

context "tmux_detached is not defined in yaml" do
it "returns false" do
expect(detached).to be_falsey
end
end

context "tmux_detached is false in yaml" do
it "returns false" do
expect(detached).to be_falsey
end
end

end
end