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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/am/version.rb +1 -1
  3. data/lib/tail.rb +10 -10
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 723bbc87212ffce2be4477ad66898027961be8ce
4
- data.tar.gz: 5183ecd4569cbc3341da6235dcaeeefd8c044308
3
+ metadata.gz: 6f536428a276df0fd09ec9937e8a5a32995c4e8b
4
+ data.tar.gz: dc5e19ae44f8d6957b67a9f138eb5edd86de37b6
5
5
  SHA512:
6
- metadata.gz: 89e0b0383852903626c45183e1fcbe36365aed67d626d48f4a4b9f0a2976bc1f34672aa3f5b153141ba0b065fe26f67bdb24a8b5b59d01b0ffe6f56b9d751aec
7
- data.tar.gz: 500a820faaf14e74861efef25981200358dfb64ef2d520e55c2ed6bc684f564137f3aabedf47750067b0fe802d49e4775d4818f8d866575fe9e02f9462356ba9
6
+ metadata.gz: 043ad037b3a430e61d3dca3e0dccaaac7019acf0ed714bfc469c33b793a7f3e655e32560db22d2528e27a956fce57e31f2a3d4c6c8ac5f1ec96be3c380d8c791
7
+ data.tar.gz: b1d21f7a283e740fc9cbe37aa834999fdea81b670b6b1a4a550db8817893256d77e069a9aa0ddf402ab52be69f76eddf8a12bd71df4d7c0540d4ca27b02f9d85
data/lib/am/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Am
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
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
- @sh_history_file = get_history_file
6
+ set_profile
7
7
  end
8
8
 
9
- def get_history_file
9
+ def set_profile
10
10
  shell = `echo $SHELL`
11
11
  if shell =~ /zsh/
12
12
  @history_pattern = '.*;(.*)'
13
- @command_col = 1
14
- return File.expand_path('~/.zsh_history')
13
+ @sh_history_file = File.expand_path('~/.zsh_history')
14
+ @tail_margin = 0
15
15
  elsif shell =~ /bash/
16
- @history_pattern = '(.*)\n'
17
- @command_col = 0
18
- return File.expand_path('~/.bash_history')
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 -6 #{@sh_history_file} | head -5`.split("\n")
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}/)[@command_col].strip
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 -2 #{@sh_history_file} | head -1`.split(/#{@history_pattern}/)[@command_col].strip
39
+ `tail -#{2-@tail_margin} #{@sh_history_file} | head -1`.split(/#{@history_pattern}/)[COMMAND].strip
40
40
  end
41
41
 
42
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.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - ka-yamashita