8.6 KiB
Functions
- shellExtension() ⇒
Little helper to return the correct file extension based on the SHELL value.
- scriptFromShell(shell) ⇒
Helper to return the correct script template based on the SHELL provided
- locationFromShell(shell) ⇒
String Helper to return the expected location for SHELL config file, based on the provided shell value.
- 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.
- isInShellConfig(filename) ⇒
Boolean Helper to check if a filename is one of the SHELL config we expect
- 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.
- writeLineToFilename(options)
Opens a file for modification adding a new
sourceline for the given SHELL. Used for both SHELL script and tabtab internal one.- 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.
- 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.
- writeToCompletionScript(options)
This writes a new completion script in the internal
~/.config/tabtabdirectory. Depending on the SHELL used, a different script is created for the given SHELL.- 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.
- removeLinesFromFilename(filename, name)
Removes the 3 relevant lines from provided filename, based on the package name passed in.
- 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.
shellExtension() ⇒
Little helper to return the correct file extension based on the SHELL value.
Kind: global function
Returns: The correct file extension for the given SHELL script location
scriptFromShell(shell) ⇒
Helper to return the correct script template based on the SHELL provided
Kind: global function
Returns: The template script content, defaults to Bash for shell we don't know yet
| Param | Type | Description |
|---|---|---|
| shell | 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 |