-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from nevzatseferoglu/zsh-shell-completion
Add zsh shell auto-completion function
- Loading branch information
Showing
3 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Shell completions | ||
|
||
## Zsh | ||
|
||
`completions/_ddosify` provides a basic auto-completions. You can apply one of the steps to get an auto-completion successfully. | ||
|
||
You can locate the file in any directory referenced by `$fpath`. You can use the following command to list directories in `$fpath`. | ||
|
||
```bash | ||
echo $fpath | tr ' ' '\n' | ||
``` | ||
|
||
For example, if you are using [oh-my-zsh](https://ohmyz.sh/) you can add it as a plugin after locating file under plugin related directory appeared in `$fpath`. You can create a directory named `ddosify` under `~/.oh-my-zsh/plugins` and copy `_ddosify` file to it. | ||
|
||
```bash | ||
mkdir -p ~/.oh-my-zsh/plugins/ddosify | ||
cp completions/_ddosify ~/.oh-my-zsh/plugins/ddosify | ||
``` | ||
|
||
Then, you can add `ddosify` to your plugins list in `~/.zshrc` file. | ||
|
||
``` | ||
# ~/.zshrc | ||
plugins=( | ||
... | ||
ddosify | ||
) | ||
``` | ||
|
||
If you don't have an appropriate directory, you can create one and add it to `$fpath`. | ||
|
||
``` | ||
mkdir -p ${ZDOTDIR:-~}/.zsh_functions | ||
echo 'fpath+=${ZDOTDIR:-~}/.zsh_functions' >> ${ZDOTDIR:-~}/.zshrc | ||
``` | ||
|
||
Then, you can copy `_ddosify` file to the directory you created. | ||
|
||
``` | ||
cp completions/_ddosify ${ZDOTDIR:-~}/.zsh_functions/_ddosify | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#compdef ddosify _ddosify | ||
|
||
typeset -A opt_args | ||
|
||
_ddosify() { | ||
local curcontext="$curcontext" state line | ||
local -a opts | ||
|
||
opts+=( | ||
"-t[Target URL.]" | ||
"-P[Proxy address as protocol\://username\:password@host\:port. Supported proxies \[http(s), socks\].]" | ||
"-T[Request timeout in seconds (default 5).]" | ||
"-a[Basic authentication, username\:password.]" | ||
"-b[Payload of the network packet (body).]" | ||
"-cert_key_path[A path to a certificate key file (usually called 'key.pem').]:filename:_files" | ||
"-cert_path[A path to a certificate file (usually called 'cert.pem'.)]:filename:_files" | ||
"-config[Json config file path. If a config file is provided, other flag values will be ignored.]:filename:_files" | ||
"-d[Test duration in seconds (default 10).]" | ||
"-debug[Iterates the scenario once and prints curl-like verbose result.]" | ||
"-h[Request Headers. Ex\: -h 'Accept\: text/html' -h 'Content-Type\: application/xml'.]" | ||
"-l[Type of the load test \['linear', 'incremental', 'waved'\] (default 'linear').]" | ||
"-m[Request Method Type. For Http(s)\:\['GET', 'POST', 'PUT', 'DELETE', 'UPDATE', 'PATCH'\] (default 'GET').]" | ||
"-n[Total iteration count (default 100).]" | ||
"-o[Output destination (default 'stdout').]" | ||
"-version[Prints version, git commit, built date (utc), go information and quit.]" | ||
) | ||
|
||
_arguments -s -w : $opts && return 0 | ||
|
||
return 1 | ||
} | ||
|