CompletionInstaller class

Installs the completion script of a shell for the current user, in the way that is the common practice for the shell:

  • Bash: the script is saved in the user directory of bash-completion, which loads it on demand. Since bash-completion may not be installed, the script is also sourced from ~/.bashrc. On macOS, where terminals start login shells, it is sourced from ~/.bash_profile instead (or from ~/.bash_login or ~/.profile if that is the file in use).
  • Zsh: the script is saved as an autoloadable _name function file and sourced from .zshrc, after initializing the completion system (compinit) unless the startup file has already done so.
  • Fish: the script is saved in the Fish user completions directory, from where Fish loads it on demand.
  • PowerShell: the script is saved next to the PowerShell profile ($PROFILE) and loaded from it.
  • Carapace: the spec is saved in the Carapace user specs directory.

The XDG base directories are honored where the shell honors them. An installation can be repeated: the script is overwritten, and a startup file that already loads it is left as it is.

A startup file is read and appended to in its own encoding: UTF-16 or UTF-32 if it starts with the byte order mark of that encoding (as a profile written by Windows PowerShell does), otherwise UTF-8.

Constructors

CompletionInstaller({Map<String, String>? environment, String? operatingSystem, String? powerShellProfile()?})
environment and operatingSystem default to those of the process.

Properties

environment → Map<String, String>
The environment variables that determine the installation locations.
final
hashCode → int
The hash code for this object.
no setterinherited
operatingSystem → String
The operating system to install for, as in Platform.operatingSystem.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
plan(CompletionShell shell, {required String name, required String script, required String executableName}) → List<CompletionInstallStep>
Plans the installation of script, the completion script of shell for the command name, and returns its steps in order.
scriptPath(CompletionShell shell, String name) → String
The file that the completion script of shell for the command name is installed as.
startupFilePath(CompletionShell shell) → String?
The shell startup file that loads the installed script of shell, or null if the shell finds the script by itself.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

isCommandName(String name) → bool
Whether a completion can be installed for the command name.