scriptura: a cozy corner for your scripts
I am pleased to present a new tool called scriptura, designed to simplify the management of scripts within a folder tree. This innovative tool is tailored for fish users and is inspired by the popular sd tool. With scriptura, you can easily run and manage scripts in a structured manner, making your scripting experience more streamlined and efficient.
To use scriptura, simply type "scriptura run" followed by the desired script path, such as "os update linde." This will execute the script located at "~/scripts/os/update/linde." The tool also offers tab completion for each element in the command line, allowing for a seamless and intuitive user experience.
Pressing the tab key after a script has been resolved will first add "--" to clearly denote the end of the script part of the command line, then use the default shell filename completion. The usage information provides further details on the capabilities and features of scriptura.
To minimize typing, scriptura has several aliases set up. The "sf" alias will display a list of scripts ready for execution, while "sfm" will show the subcommands available within the tool. Scriptura leverages the fish completion system effectively, making it a powerful and user-friendly solution for managing scripts.
For documentation purposes, scriptura searches in specific locations. Although the tool is written in fish, it is not limited to fish scripts; it supports scripts written in any language. If you want to create a new script using scriptura, you can use the "scriptura new" command, which will generate a file with a fish shebang, ready for customization.
I am also planning to add a command-line option to specify a different interpreter, providing even more flexibility to users. The blog post version of sd and the version published to GitHub differ slightly in their implementation. The blog post version uses subcommands similar to sd new, while the GitHub version utilizes flags for actions that do not involve running a script, such as "sd --new." Personally, I find the subcommand style more intuitive, especially when the "run" subcommand is frequently used.
One notable feature I added is the "tree" subcommand. This feature allows you to execute the tree command with the working directory set to $SCRIPTURA_ROOT. However, I understand that not all users may want this functionality. To cater to diverse preferences, the "scriptura" subdirectory exposes scripts as subcommands, allowing flags to be passed to the underlying command and interpreting positional arguments as script path components.
Interestingly, I discovered the sd tool, which also aims to help run and manage scripts under a specific directory tree. There are two reasons why I decided not to use sd directly. Firstly, I believe that a fish implementation would be easier to read and write, as it aligns better with my personal preferences. Secondly, I wanted to avoid the necessity of making numerous external command calls, which can sometimes be cumbersome.
In the introductory blog post, the author states, "It’s not really a thing. It’s more of an idea. You can implement it yourself in one sitting, if you want." Although the process took me more than one sitting, I found the experience both rewarding and enlightening. I encourage you to visit the repository to find installation instructions, including a home-manager module, to get started with scriptura and enjoy its benefits.
Rewritten by urgent.news; may contain errors — check the original.
Source: alanpearce.eu