Shell Completion
Dgraph supports command-line completion, a common feature provided by shells like bash or zsh that helps you to type commands in a fast and easy way
We’re overhauling Dgraph’s docs to make them clearer and more approachable. If you notice any issues during this transition or have suggestions, please let us know.
Command-line completion is a common feature provided by shells like bash
or
zsh
that lets you type commands in a fast and easy way. This functionality
automatically fills in partially typed commands when the user press the
tab key.
Completion script
The command-line interpreter requires a completion script to define which completion suggestions can be displayed for a given executable.
Using the dgraph completion
command you can generate a file that can be added
to your shell configuration. Once added, you will be able to auto-complete any
dgraph
command.
Dgraph command completion currently supports bash
and zsh
shells.
First, you need to know which shell you are running. If you don’t know, you can execute the following command:
and the output should look like:
Bash shell
To generate a dgraph-completion.sh
configuration file for your bash
shell,
run the completion
command as follows:
The file content should look like:
Currently, the generated file has 2 lines at the beginning that need to be
removed, or else the script won’t run properly. You can comment them out with a
#
, or you can easily remove them with the following command:
Next, you have to make that file executable by running the following command
(your system might require sudo
to run it):
Now open the .bashrc
file with any text editor (you might need sudo
to apply
changes). For example:
Once opened, add the path to dgraph-completion.sh
using the following syntax
and save:
Finally, reload the bashrc
settings with the following command:
Now you can start typing dgraph
and press tab to get
auto-completion and suggestions:
Was this page helpful?