Class: Tmux::Commands

Inherits:
Object
  • Object
show all
Defined in:
app/tmux/commands.rb

Instance Method Summary collapse

Constructor Details

#initialize(executable = nil) ⇒ Commands

Returns a new instance of Commands.



3
4
5
# File 'app/tmux/commands.rb', line 3

def initialize(executable=nil)
  @executable ||= `which tmux`.chomp
end

Instance Method Details

#attach_to(id) ⇒ Object



17
18
19
# File 'app/tmux/commands.rb', line 17

def attach_to(id)
  system("#{@executable} attach -t #{id}")
end

#in_tmux?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'app/tmux/commands.rb', line 25

def in_tmux?
  ENV.has_key?('TMUX')
end

#new_session(id) ⇒ Object



21
22
23
# File 'app/tmux/commands.rb', line 21

def new_session(id)
  system("#{@executable} new-session -s #{id}")
end

#sessionsObject



7
8
9
10
11
12
13
14
15
# File 'app/tmux/commands.rb', line 7

def sessions
  strings = `#{@executable} list-sessions`.split("\n")

  if strings.nil? || (strings.count == 1 && empty_session?(strings.first))
    return []
  end

  strings.map { |str| Selections::Session.new(str) }
end