Class: Tmux::Commands
- Inherits:
-
Object
- Object
- Tmux::Commands
- Defined in:
- app/tmux/commands.rb
Instance Method Summary collapse
- #attach_to(id) ⇒ Object
- #in_tmux? ⇒ Boolean
-
#initialize(executable = nil) ⇒ Commands
constructor
A new instance of Commands.
- #new_session(id) ⇒ Object
- #sessions ⇒ Object
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
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 |
#sessions ⇒ Object
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 |