am 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/am/version.rb +1 -1
  3. data/lib/tail.rb +8 -6
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2daba3de95eb8972a6ee9de3b8af5686a77f66d4
4
- data.tar.gz: 86cf82ef88025b34465e1bcdb9397774ab2aceb0
3
+ metadata.gz: dd20e052e21e26b87aa4b9cc4c57a05a8583a7a3
4
+ data.tar.gz: f81a14e5fa2d91ce26a86689ffece48b32a97741
5
5
  SHA512:
6
- metadata.gz: 4d88e019ba34b2e53317d75c851f196a246c220a37d5f80afdea72e3d44707001403568f49769b5f07f847a00160608a35b5446de58e5121e48e4dddbc70bc09
7
- data.tar.gz: 8d5eb095075f76de314aa664c43d0a4aff0da2a48284c4d61b0d060826b4bca3f805dac9f463ff4452795b70f97d17315353ddb2e613438b3b2f2131961ee671
6
+ metadata.gz: 99d393b3714778abb145fe43b99c52cf951cf84a40f3f047cdd062cd650d54ef1d0bbe4649a8dfaf6ce00059cfd44ec22a36887c1c4d9c171a3de6016d674c44
7
+ data.tar.gz: e3dc3b99aefce5967a19594fe332eda737c9e46c4e4a6302d45d9bf176adaf06815b4d8bddf0207dd33b68d8417aa761eef8f8e1d6a18de777d41160bee3ea3a
data/lib/am/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Am
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
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 = '.*;(.*)\n'
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}/)[COMMAND]
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}/)[COMMAND].strip
39
+ `tail -2 #{@sh_history_file} | head -1`.split(/#{@history_pattern}/)[@command_col].strip
38
40
  end
39
41
 
40
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: am
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ka-yamashita