Add a command for installing bash/zsh completion rules
postmodern opened this issue · 3 comments
Add a command which can install ronin
's completion rules into the users shell configuration or into one of the bash.completion.d
directories or zsh/vendor-completions
. The command should pick the appropriate directory based on ENV['SHELL']
and whether the user is a regular user or root.
The command should also install the completion files from the other ronin-*
gems, using Ronin::Foo::ROOT
from each library's ronin/foo/root
file.
COMPLETION_FILES = [
File.join(ROOT,'data','completions','ronin'),
File.join(Exploits::ROOT,'data','completions','ronin-exploits'),
...
]
If the user is root then install into the /usr/local/...
completion directory for the shell. If the user is a regular user, install into the ~/.local/share/
or ~/
completions directory.
The command should also have a --print
option which prints all completion files instead of installing them. This will allow doing eval $(ronin completions --print)
.
Alternatively, instead of doing File.join(Ronin::SomeOtherLibrary::ROOT,'data','completions',...)
to access another library's shell completions file, we could probably define a constant in the other library:
lib/ronin/some_other_library/cli/completions.rb
:
module Ronin
module SomeOtherLibrary
class CLI
COMPLETIONS = File.join(ROOT,'data','completions','ronin-foo')
end
end
end
This way we wouldn't be violating "tell, don't ask" and not directly accessing another library's data
directory, and instead having it tell us where it's completion file is.
Implemented in 3f50f7a. Although the ronin completion
command is kind of awkward. I inherited from Ronin::Core::CLI::CompletionCommand
but override the methods to handle printing/installing/uninstalling multiple completion files (data/completions/ronin
+ all of the other gem's completion files).