3 Ways to Supercharge your Shell Workflows
Hey! We're Fig. Fig provides a suite of tools to make developers more productive in the terminal. Fig Scripts allow you to easily automate your and your teams most common terminal workflows.
The terminal is a versatile and efficient tool that can help streamline workflows and boost productivity. But, as anyone who's ever worked with the terminal knows, it can also be a bit of a pain to use. That's why we're excited about Fig Scripts. Fig Scripts makes it easy to build, deploy, and share internal scripts and CLI tools. In this post, we'll highlight 3 of the most powerful features of Fig scripts that will empower you to become a 10x developer 💪💪
Fig Scripts take inputs through interactive terminal UIs. Instead of having to remember the exact syntax and order for passing inputs as options/arguments, users can simply fill out a form-like interface. This makes it much easier for teammates to understand how to actually use the script. It also helps to ensure that the right inputs are being passed.
In addition to making scripts more discoverable, form-like input also allows you to specify the types of inputs that are required. This helps validate inputs before they are executed, not after. For example, you can specify that a particular input is a file, and Fig will display a file picker component to the end user. Validating input types helps to prevent errors and ensure that the script is being used correctly.
Finally, if you still want to pass inputs to the script the traditional way (using options or arguments passed in from the command line), you can do this too! Any mandatory inputs that aren't passed in this way will just show up as interactive inputs.
Fig adds contextual suggestions to your inputs. For example, if the input to a script is a Git branch name, you could populate the suggestions for the input with a list of all the branch names in that repo. We call these type of suggestions “generators” and they are one of the most powerful ways to make script execution dead simple. Fig has predefined hundreds of generators for common input types (git branches, AWS resources, kubernetes clusters, etc). However, you can also specify your own generators with an arbitrary shell command.
For example, let's say you have a script that asks for an AWS EC2 instance name as an input. To generate suggestions for it, you would use Fig's pre-built generator to list of all AWS instances available to the current user. You can even pass inputs to generators. For example, a user could select an AWS region first, and then the list of EC2 regions could be automatically filtered based on the user's selected region.
Generators save a lot of time spent re-running commands and copying/pasting. They also help prevent typos or invalid inputs!
Fig Scripts also comes with guardrails built in: when you create a script, you can specify rules that ensure it makes sense for the script to be run. For example, you can set rules to check the current working directory, the value of an environment variable, or the current git branch to validate that the script is sensible before the script is event executed.
Rules are especially helpful for shared scripts across teams. For example, you can set up guardrails to make sure there is a
package.json file present when trying to run a script meant only for a typescript project. Rules can also help provide guarantees around dangerous actions like deploying a repo, by making sure that the repo is only deployed from the
main branch. While it may seem like rules may slow you down, they're designed to save you and your team time by preventing you from re-running commands or waiting for workflows to run, only to find out some initial condition was mis-configured part way through.
If you want to read more about what you can do with Fig Scripts, check out our launch blog post. Alternatively, you can get started creating your own script today by downloading the Fig from fig.io/download