Sha256: 62c6bdeda622790cc478338a9455b6ad7d4f63d3c7c36ce4a054e5a31713b249

Contents?: true

Size: 965 Bytes

Versions: 13

Compression:

Stored size: 965 Bytes

Contents

require 'optparse'
require 'json'
require 'tempfile'
require 'tmpdir'

module PerfMonger
module Command

class InitShellCommand < BaseCommand
  register_command 'init-shell', "Generate shell script to init shell completion"

  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 <<EOS
source #{File.expand_path("misc/perfmonger.zsh", gem_dir)}
EOS
      else
        puts <<EOS
# Add a following line to ~/.zshrc

eval "$(perfmonger init-shell -)"
EOS
      end
    when "bash"
      if argv.first == "-"
        puts <<EOS
source #{File.expand_path("misc/perfmonger.bash", gem_dir)}
EOS
      else
        puts <<EOS
# Add a following line to ~/.bashrc

eval "$(perfmonger init-shell -)"
EOS
      end
    end

    true
  end
end

end # module Command
end # module PerfMonger

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
perfmonger-0.14.4 lib/perfmonger/command/init-shell.rb
perfmonger-0.14.2 lib/perfmonger/command/init-shell.rb
perfmonger-0.14.1 lib/perfmonger/command/init-shell.rb
perfmonger-0.14.0 lib/perfmonger/command/init-shell.rb
perfmonger-0.13.1 lib/perfmonger/command/init-shell.rb
perfmonger-0.12.1 lib/perfmonger/command/init-shell.rb
perfmonger-0.12.0 lib/perfmonger/command/init-shell.rb
perfmonger-0.11.2 lib/perfmonger/command/init-shell.rb
perfmonger-0.11.1 lib/perfmonger/command/init-shell.rb
perfmonger-0.11.0 lib/perfmonger/command/init-shell.rb
perfmonger-0.10.2 lib/perfmonger/command/init-shell.rb
perfmonger-0.10.1 lib/perfmonger/command/init-shell.rb
perfmonger-0.9.0 lib/perfmonger/command/init-shell.rb