Paket shell completion for zsh
Installation
Download
-
Download the
paket-completion.zsh
file to a subdirectory of your home directory, preferably a directory with other function files. - Rename it to
_paket
. - Add the directory to your zsh
fpath
before runningcompinit
.
1: 2: 3: 4: |
|
In your ~/.zshrc
:
1:
|
|
Updating an existing installation
Just repeat the download from above.
Alternatively the completion script comes bundled with the
paket-completion-update
function that will download the current
paket-completion.zsh
to the same file as above, even if you changed its
location after the initial download.
Please note: The paket-completion-update
function requires curl
to be
installed. paket-completion-update
is only available after your
first paket
completion per shell session (i.e. after the Paket completion
functions have been autoload
ed by zsh).
paket-completion-update
supports an optional first parameter that allows you
to override the default download root URL which is
https://raw.githubusercontent.com/fsprojects/Paket/master/completion
.
paket
alias
For easier consumption of Paket (without paket.sh
or paket.cmd
) it is
advised to create an alias and always run Paket from the repository root.
Also have a look at Paket's magic mode.
Somewhere in your ~/.zshrc
:
1: 2: 3: 4: 5: |
|
Also ensure that zsh completes aliases based on the expanded alias contents.
1:
|
|
If you don't like alias completion, define that the paket
alias should be
completed using the _paket
function defined in the _paket
file.
1: 2: |
|
Mono
If you use Mono (e.g. on Linux or macOS) and do not have Mono completion
installed, you need to define that mono
invokes other programs:
1:
|
|
This is similar to nohup
invoking the "real" program that needs to be completed.
More details.
For an exemplar mono
completion, have a look at
@agross dotfiles.
Configuration
You can configure some aspects of Paket completion. Add these to your
~/.zshrc
.
Define where to look for paket.exe
Depending on what should be completed the Paket executable will be run by the
completion script. The completion script searches for a local installation at
./.paket/paket.exe
first. Local installs will be prepended with mono
unless
you are running Windows. Global installations will be looked at last (i.e.
paket
in the $PATH
). They are not prepended with mono
.
To override the list of possible locations for local installations of
paket.exe
, define the following paket-executable
style. The list of values
will be searched as defined.
1: 2: 3: 4: |
|
Enable infix matching for package IDs
By default paket find-packages
will match infixes, which is not the default
mode for Paket completion. I think it's unnatural to type
1:
|
|
which will be completed to
1:
|
|
if infix matching is enabled.
If you want this behavior, enable infix matches:
1: 2: |
|
Disable fallback (i.e. default zsh) completion for Paket commands that do not have a completion function
1:
|
|
Disable verbose completion of main commands
1:
|
|
Define the zsh completion cache policy for expensive operations that generate completions
Paket will e.g. issue HTTP requests when you complete a package ID or a version number. These take time so we take advantage of the zsh completion cache and store such results.
Enable the zsh completion cache globally, including completions for other commands that also leverage caching:
1: 2: |
|
To disable the cache for specific Paket commands to always get fresh
results when completing e.g. paket add
:
1:
|
|
The caches are stored under the cache-path
as follows:
1:
|
|
e.g. <cache-path>/paket/find-packages/fak
if you completed paket add FAK
or
paket add fak
before.
The default cache policy caches results for 1 day (see _paket_cache_policy
).
To remove cached results you can either delete the
<cache-path>/paket
directory or provide a custom cache policy to control
cache expiration for all or specific Paket commands:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: |
|
There are two special default cache policies for completions relying on the
existence of local files, e.g. paket.dependencies
and paket.lock
.
For Paket commands that read these, the cache is invalidated as soon as the
file's modification time is newer than the cache.
(See _paket_cache_policy_dependencies_file
and
_paket_cache_policy_lock_file
.)
Disable running Paket to get packages, versions etc. as completion arguments
1:
|
|
Disable only a single means to get completion values:
1: 2: 3: 4: 5: 6: 7: |
|
Custom feed URLs for --source
and paket push --url
argument
1: 2: 3: 4: |
|
Override list for a specific command:
1: 2: 3: 4: |
|