## Functions
Little helper to return the correct file extension based on the SHELL value.
Helper to return the correct script template based on the SHELL provided
StringHelper to return the expected location for SHELL config file, based on the provided shell value.
Helper to return the source line to add depending on the SHELL provided or detected.
If the provided SHELL is not known, it returns the source line for a Bash shell.
BooleanHelper to check if a filename is one of the SHELL config we expect
BooleanChecks a given file for the existence of a specific line. Used to prevent adding multiple completion source to SHELL scripts.
Opens a file for modification adding a new source line for the given
SHELL. Used for both SHELL script and tabtab internal one.
Writes to SHELL config file adding a new line, but only one, to the SHELL config script. This enables tabtab to work for the given SHELL.
Writes to tabtab internal script that acts as a frontend router for the completion mechanism, in the internal ~/.config/tabtab directory. Every completion is added to this file.
This writes a new completion script in the internal ~/.config/tabtab
directory. Depending on the SHELL used, a different script is created for
the given SHELL.
Top level install method. Does three things:
Removes the 3 relevant lines from provided filename, based on the package name passed in.
Here the idea is to uninstall a given package completion from internal tabtab scripts and / or the SHELL config.
It also removes the relevant scripts if no more completion are installed on the system.
String | Shell to base the check on, defaults to system shell. |
## locationFromShell(shell) ⇒ String
Helper to return the expected location for SHELL config file, based on the
provided shell value.
**Kind**: global function
**Returns**: String - Either ~/.bashrc, ~/.zshrc or ~/.config/fish/config.fish,
untildified. Defaults to ~/.bashrc if provided SHELL is not valid.
| Param | Type | Description |
| --- | --- | --- |
| shell | String | Shell value to test against |
## sourceLineForShell(scriptname, shell)
Helper to return the source line to add depending on the SHELL provided or detected.
If the provided SHELL is not known, it returns the source line for a Bash shell.
**Kind**: global function
| Param | Type | Description |
| --- | --- | --- |
| scriptname | String | The script to source |
| shell | String | Shell to base the check on, defaults to system shell. |
## isInShellConfig(filename) ⇒ Boolean
Helper to check if a filename is one of the SHELL config we expect
**Kind**: global function
**Returns**: Boolean - Either true or false
| Param | Type | Description |
| --- | --- | --- |
| filename | String | Filename to check against |
## checkFilenameForLine(filename, line) ⇒ Boolean
Checks a given file for the existence of a specific line. Used to prevent
adding multiple completion source to SHELL scripts.
**Kind**: global function
**Returns**: Boolean - true or false, false if the line is not present.
| Param | Type | Description |
| --- | --- | --- |
| filename | String | The filename to check against |
| line | String | The line to look for |
## writeLineToFilename(options)
Opens a file for modification adding a new `source` line for the given
SHELL. Used for both SHELL script and tabtab internal one.
**Kind**: global function
| Param | Type | Description |
| --- | --- | --- |
| options | Object | Options with - filename: The file to modify - scriptname: The line to add sourcing this file - name: The package being configured |
## writeToShellConfig(options)
Writes to SHELL config file adding a new line, but only one, to the SHELL
config script. This enables tabtab to work for the given SHELL.
**Kind**: global function
| Param | Type | Description |
| --- | --- | --- |
| options | Object | Options object with - location: The SHELL script location (~/.bashrc, ~/.zshrc or ~/.config/fish/config.fish) - name: The package configured for completion |
## writeToTabtabScript(options)
Writes to tabtab internal script that acts as a frontend router for the
completion mechanism, in the internal ~/.config/tabtab directory. Every
completion is added to this file.
**Kind**: global function
| Param | Type | Description |
| --- | --- | --- |
| options | Object | Options object with - name: The package configured for completion |
## writeToCompletionScript(options)
This writes a new completion script in the internal `~/.config/tabtab`
directory. Depending on the SHELL used, a different script is created for
the given SHELL.
**Kind**: global function
| Param | Type | Description |
| --- | --- | --- |
| options | Object | Options object with - name: The package configured for completion - completer: The binary that will act as the completer for `name` program |
## install(options)
Top level install method. Does three things:
- Writes to SHELL config file, adding a new line to tabtab internal script.
- Creates or edit tabtab internal script
- Creates the actual completion script for this package.
**Kind**: global function
| Param | Type | Description |
| --- | --- | --- |
| options | Object | Options object with - name: The program name to complete - completer: The actual program or binary that will act as the completer for `name` program. Can be the same. - location: The SHELL script config location (~/.bashrc, ~/.zshrc or ~/.config/fish/config.fish) |
## removeLinesFromFilename(filename, name)
Removes the 3 relevant lines from provided filename, based on the package
name passed in.
**Kind**: global function
| Param | Type | Description |
| --- | --- | --- |
| filename | String | The filename to operate on |
| name | String | The package name to look for |
## uninstall(options)
Here the idea is to uninstall a given package completion from internal
tabtab scripts and / or the SHELL config.
It also removes the relevant scripts if no more completion are installed on
the system.
**Kind**: global function
| Param | Type | Description |
| --- | --- | --- |
| options | Object | Options object with - name: The package name to look for |