rtmux 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/rtmux +20 -18
  3. data/lib/rtmux.rb +14 -6
  4. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a332f0ab076b868caeba90ccd342daad183a728
4
- data.tar.gz: e04290ecbd85ddff1b415fcc02cc020e8ca246ac
3
+ metadata.gz: 19e937ca015c569ee18267d86b232c463ca92ee8
4
+ data.tar.gz: 0b76e33d35ca8d0cb142c83b7ce1e5d33d5a7011
5
5
  SHA512:
6
- metadata.gz: 91ad374d37ebf97e6e4d517f335ea4dd5bf49d505f01389dca47a2300031da0e80e8625a6cf399c055f6aa12f9b5357b64a7a752989735fc96cbcba061d81b2d
7
- data.tar.gz: 115c596e9af48535b3c3987e8619145c694dd4d39771c168df02f19a7fe341f7a33701525b964155bdb0bb706ae4c22c0c70e1636ddf51a8696e3cce5888dd0f
6
+ metadata.gz: a92540ba3dd8af19ff56d0f62b848dff937b9e23fdfbf7766b29f5e85af75a9ca3c48a25530085d758c4b32294341bf38aab1a43c4aa34055f915b5cd8b3c49c
7
+ data.tar.gz: 9031884f5fafbdaa40b82cff26935c2d6e41f829abecd5b4b3cfa35acfc9049f8c961b2687779a27d010de3c2d440a6d65041ce6c2c0d6f9016cb007438bd999
data/bin/rtmux CHANGED
@@ -6,7 +6,7 @@
6
6
  # excutable for rtmux.rb
7
7
  #
8
8
  # created on : 2013.08.12
9
- # last update: 2013.08.13
9
+ # last update: 2013.10.16
10
10
  #
11
11
  # by meinside@gmail.com
12
12
 
@@ -15,16 +15,17 @@ require "thor"
15
15
 
16
16
  require "rtmux"
17
17
 
18
+ # rtmux module
18
19
  module RTmux
19
20
 
20
- CONFIG_FILEPATH = File.expand_path("~/.rtmux.conf")
21
+ CONFIG_FILEPATH = File.expand_path(File.join("~", ".rtmux.conf"))
21
22
 
22
23
  # predefined variables:
23
24
  # %d: current directory(where this script is run)'s name
24
25
  # %h: host name
25
- # %Y: year (eg. 2012)
26
- # %M: month (eg. 11)
27
- # %D: day (eg. 22)
26
+ # %Y: year (eg. 2013)
27
+ # %M: month (eg. 10)
28
+ # %D: day (eg. 16)
28
29
  RTMUX_CONFIG_EXAMPLE = <<EXAMPLE
29
30
  ---
30
31
  rails: # for rails projects
@@ -57,7 +58,7 @@ EXAMPLE
57
58
  # @param txt [String] text
58
59
  # @return [String] replaced text
59
60
  def self.replace(txt)
60
- unless txt
61
+ if !txt
61
62
  nil
62
63
  else
63
64
  txt
@@ -83,6 +84,7 @@ EXAMPLE
83
84
  return nil
84
85
  end
85
86
 
87
+ # executable class
86
88
  class Exec < Thor
87
89
  desc "launch [SESSION]", "Starts/resumes a session with given SESSION name"
88
90
  long_desc <<LAUNCH_DESC
@@ -112,27 +114,27 @@ LAUNCH_DESC
112
114
  # read config
113
115
  if File.exists? CONFIG_FILEPATH
114
116
  puts "> Loading config file: #{CONFIG_FILEPATH}" if verbose
115
- configs = RTmux::parse_config(CONFIG_FILEPATH) || {}
117
+ configs = RTmux.parse_config(CONFIG_FILEPATH) || {}
116
118
  else
117
119
  puts "> Loading sample config" if verbose
118
- configs = RTmux::parse_config(RTMUX_CONFIG_EXAMPLE) || {}
120
+ configs = RTmux.parse_config(RTMUX_CONFIG_EXAMPLE) || {}
119
121
  end
120
122
  config = configs[session] || {}
121
123
 
122
124
  # create/resume session
123
- RTmux::TmuxHelper.new(RTmux::replace(config["session_name"]) || session){|tmux|
125
+ RTmux::TmuxHelper.new(RTmux.replace(config["session_name"]) || session){|tmux|
124
126
  unless tmux.session_created?
125
127
  # create, split windows and run commands in them
126
- if windows = config["windows"]
128
+ if (windows = config["windows"])
127
129
  windows.each{|window|
128
- window_name = RTmux::replace(window["name"])
129
- tmux.create_window(window_name, cmd: RTmux::replace(window["cmd"]))
130
+ window_name = RTmux.replace(window["name"])
131
+ tmux.create_window(window_name, cmd: RTmux.replace(window["cmd"]))
130
132
 
131
- if split = window["split"]
133
+ if (split = window["split"])
132
134
  tmux.split(window_name, vertical: split["vertical"], percentage: split["percentage"])
133
- if panes = split["panes"]
135
+ if (panes = split["panes"])
134
136
  panes.each{|pane|
135
- tmux.cmd(RTmux::replace(pane["cmd"]), window_name, pane: pane["pane"])
137
+ tmux.cmd(RTmux.replace(pane["cmd"]), window_name, pane: pane["pane"])
136
138
  }
137
139
  end
138
140
  end
@@ -142,8 +144,8 @@ LAUNCH_DESC
142
144
  end
143
145
 
144
146
  # focus on window
145
- if focus = config["focus"]
146
- tmux.focus(RTmux::replace(focus["name"]), pane: focus["pane"])
147
+ if (focus = config["focus"])
148
+ tmux.focus(RTmux.replace(focus["name"]), pane: focus["pane"])
147
149
  end
148
150
  end
149
151
 
@@ -175,5 +177,5 @@ LAUNCH_DESC
175
177
  end
176
178
  end
177
179
 
178
- RTmux::Exec::start(ARGV)
180
+ RTmux::Exec.start(ARGV)
179
181
 
@@ -6,10 +6,11 @@
6
6
  # help create/resume tmux sessions
7
7
  #
8
8
  # created on : 2012.11.22
9
- # last update: 2013.08.13
9
+ # last update: 2013.10.16
10
10
  #
11
11
  # by meinside@gmail.com
12
12
 
13
+ # rtmux module
13
14
  module RTmux
14
15
 
15
16
  =begin
@@ -31,13 +32,20 @@ module RTmux
31
32
  =end
32
33
  class TmuxHelper
33
34
  # initializer
34
- # @param session_name [String] session name
35
+ # @param session_name [String] session name (default: hostname)
35
36
  def initialize(session_name, &block)
37
+ # check if tmux is installed or not
38
+ if `which tmux`.empty?
39
+ puts "* tmux is not installed on this machine"
40
+ puts "> brew install tmux"
41
+ puts "or"
42
+ puts "> sudo apt-get install tmux"
43
+ exit 1
44
+ end
45
+
36
46
  @session_name = session_name || `hostname`.strip
37
47
 
38
- if block_given?
39
- yield self
40
- end
48
+ yield self if block_given?
41
49
  end
42
50
 
43
51
  # check if session is already created or not
@@ -59,7 +67,7 @@ module RTmux
59
67
  # @param options [Hash] options
60
68
  def create_window(name = nil, options = {cmd: nil})
61
69
  if session_created?
62
- unless window_created?(name)
70
+ if !window_created?(name)
63
71
  `tmux new-window -t #{@session_name} #{name.nil? ? "" : "-n #{name}"}`
64
72
  else
65
73
  return # don't create duplicated windows
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rtmux
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sungjin Han
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-13 00:00:00.000000000 Z
11
+ date: 2013-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  description: help create/resume tmux sessions
@@ -43,12 +43,12 @@ require_paths:
43
43
  - lib
44
44
  required_ruby_version: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - '>='
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  required_rubygems_version: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - '>='
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  requirements: []