am 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/am/version.rb +1 -1
- data/lib/tail.rb +8 -6
- 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: dd20e052e21e26b87aa4b9cc4c57a05a8583a7a3
|
4
|
+
data.tar.gz: f81a14e5fa2d91ce26a86689ffece48b32a97741
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99d393b3714778abb145fe43b99c52cf951cf84a40f3f047cdd062cd650d54ef1d0bbe4649a8dfaf6ce00059cfd44ec22a36887c1c4d9c171a3de6016d674c44
|
7
|
+
data.tar.gz: e3dc3b99aefce5967a19594fe332eda737c9e46c4e4a6302d45d9bf176adaf06815b4d8bddf0207dd33b68d8417aa761eef8f8e1d6a18de777d41160bee3ea3a
|
data/lib/am/version.rb
CHANGED
data/lib/tail.rb
CHANGED
@@ -9,10 +9,12 @@ module AM
|
|
9
9
|
def get_history_file
|
10
10
|
shell = `echo $SHELL`
|
11
11
|
if shell =~ /zsh/
|
12
|
-
@history_pattern = '.*;(.*)
|
12
|
+
@history_pattern = '.*;(.*)'
|
13
|
+
@command_col = 1
|
13
14
|
return File.expand_path('~/.zsh_history')
|
14
15
|
elsif shell =~ /bash/
|
15
|
-
@history_pattern = '(.*)'
|
16
|
+
@history_pattern = '(.*)\n'
|
17
|
+
@command_col = 0
|
16
18
|
return File.expand_path('~/.bash_history')
|
17
19
|
else
|
18
20
|
puts "does not support is #{shell}"
|
@@ -23,10 +25,10 @@ module AM
|
|
23
25
|
exit if @sh_history_file.nil?
|
24
26
|
|
25
27
|
commands = []
|
26
|
-
last_commands = `tail -6 #{@sh_history_file} | head -5
|
28
|
+
last_commands = `tail -6 #{@sh_history_file} | head -5`.split("\n")
|
27
29
|
last_commands.each_with_index do |c,i|
|
28
|
-
record = c.split(/#{@history_pattern}/)[
|
29
|
-
puts (i+1).to_s + ': ' + record
|
30
|
+
record = c.split(/#{@history_pattern}/)[@command_col].strip
|
31
|
+
puts (i+1).to_s + ': ' + record.to_s
|
30
32
|
commands << record
|
31
33
|
end
|
32
34
|
commands
|
@@ -34,7 +36,7 @@ module AM
|
|
34
36
|
|
35
37
|
def get_last_command
|
36
38
|
exit if @sh_history_file.nil?
|
37
|
-
`tail -2 #{@sh_history_file} | head -1`.split(/#{@history_pattern}/)[
|
39
|
+
`tail -2 #{@sh_history_file} | head -1`.split(/#{@history_pattern}/)[@command_col].strip
|
38
40
|
end
|
39
41
|
|
40
42
|
end
|