sesh 0.3.3 → 0.3.4
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/Session.vim +46 -45
- data/lib/sesh/cli.rb +8 -9
- data/lib/sesh/tmux_control.rb +10 -14
- data/lib/sesh/version.rb +1 -1
- data/lib/sesh.rb +1 -4
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 45fa82a9c47d0cbdeef3e2e4559be075213997bb
|
|
4
|
+
data.tar.gz: efc1cbf7895f51e8f22233159d1c9f010ce71c83
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e89fbf514e3327e0705f314511aafd0c5704f218e604f8f36d071ce97f581c079b922f958617e577e3dd12232fce642e6297b46b7600c027fb8e26fb2978e57d
|
|
7
|
+
data.tar.gz: ee54d777d081611fd467cff0bc448352b7d9a8a2286a911d86fdc563cfbbfc27c4d5f2c01abcf7666a0223412f5d8e4a6f53e4e6863af2e480b65bb02b2e1bad
|
data/Gemfile.lock
CHANGED
data/Session.vim
CHANGED
|
@@ -8,7 +8,7 @@ if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
|
|
|
8
8
|
let s:wipebuf = bufnr('%')
|
|
9
9
|
endif
|
|
10
10
|
set shortmess=aoO
|
|
11
|
-
badd +
|
|
11
|
+
badd +3 lib/sesh/version.rb
|
|
12
12
|
badd +1 ~/Sites/energy_innovation_award/index.html
|
|
13
13
|
badd +1 ~/Sites/energy_innovation_award/css/custom.css
|
|
14
14
|
badd +1 ~/Sites/energy_innovation_award/about.html
|
|
@@ -269,10 +269,10 @@ badd +7 ~/Sites/polygallery/lib/polygallery.rb
|
|
|
269
269
|
badd +12 ~/Sites/polygallery/lib/polygallery/paperclip_integration.rb
|
|
270
270
|
badd +172 lib/sesh/cli.rb
|
|
271
271
|
badd +18 lib/sesh/inferences.rb
|
|
272
|
-
badd +
|
|
272
|
+
badd +13 lib/sesh/assets/sample.yml
|
|
273
273
|
badd +74 lib/sesh/tmux_control.rb
|
|
274
274
|
badd +15 lib/sesh/ssh_control.rb
|
|
275
|
-
badd +
|
|
275
|
+
badd +1 lib/sesh.rb
|
|
276
276
|
badd +32 sesh.gemspec
|
|
277
277
|
argglobal
|
|
278
278
|
silent! argdel *
|
|
@@ -302,18 +302,18 @@ set nosplitbelow
|
|
|
302
302
|
set nosplitright
|
|
303
303
|
wincmd t
|
|
304
304
|
set winheight=1 winwidth=1
|
|
305
|
-
exe '1resize ' . ((&lines *
|
|
306
|
-
exe 'vert 1resize ' . ((&columns *
|
|
307
|
-
exe '2resize ' . ((&lines *
|
|
308
|
-
exe 'vert 2resize ' . ((&columns *
|
|
309
|
-
exe '3resize ' . ((&lines *
|
|
310
|
-
exe 'vert 3resize ' . ((&columns *
|
|
311
|
-
exe '4resize ' . ((&lines *
|
|
312
|
-
exe 'vert 4resize ' . ((&columns *
|
|
313
|
-
exe '5resize ' . ((&lines *
|
|
314
|
-
exe 'vert 5resize ' . ((&columns *
|
|
315
|
-
exe '6resize ' . ((&lines *
|
|
316
|
-
exe 'vert 6resize ' . ((&columns *
|
|
305
|
+
exe '1resize ' . ((&lines * 16 + 25) / 50)
|
|
306
|
+
exe 'vert 1resize ' . ((&columns * 72 + 73) / 146)
|
|
307
|
+
exe '2resize ' . ((&lines * 15 + 25) / 50)
|
|
308
|
+
exe 'vert 2resize ' . ((&columns * 72 + 73) / 146)
|
|
309
|
+
exe '3resize ' . ((&lines * 16 + 25) / 50)
|
|
310
|
+
exe 'vert 3resize ' . ((&columns * 73 + 73) / 146)
|
|
311
|
+
exe '4resize ' . ((&lines * 15 + 25) / 50)
|
|
312
|
+
exe 'vert 4resize ' . ((&columns * 73 + 73) / 146)
|
|
313
|
+
exe '5resize ' . ((&lines * 15 + 25) / 50)
|
|
314
|
+
exe 'vert 5resize ' . ((&columns * 73 + 73) / 146)
|
|
315
|
+
exe '6resize ' . ((&lines * 15 + 25) / 50)
|
|
316
|
+
exe 'vert 6resize ' . ((&columns * 72 + 73) / 146)
|
|
317
317
|
argglobal
|
|
318
318
|
setlocal fdm=manual
|
|
319
319
|
setlocal fde=0
|
|
@@ -324,12 +324,12 @@ setlocal fml=1
|
|
|
324
324
|
setlocal fdn=20
|
|
325
325
|
setlocal fen
|
|
326
326
|
silent! normal! zE
|
|
327
|
-
let s:l =
|
|
327
|
+
let s:l = 3 - ((1 * winheight(0) + 8) / 16)
|
|
328
328
|
if s:l < 1 | let s:l = 1 | endif
|
|
329
329
|
exe s:l
|
|
330
330
|
normal! zt
|
|
331
|
-
|
|
332
|
-
normal!
|
|
331
|
+
3
|
|
332
|
+
normal! 03|
|
|
333
333
|
wincmd w
|
|
334
334
|
argglobal
|
|
335
335
|
edit lib/sesh/tmux_control.rb
|
|
@@ -342,12 +342,12 @@ setlocal fml=1
|
|
|
342
342
|
setlocal fdn=20
|
|
343
343
|
setlocal fen
|
|
344
344
|
silent! normal! zE
|
|
345
|
-
let s:l =
|
|
345
|
+
let s:l = 113 - ((11 * winheight(0) + 7) / 15)
|
|
346
346
|
if s:l < 1 | let s:l = 1 | endif
|
|
347
347
|
exe s:l
|
|
348
348
|
normal! zt
|
|
349
|
-
|
|
350
|
-
normal!
|
|
349
|
+
113
|
|
350
|
+
normal! 018|
|
|
351
351
|
wincmd w
|
|
352
352
|
argglobal
|
|
353
353
|
edit lib/sesh/ssh_control.rb
|
|
@@ -360,12 +360,12 @@ setlocal fml=1
|
|
|
360
360
|
setlocal fdn=20
|
|
361
361
|
setlocal fen
|
|
362
362
|
silent! normal! zE
|
|
363
|
-
let s:l =
|
|
363
|
+
let s:l = 38 - ((10 * winheight(0) + 8) / 16)
|
|
364
364
|
if s:l < 1 | let s:l = 1 | endif
|
|
365
365
|
exe s:l
|
|
366
366
|
normal! zt
|
|
367
|
-
|
|
368
|
-
normal!
|
|
367
|
+
38
|
|
368
|
+
normal! 036|
|
|
369
369
|
wincmd w
|
|
370
370
|
argglobal
|
|
371
371
|
edit lib/sesh/inferences.rb
|
|
@@ -378,12 +378,12 @@ setlocal fml=1
|
|
|
378
378
|
setlocal fdn=20
|
|
379
379
|
setlocal fen
|
|
380
380
|
silent! normal! zE
|
|
381
|
-
let s:l =
|
|
381
|
+
let s:l = 22 - ((9 * winheight(0) + 7) / 15)
|
|
382
382
|
if s:l < 1 | let s:l = 1 | endif
|
|
383
383
|
exe s:l
|
|
384
384
|
normal! zt
|
|
385
|
-
|
|
386
|
-
normal!
|
|
385
|
+
22
|
|
386
|
+
normal! 068|
|
|
387
387
|
wincmd w
|
|
388
388
|
argglobal
|
|
389
389
|
edit lib/sesh.rb
|
|
@@ -396,12 +396,12 @@ setlocal fml=1
|
|
|
396
396
|
setlocal fdn=20
|
|
397
397
|
setlocal fen
|
|
398
398
|
silent! normal! zE
|
|
399
|
-
let s:l =
|
|
399
|
+
let s:l = 41 - ((11 * winheight(0) + 7) / 15)
|
|
400
400
|
if s:l < 1 | let s:l = 1 | endif
|
|
401
401
|
exe s:l
|
|
402
402
|
normal! zt
|
|
403
|
-
|
|
404
|
-
normal!
|
|
403
|
+
41
|
|
404
|
+
normal! 023|
|
|
405
405
|
wincmd w
|
|
406
406
|
argglobal
|
|
407
407
|
edit lib/sesh/cli.rb
|
|
@@ -414,25 +414,26 @@ setlocal fml=1
|
|
|
414
414
|
setlocal fdn=20
|
|
415
415
|
setlocal fen
|
|
416
416
|
silent! normal! zE
|
|
417
|
-
let s:l =
|
|
417
|
+
let s:l = 210 - ((1 * winheight(0) + 7) / 15)
|
|
418
418
|
if s:l < 1 | let s:l = 1 | endif
|
|
419
419
|
exe s:l
|
|
420
420
|
normal! zt
|
|
421
|
-
|
|
422
|
-
normal!
|
|
421
|
+
210
|
|
422
|
+
normal! 032|
|
|
423
423
|
wincmd w
|
|
424
|
-
|
|
425
|
-
exe '
|
|
426
|
-
exe '
|
|
427
|
-
exe '
|
|
428
|
-
exe '
|
|
429
|
-
exe '
|
|
430
|
-
exe '
|
|
431
|
-
exe '
|
|
432
|
-
exe '
|
|
433
|
-
exe '
|
|
434
|
-
exe '
|
|
435
|
-
exe '
|
|
424
|
+
2wincmd w
|
|
425
|
+
exe '1resize ' . ((&lines * 16 + 25) / 50)
|
|
426
|
+
exe 'vert 1resize ' . ((&columns * 72 + 73) / 146)
|
|
427
|
+
exe '2resize ' . ((&lines * 15 + 25) / 50)
|
|
428
|
+
exe 'vert 2resize ' . ((&columns * 72 + 73) / 146)
|
|
429
|
+
exe '3resize ' . ((&lines * 16 + 25) / 50)
|
|
430
|
+
exe 'vert 3resize ' . ((&columns * 73 + 73) / 146)
|
|
431
|
+
exe '4resize ' . ((&lines * 15 + 25) / 50)
|
|
432
|
+
exe 'vert 4resize ' . ((&columns * 73 + 73) / 146)
|
|
433
|
+
exe '5resize ' . ((&lines * 15 + 25) / 50)
|
|
434
|
+
exe 'vert 5resize ' . ((&columns * 73 + 73) / 146)
|
|
435
|
+
exe '6resize ' . ((&lines * 15 + 25) / 50)
|
|
436
|
+
exe 'vert 6resize ' . ((&columns * 72 + 73) / 146)
|
|
436
437
|
tabnext 1
|
|
437
438
|
if exists('s:wipebuf')
|
|
438
439
|
silent exe 'bwipe ' . s:wipebuf
|
data/lib/sesh/cli.rb
CHANGED
|
@@ -68,11 +68,11 @@ module Sesh
|
|
|
68
68
|
parsed_options[:ssh][:remote_addr] = v }
|
|
69
69
|
|
|
70
70
|
# Tmux options
|
|
71
|
-
opts.on('-S', '--tmux-socket-file=path', 'Path to Tmux Socket File') {|v|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
opts.on('--tmux-pids-file=path', 'Path to Tmux Pids File') {|v|
|
|
75
|
-
|
|
71
|
+
# opts.on('-S', '--tmux-socket-file=path', 'Path to Tmux Socket File') {|v|
|
|
72
|
+
# # fatal("Socket file #{v} does not exist.") unless File.exist?(v)
|
|
73
|
+
# parsed_options[:tmux][:socket_file] = v }
|
|
74
|
+
# opts.on('--tmux-pids-file=path', 'Path to Tmux Pids File') {|v|
|
|
75
|
+
# parsed_options[:tmux][:pids_file] = v }
|
|
76
76
|
|
|
77
77
|
# Shell options for remote commands
|
|
78
78
|
opts.on('-C', '--shell-command=cmd', 'Shell Command to Execute') {|v|
|
|
@@ -139,8 +139,8 @@ module Sesh
|
|
|
139
139
|
@options[:template] ||= File.join(
|
|
140
140
|
File.dirname(File.expand_path(__FILE__)), 'assets', 'sample.yml' )
|
|
141
141
|
end
|
|
142
|
-
@options[:tmux][:socket_file] ||= "/tmp/#{@options[:project]}.sock"
|
|
143
|
-
@options[:tmux][:pids_file] ||= "/tmp/#{@options[:project]}.pids.txt"
|
|
142
|
+
# @options[:tmux][:socket_file] ||= "/tmp/#{@options[:project]}.sock"
|
|
143
|
+
# @options[:tmux][:pids_file] ||= "/tmp/#{@options[:project]}.pids.txt"
|
|
144
144
|
if %w(enslave connect).include? @command
|
|
145
145
|
@options[:ssh][:local_addr] ||= Sesh::Inferences.infer_local_ssh_addr
|
|
146
146
|
if @options[:ssh][:remote_addr].nil? && ARGV.any?
|
|
@@ -205,8 +205,7 @@ module Sesh
|
|
|
205
205
|
Logger.success "#{pcount} project#{pcount>1 ? 's':''} currently running:"
|
|
206
206
|
running_projects.each do |rp|
|
|
207
207
|
puts; Logger.info "Project: #{rp}", 1
|
|
208
|
-
|
|
209
|
-
tc = TmuxControl.new rp, socket_file: "/tmp/#{rp}.sock"
|
|
208
|
+
tc = TmuxControl.new rp
|
|
210
209
|
tc_clients = tc.connected_client_devices
|
|
211
210
|
if tc_clients.any?
|
|
212
211
|
Logger.success "Connected Client Devices:", 2
|
data/lib/sesh/tmux_control.rb
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
require 'sesh'
|
|
2
|
+
# require 'tmuxinator'
|
|
3
|
+
# require 'yaml'
|
|
2
4
|
|
|
3
5
|
module Sesh
|
|
4
6
|
class TmuxControl
|
|
5
7
|
def initialize(project, options={})
|
|
6
8
|
@project = project || Inferences::infer_project_from_current_directory
|
|
7
|
-
@options = {}.merge(DEFAULT_OPTIONS[:tmux]).merge
|
|
8
|
-
@socket_file = @options[:socket_file]
|
|
9
|
+
@options = {}.merge(DEFAULT_OPTIONS[:tmux]).merge options
|
|
10
|
+
@socket_file = @options[:socket_file] || "/tmp/#{@project}.sock"
|
|
9
11
|
end
|
|
10
12
|
|
|
11
13
|
def self.get_running_projects
|
|
12
|
-
# TODO: handle custom socket paths
|
|
13
14
|
output = Sesh.format_and_run_command <<-BASH
|
|
14
15
|
ps aux | grep tmux | grep "sesh begin" | grep -v "[g]rep" \
|
|
15
16
|
| sed -e "s/.*\\/tmp\\/\\(.*\\)\\.sock.*/\\1/"
|
|
16
17
|
BASH
|
|
17
|
-
output.lines
|
|
18
|
+
output.lines.map(&:strip)
|
|
18
19
|
end
|
|
19
20
|
def already_running?; self.class.get_running_projects.include? @project end
|
|
20
21
|
# `ps aux | grep "#{project_name_matcher}"`.strip.length > 0 end
|
|
@@ -60,10 +61,6 @@ module Sesh
|
|
|
60
61
|
output += output.map{|cpid| obtain_child_pids_from_pid(cpid) - [pid] }.flatten
|
|
61
62
|
output.reverse
|
|
62
63
|
end
|
|
63
|
-
def store_pids_from_session!
|
|
64
|
-
File.open(@options[:pids_file], 'w') {|f|
|
|
65
|
-
obtain_pids_from_session.each{|pid| f.puts pid } }
|
|
66
|
-
end
|
|
67
64
|
|
|
68
65
|
def kill_running_processes
|
|
69
66
|
pane_count = `tmux list-panes -s -F "\#{pane_pid} \#{pane_current_command}" -t "#{@project}" 2>/dev/null`.strip.lines.count
|
|
@@ -89,7 +86,6 @@ module Sesh
|
|
|
89
86
|
if issue_start_command! && Logger.show_progress_until(-> { already_running? })
|
|
90
87
|
sleep 1
|
|
91
88
|
if already_running?
|
|
92
|
-
store_pids_from_session!
|
|
93
89
|
Logger.success 'Sesh started successfully.'
|
|
94
90
|
puts
|
|
95
91
|
else Logger.fatal 'Sesh failed to start!' end
|
|
@@ -108,7 +104,7 @@ module Sesh
|
|
|
108
104
|
def restart_project!; stop_project!; sleep 0.5; start_project! end
|
|
109
105
|
|
|
110
106
|
def connected_client_devices
|
|
111
|
-
`tmux -S "#{@socket_file}" list-clients | cut -d : -f 1 | cut -d / -f 3`.strip.lines.map(&:strip)
|
|
107
|
+
`tmux -S "#{@socket_file}" list-clients 2>/dev/null | cut -d : -f 1 | cut -d / -f 3`.strip.lines.map(&:strip)
|
|
112
108
|
end
|
|
113
109
|
def get_ip_from_device(devname)
|
|
114
110
|
ip_line = `who -a 2> /dev/null | grep " #{devname} "`.strip
|
|
@@ -117,9 +113,9 @@ module Sesh
|
|
|
117
113
|
end
|
|
118
114
|
def get_device_from_ip(ip)
|
|
119
115
|
return if ( connected_devs = connected_client_devices ).length == 0
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
116
|
+
return connected_devs.find{|d| get_ip_from_device(ip) == ip } if ip == '127.0.0.1'
|
|
117
|
+
who_lines = `who -a 2> /dev/null | grep "#{ Regexp.escape("(#{ip})") }"`.strip.lines
|
|
118
|
+
puts connected_devs.inspect
|
|
123
119
|
return if who_lines.length == 0
|
|
124
120
|
connected_devs.find{|d| who_lines.find{|l| l =~ / #{d} / } }
|
|
125
121
|
end
|
|
@@ -145,7 +141,7 @@ module Sesh
|
|
|
145
141
|
resolved_ip = ping_output[1].split(' from ')[1].split(': ')[0]
|
|
146
142
|
disconnect_client_by_ip! resolved_ip
|
|
147
143
|
else
|
|
148
|
-
puts ping_output
|
|
144
|
+
puts "Ping output: #{ping_output}"
|
|
149
145
|
end
|
|
150
146
|
else
|
|
151
147
|
ssh_identifier =
|
data/lib/sesh/version.rb
CHANGED
data/lib/sesh.rb
CHANGED