opsi-cli: Working faster with the Shell Completion

opsi-cli: Working faster with the Shell Completion

As announced in our previous blog post, we have released a new command line tool to work with opsi environments. opsi-cli is implemented in Python and available as part of opsi-utils >= 4.2.0.187 as well as opsi package in our public repositories .

opsi-cli offers a really cool autocompletion feature which I would like to introduce in this blog post. The goal is to make working with opsi-cli more smoothly—like in the shell, the autocompletion works for commands, subcommands, options, etc.

Download now

How to set up Shell Completion for opsi-cli

Shell completion is currently available for three different shells: Bash, ZSH, and Fish. Support for Windows PowerShell is still work in progress.

To set up opsi-cli shell completion, type this command:

opsi-cli self setup-shell-completion

The autocompletion files are now being integrated into the shell’s configuration file in your home directory. As a result, the feature is available in the active shell session and after starting a new login session. For more sophisticated setups, please use the opsi-cli self setup-shell-completion --help command.

Note

For the shell completion to work, please make sure that the opsi-cli executable is included in the PATH environment variable. This is automatically the case after you’ve installed the opsi package or opsi-utils (>= 4.2.0.187).

Features of opsi-cli Shell Completion

The opsi-cli autocompletion works just like traditional Unix shells’ tab completion. Type the first few characters of a command, subcommand, configuration item, option, file argument, or subcommand-specific argument. Pressing the [Tab] key completes the current item if it is unambiguous. Otherwise, you can type more characters and press [Tab] again to narrow down the list.

Pressing [Tab] [Tab] prints all available options or commands (depending on the context). This is how [Tab] [Tab] behaves in various situations:

  • After opsi-cli or any command that has at least one subcommand: shows a list of available (sub-)commands
  • After -: shows available options affecting the current command or the opsi-clitool itself
  • After a subcommand: shows possible values for arguments, depending on the subcommand:
    • For the set, show and unset subcommands of opsi-cli config it shows a list of all available configs to affect.
    • For opsi-cli jsonrpc execute it shows a list of available methods (filtered by a provided prefix).

Give it a try yourself. Working with the opsi-cli autocompletion is so much faster. If you have any questions, feel free to discuss them in our forum .

Visit our Forum

Related Posts

opsi at it-sa 2023: A Recap of a Highly Successful Exhibition

opsi at it-sa 2023: A Recap of a Highly Successful Exhibition

From October 10th to 12th 2023 the it-sa Expo&Congress took place in Nuremberg. Once again, we proudly participated as an exhibitor at Europe’s premier IT security trade fair, showcasing opsi in its fresh, new design.

Read More
New opsi Basic License: Paid Extensions now free for 30 Clients

New opsi Basic License: Paid Extensions now free for 30 Clients

Good news for everyone out there using opsi extensions: With our new Basic license you can install (almost) all our paid extension free of charge on up to 30 clients. This article gives a brief introduction to the new opsi license.

Read More
We proudly present: a new Look for opsi

We proudly present: a new Look for opsi

Right on schedule, opsi unveils a fresh design in celebration of its 20th anniversary. The previous logo has been a companion for two decades: on our website, on mugs, pens, notepads, and gracing the laptops of our dedicated developers and users as stickers. This is the perfect moment for a contemporary makeover with a modern look, fresh colors and a brand-new logo.

Read More