don't explode if you aren't in a tmux session

This commit is contained in:
Joshua Antonishen 2012-04-15 02:07:03 -04:00
parent 62ded6f281
commit de99c54046

View File

@ -190,11 +190,15 @@ end
class CurrentTmuxSession < TmuxSession
def initialize
session = self.get_session
window = self.get_property(:active, :window)
pane = self.get_property(:active, :pane)
if tmux?
session = self.get_session
window = self.get_property(:active, :window)
pane = self.get_property(:active, :pane)
super(session, window, pane)
super(session, window, pane)
else
raise "You are not in a tmux session"
end
end
def get_property(match, type)
@ -206,5 +210,9 @@ class CurrentTmuxSession < TmuxSession
def get_session
_run("display -p '#S'").strip
end
def tmux?
`echo $TMUX` =~ /.+/ ? true : false
end
end
EOF