Tool for writing and running commands from a command directory.
-
MyCmd is a tool to execute scripts found in directories in the MyCmd Search Path. Each of these scripts are in a hierarchical structure.
-
A script that is executed is called a command.
-
However, the command script isn't run directly by the user.
mycmdis a launcher that sets everything up and then runs the specified command. When launching, the hierarchy is specified by spaces, and not slashes. -
Each command is part of a command group. Command groups are hierarchical.
mycmdis the implicit top level command group. The command group is the mechanism for grouping related commands together, and also for code reuse. The command group consists of a directory named for the command group, as well as a shell library, by convention the command group name suffixed by-lib. -
MyCmd also provides a set of common routines that make writing commands easier.
Read the development log for MyCmd here.
MyCmd is still pre-release software, but we currently support a few mechanisms for installation.
Requirements
To run MyCmd, the following are required:
- Bash 5.x -- if you are on Mac OS, that means installing from Homebrew or another means, as the
bashshipped with Mac OS is too old. - GNU Coreutils
If you want to use the logging command group, the following are also required:
scriptfzfzcat
If you are running on Mac OS, you can install those not already included with Mac OS with Homebrew:
brew install bash coreutils fzfInstallation with Homebrew
I have created a Homebrew tap to install MyCmd via Homebrew. It has the dependencies on the other required Homebrew packages mentioned above, and will automatically install those when you install it. To use this, do the following:
brew tap travisbhartwell/mycmd
brew install mycmdOr:
brew install travisbhartwell/mycmd/mycmd Currently, this has only been tested with Homebrew on Mac OS, but should also work with Homebrew on Linux.
Installation with Mise
You can use the excellent Mise to install MyCmd. Assuming you have Mise installed and configured according to the Getting Started Documentation, you can install MyCmd by:
mise use -g github:travisbhartwell/mycmdMise handles exposing the mycmd command to your PATH and thus requires no additional configuration, by default.
Installation From a Release Tarball
Get the latest release from the releases page. Download the GZipped Tarball attached to the release and untar it. It is recommended to put this in $HOME/.local/share. For example, if you have downloaded the first release version, you would do the following:
mkdir -p $HOME/.local/share &&
cd $HOME/.local/share &&
tar xvf ~/Downloads/mycmd-0.01.tar.gzThis will untar the release contents into $HOME/.local/share/mycmd-0.01. You can either put $HOME/.local/share/mycmd-0.01/bin on your PATH in your shell or symlink $HOME/.local/share/mycmd-0.01/bin/mycmd into a directory such as $HOME/.local/bin that is already on your PATH.
Installation From a Git Checkout
You could also use a Git checkout, but as MyCmd is still in active development, note that the main branch isn't guaranteed to always be in a working state. If you do use a git checkout, it is suggested that you use one of the tags. Tag names prefixed with snapshot- are interim snapshot releases, and tag names prefixed with v are release versions. Again, doing this in $HOME/.local/share is suggested. So, for example, to do a git checkout of the initial release, v0.01:
mkdir -p $HOME/.local/share &&
cd $HOME/.local/share &&
git clone --branch v0.01 https://github.com/travisbhartwell/mycmd.git You can either put $HOME/.local/share/mycmd/bin on your PATH in your shell or symlink $HOME/.local/share/mycmd/bin/mycmd into a directory such as $HOME/.local/bin that is already on your PATH.
Development Worktrees
This is the mechanism I use on my main development machine where I develop MyCmd itself. See the development documentation for more details.
- After reading Ian Henry's post, sd: my script directory, and realizing the haphazard way I was throwing together scripts at work, I saw that a similar approach could work for me, giving me reuse for common tasks. It has indeed made my life a lot better. My
mycmduser directory at work now has over 30 scripts spread across over 15 command groups, and it's infinitely easier for me to create one-off scripts that re-use existing functionality from my other commands and command groups.
MyCmd is licensed under the MIT license and includes other open source software developed by contributors to their respective projects.
These other libraries included in the vendor subdirectory have their own licenses, acknowledged here:
bashup.events: Licensed under the CC0 License. The project repository is at https://github.com/bashup/events/tree/bash44.ansi: Licensed under the MIT License with a non-advertising clause. The project repository is at https://github.com/fidian/ansi.
Additionally, these libraries used for testing MyCmd included in the testing/vendor subdirectory have their own licenses, acknowledged here:
shunit2: Licensed under the Apache License 2.0. The project repository is at https://github.com/kward/shunit2.