lida 0.0.2 → 0.0.3
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/README.md +3 -3
- data/bin/lida +27 -13
- data/lida.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e22eb2528939524d714b032a9b16af31c27bfea3ec313793a588ec6f6aee2fe7
|
4
|
+
data.tar.gz: 8a5d92f8ac40cf91e45c7de4540509c7d88573254353c9fa3122b5cced6b6535
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bb342020c1a9fa053e28e9b6c4aeda8d54c7cdfc9dcd877244a8540f1a580ed292d57b258e438045be394e1270f619e66cf1b80eb32dfbcfccaff12042cc39f
|
7
|
+
data.tar.gz: 4ba1611f68d32544e88642743d1b9e37180aa8c18fa6dd06fc7cffaaacce12059bdc5560afa14c4f7de962b2ac5c2ebbf1b6daab740aba598ff56a989d3c2339
|
data/README.md
CHANGED
@@ -8,15 +8,15 @@
|
|
8
8
|
# Open working directory of current terminal in finder
|
9
9
|
lida
|
10
10
|
|
11
|
-
# Open current finder
|
11
|
+
# Open current working directory of finder in a new tab of current terminal
|
12
12
|
lida finder
|
13
13
|
lida f
|
14
14
|
|
15
|
-
# Open current xcode
|
15
|
+
# Open current working directory of xcode in a new tab of current terminal
|
16
16
|
lida xcode
|
17
17
|
lida x
|
18
18
|
|
19
|
-
#
|
19
|
+
# Open current working directory of xcode-beta in a new tab of current terminal
|
20
20
|
lida xcodebeta
|
21
21
|
lida xb
|
22
22
|
```
|
data/bin/lida
CHANGED
@@ -3,12 +3,13 @@
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'commander/import'
|
5
5
|
require 'applescript'
|
6
|
+
require 'uri'
|
6
7
|
require 'rainbow/refinement'
|
7
8
|
using Rainbow
|
8
9
|
|
9
10
|
program :name, 'Lida'
|
10
|
-
program :version, '0.0.
|
11
|
-
program :description, '
|
11
|
+
program :version, '0.0.3'
|
12
|
+
program :description, '🍰 Open current finder/xcode dir in terminal/iterm and vice versa, easy as cake!'
|
12
13
|
program :help, 'Author', 'Quentin Jin <jianstm@gmail.com>'
|
13
14
|
|
14
15
|
# Terminal to finder
|
@@ -28,7 +29,7 @@ command :xcode do |c|
|
|
28
29
|
begin
|
29
30
|
path = get_current_path_of_xcode 'Xcode'
|
30
31
|
rescue
|
31
|
-
|
32
|
+
puts_error 'No active window on xcode.'
|
32
33
|
end
|
33
34
|
|
34
35
|
open_path path if path
|
@@ -38,12 +39,12 @@ end
|
|
38
39
|
# Xcode-beta to terminal
|
39
40
|
command :xcodebeta do |c|
|
40
41
|
c.syntax = 'lida xcodebeta'
|
41
|
-
c.description = 'Open current xcode dir in a new tab of current terminal'
|
42
|
+
c.description = 'Open current xcode-beta dir in a new tab of current terminal'
|
42
43
|
c.action do
|
43
44
|
begin
|
44
45
|
path = get_current_path_of_xcode 'Xcode-beta'
|
45
46
|
rescue
|
46
|
-
|
47
|
+
puts_error 'No active window on xcode-beta.'
|
47
48
|
end
|
48
49
|
|
49
50
|
open_path path if path
|
@@ -58,7 +59,7 @@ command :finder do |c|
|
|
58
59
|
begin
|
59
60
|
path = get_current_path_of_finder
|
60
61
|
rescue
|
61
|
-
|
62
|
+
puts_error 'No active window on Finder.'
|
62
63
|
end
|
63
64
|
open_path path if path
|
64
65
|
end
|
@@ -122,23 +123,28 @@ def open_path(path)
|
|
122
123
|
elsif flag == 1
|
123
124
|
open_path_in_iterm path
|
124
125
|
else
|
125
|
-
|
126
|
+
puts_error 'Lida only supports iterm and terminal for now.'
|
126
127
|
end
|
127
128
|
end
|
128
129
|
|
129
|
-
def open_path_in_iterm(
|
130
|
+
def open_path_in_iterm(dir)
|
130
131
|
script = <<~EOS
|
131
|
-
set
|
132
|
+
set dir to (quoted form of POSIX path of ("#{dir}"))
|
133
|
+
set command to "clear; cd " & dir
|
132
134
|
tell application "iTerm"
|
133
135
|
select first window
|
134
136
|
tell the first window
|
135
137
|
create tab with default profile
|
136
|
-
tell current session to write text "clear"
|
137
138
|
tell current session to write text command
|
138
139
|
end tell
|
139
140
|
end tell
|
140
141
|
EOS
|
141
|
-
|
142
|
+
|
143
|
+
begin
|
144
|
+
AppleScript.execute(script)
|
145
|
+
rescue
|
146
|
+
puts_error 'Open path in iterm failed.'
|
147
|
+
end
|
142
148
|
end
|
143
149
|
|
144
150
|
def open_path_in_terminal(path)
|
@@ -148,10 +154,18 @@ def open_path_in_terminal(path)
|
|
148
154
|
tell application "System Events" to keystroke "t" using command down
|
149
155
|
delay 1
|
150
156
|
do script ("clear") in first window
|
151
|
-
do script ("cd #{path}") in first window
|
157
|
+
do script ("cd '#{path}'") in first window
|
152
158
|
end tell
|
153
159
|
EOS
|
154
|
-
|
160
|
+
begin
|
161
|
+
AppleScript.execute(script)
|
162
|
+
rescue
|
163
|
+
puts_error 'Open path in terminal failed.'
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def puts_error(msg)
|
168
|
+
puts '[lida]: ' + msg.red
|
155
169
|
end
|
156
170
|
|
157
171
|
class NoWindowError < StandardError
|
data/lida.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lida
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Quentin Jin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|