am 0.0.5 → 0.0.6
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/lib/am/version.rb +1 -1
- data/lib/tail.rb +10 -10
- 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: 6f536428a276df0fd09ec9937e8a5a32995c4e8b
|
4
|
+
data.tar.gz: dc5e19ae44f8d6957b67a9f138eb5edd86de37b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 043ad037b3a430e61d3dca3e0dccaaac7019acf0ed714bfc469c33b793a7f3e655e32560db22d2528e27a956fce57e31f2a3d4c6c8ac5f1ec96be3c380d8c791
|
7
|
+
data.tar.gz: b1d21f7a283e740fc9cbe37aa834999fdea81b670b6b1a4a550db8817893256d77e069a9aa0ddf402ab52be69f76eddf8a12bd71df4d7c0540d4ca27b02f9d85
|
data/lib/am/version.rb
CHANGED
data/lib/tail.rb
CHANGED
@@ -3,19 +3,19 @@ require 'am'
|
|
3
3
|
module AM
|
4
4
|
class Tail
|
5
5
|
def initialize(*args)
|
6
|
-
|
6
|
+
set_profile
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
9
|
+
def set_profile
|
10
10
|
shell = `echo $SHELL`
|
11
11
|
if shell =~ /zsh/
|
12
12
|
@history_pattern = '.*;(.*)'
|
13
|
-
@
|
14
|
-
|
13
|
+
@sh_history_file = File.expand_path('~/.zsh_history')
|
14
|
+
@tail_margin = 0
|
15
15
|
elsif shell =~ /bash/
|
16
|
-
@history_pattern = '(.*)
|
17
|
-
@
|
18
|
-
|
16
|
+
@history_pattern = '(.*)'
|
17
|
+
@sh_history_file = File.expand_path('~/.bash_history')
|
18
|
+
@tail_margin = 1
|
19
19
|
else
|
20
20
|
puts "does not support is #{shell}"
|
21
21
|
end
|
@@ -25,9 +25,9 @@ module AM
|
|
25
25
|
exit if @sh_history_file.nil?
|
26
26
|
|
27
27
|
commands = []
|
28
|
-
last_commands = `tail
|
28
|
+
last_commands = `tail -#{6-@tail_margin} #{@sh_history_file} | head -5`.split("\n")
|
29
29
|
last_commands.each_with_index do |c,i|
|
30
|
-
record = c.split(/#{@history_pattern}/)[
|
30
|
+
record = c.split(/#{@history_pattern}/)[COMMAND].strip
|
31
31
|
puts " #{(i+1).to_s} : #{record.to_s}"
|
32
32
|
commands << record
|
33
33
|
end
|
@@ -36,7 +36,7 @@ module AM
|
|
36
36
|
|
37
37
|
def get_last_command
|
38
38
|
exit if @sh_history_file.nil?
|
39
|
-
`tail
|
39
|
+
`tail -#{2-@tail_margin} #{@sh_history_file} | head -1`.split(/#{@history_pattern}/)[COMMAND].strip
|
40
40
|
end
|
41
41
|
|
42
42
|
end
|