Class: PGit::Installer::BashAutoCompletion
- Inherits:
-
Object
- Object
- PGit::Installer::BashAutoCompletion
- Defined in:
- lib/pgit/installer/bash_auto_completion.rb
Constant Summary collapse
- FILENAME =
"~/.pgit_auto_completion"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(global_opts, opts, args) ⇒ BashAutoCompletion
constructor
A new instance of BashAutoCompletion.
- #source_completer_from_bashrc ⇒ Object
- #write_completer_file ⇒ Object
Constructor Details
#initialize(global_opts, opts, args) ⇒ BashAutoCompletion
Returns a new instance of BashAutoCompletion.
22 23 |
# File 'lib/pgit/installer/bash_auto_completion.rb', line 22 def initialize(global_opts, opts, args) end |
Class Method Details
.script ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/pgit/installer/bash_auto_completion.rb', line 6 def self.script autocompletion = " function get_pgit_commands\n {\n if [ -z $2 ]; then\n COMPREPLY=(`pgit help -c`)\n else\n COMPREPLY=(`pgit help -c $2`)\n fi\n }\n complete -F get_pgit_commands pgit\n AUTOCOMPLETION\n\n PGit::Helpers::Heredoc.remove_front_spaces(autocompletion)\nend\n" |
Instance Method Details
#source_completer_from_bashrc ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/pgit/installer/bash_auto_completion.rb', line 34 def source_completer_from_bashrc if already_sourced? puts "Already sourcing #{FILENAME} in ~/.bashrc" else = File.("~/.bashrc") b = File.open(, 'a') b.puts "source #{FILENAME}" b.close puts "~/.bashrc will now source #{FILENAME}" end end |
#write_completer_file ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/pgit/installer/bash_auto_completion.rb', line 25 def write_completer_file = File.(FILENAME) f = File.open(, 'w') f.puts PGit::Installer::BashAutoCompletion.script f.close puts "Wrote autocompletion script under #{FILENAME}" end |