From f25c3ef9faaf0e8eb071f6d8ce6f4ffcf52084b5 Mon Sep 17 00:00:00 2001 From: sophia Date: Thu, 16 Apr 2020 14:42:29 -0400 Subject: [PATCH] Install autocomplete for bash --- lib/vagrant/util/install_cli_autocomplete.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/util/install_cli_autocomplete.rb b/lib/vagrant/util/install_cli_autocomplete.rb index ea7cee3e5..2408b3caf 100644 --- a/lib/vagrant/util/install_cli_autocomplete.rb +++ b/lib/vagrant/util/install_cli_autocomplete.rb @@ -1,5 +1,6 @@ module Vagrant module Util + # Generic installation of content to shell config file class Shell PREPEND = "".freeze STRING_INSERT = "".freeze @@ -41,6 +42,7 @@ module Vagrant end end + # Install autocomplete script to zsh config located as .zshrc class ZSHShell < Shell PREPEND = "# >>>> Vagrant zsh completion (start)".freeze STRING_INSERT = """fpath=(#{File.join(Vagrant.source_root, "contrib", "zsh")} $fpath)\ncompinit""".freeze @@ -48,10 +50,19 @@ module Vagrant CONFIG_PATHS = [".zshrc"].freeze end + # Install autocomplete script to bash config located as .bashrc or .bash_profile + class BashShell < Shell + PREPEND = "# >>>> Vagrant bash completion (start)".freeze + STRING_INSERT = ". #{File.join(Vagrant.source_root, 'contrib', 'bash', 'completion.sh')}".freeze + APPEND = "# <<<< Vagrant basg completion (end)".freeze + CONFIG_PATHS = [".bashrc", ".bash_profile"].freeze + end + # Install autocomplete script for supported shells class InstallCLIAutocomplete SUPPORTED_SHELLS = { - "zsh" => Vagrant::Util::ZSHShell + "zsh" => Vagrant::Util::ZSHShell, + "bash" => Vagrant::Util::BashShell } def self.install