text_tunnel 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,11 +14,23 @@ where [options] are:
14
14
  EOS
15
15
 
16
16
  opt :port, "Port", :type => :int, :default => 1777
17
+ opt :fallback_editor, "Fallback editor if error connecting to text_tunneld web server", :default => "vi"
17
18
  end
18
19
 
19
20
  Trollop.die "text_tunnel requires exactly one filename argument" unless ARGV.size == 1
20
21
  file_path = ARGV[0]
21
22
 
23
+ # Ensure that we will receive the interrupt (crtl+c) signal. When text_tunnel
24
+ # is launched by crontab -e it blocks or ignores the INT signal. This restores
25
+ # default functionality.
26
+ Signal.trap "INT", "DEFAULT"
27
+
28
+ def try_fallback_editor(fallback_editor, file_path)
29
+ puts "Attempting fallback editor: #{fallback_editor} #{file_path}"
30
+ success = system fallback_editor, file_path
31
+ puts "ERROR: Fallback editor failed." unless success
32
+ end
33
+
22
34
  require "text_tunnel/client"
23
35
  begin
24
36
  client = Client.new(config[:port], file_path)
@@ -33,6 +45,7 @@ begin
33
45
  end
34
46
  rescue Errno::ECONNREFUSED => e
35
47
  puts "ERROR: Unable to connect to text_tunneld web server."
48
+ try_fallback_editor config[:fallback_editor], file_path
36
49
  rescue Errno::EISDIR
37
50
  puts "ERROR: #{file_path} is a directory."
38
51
  rescue Errno::EACCES
@@ -42,6 +55,7 @@ rescue RestClient::Exception, UnexpectedResponseError => e
42
55
  puts "HTTP Status Code: #{e.http_code}"
43
56
  puts "HTTP Body:"
44
57
  puts e.http_body
58
+ try_fallback_editor config[:fallback_editor], file_path
45
59
  rescue Interrupt
46
60
  puts "Exiting..."
47
61
  ensure
@@ -1,3 +1,3 @@
1
1
  module TextTunnel
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
data/readme.md CHANGED
@@ -28,11 +28,11 @@ variable set you will need to include an --editor option.
28
28
  Connect to the remote host with SSH and specify a reverse port forward (the
29
29
  default port for Text Tunnel is 1777).
30
30
 
31
- ssh -R 1777:localhost:1777 remote-host
31
+ ssh -R 1777:localhost:1777 remote-host
32
32
 
33
33
  On the remote machine use text_tunnel as your editor.
34
34
 
35
- text_tunnel /path/to/file
35
+ text_tunnel /path/to/file
36
36
 
37
37
  The file should open on your local machine. Do your edits and save your file.
38
38
  It will automatically be transferred to the remote host. When you are done hit
@@ -43,14 +43,32 @@ Crtl+C on the remote host to terminate Text Tunnel.
43
43
  The reverse port forward can be configured in ~/.ssh/config to avoid having to
44
44
  retype the reverse port forward on the command line every time.
45
45
 
46
+ RemoteForward 127.0.0.1:1777 127.0.0.1:1777
47
+
46
48
  Consider setting text_tunnel as your EDITOR environment variable on your
47
49
  remote hosts. This will let you use a local text editor for git commit
48
- messages, crontabs, etc.
50
+ messages, crontabs, etc. If the text_tunneld server is unavailable it will
51
+ seamlessly fall back to vi. You can use the --fallback-editor option to
52
+ configure the fallback console editor.
53
+
54
+ export EDITOR='/usr/local/bin/text_tunnel --fallback-editor=nano'
55
+
56
+ text_tunneld supports a background daemon mode. Run text_tunneld -h for full
57
+ options. You may want to configure it to run automatically when you log in to
58
+ your desktop environment. Sadly, the exact means of doing this vary across
59
+ platforms. On Ubuntu 12.04 with the Gnome Classic desktop environment you can
60
+ configure a program to autostart in Applications -> System Tools ->
61
+ Preferences -> Startup Applications. The following command would start
62
+ text_tunneld in background mode with the "subl" editor.
49
63
 
50
- text_tunneld supports a background daemon mode. Run text_tunneld -h for full options.
64
+ text_tunneld --editor subl --daemon
51
65
 
52
66
  ## Version History
53
67
 
68
+ * **0.2.0**
69
+ * Unblock INT signal for bin/text_tunnel. This allows usage with crontab -e.
70
+ * Fall back to local editor if text_tunneld server is unreachable.
71
+ * Added information to readme about autostarting on desktop login.
54
72
  * **0.1.1**
55
73
  * Add compatibility with older patch versions of Ruby 1.9.2.
56
74
  * **0.1.0**
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: text_tunnel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-23 00:00:00.000000000 Z
12
+ date: 2012-08-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client