Class: PerfMonger::Command::InitShellCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/perfmonger/command/init-shell.rb

Instance Method Summary collapse

Methods inherited from BaseCommand

#initialize, register_alias, register_command

Constructor Details

This class inherits a constructor from PerfMonger::Command::BaseCommand

Instance Method Details

#run(argv) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/perfmonger/command/init-shell.rb', line 13

def run(argv)
  gem_dir = File.expand_path("../../../", __dir__)

  shell = `ps -p #{Process.ppid()} -o 'args='`.strip
  shell = File.basename(shell.split.first)

  case shell
  when "zsh"
    if argv.first == "-"
      puts "source \#{File.expand_path(\"misc/perfmonger.zsh\", gem_dir)}\n"
    else
      puts "# Add a following line to ~/.zshrc\n\neval \"$(perfmonger init-shell -)\"\n"
    end
  when "bash"
    if argv.first == "-"
      puts "source \#{File.expand_path(\"misc/perfmonger.bash\", gem_dir)}\n"
    else
      puts "# Add a following line to ~/.bashrc\n\neval \"$(perfmonger init-shell -)\"\n"
    end
  end

  true
end