A simple way to save commonly run commands or snippets.
There is the ability to share and collaborate on commands, e.g. in a work environment. This is done via git
and the concept of spaces which we will go into detail later.
This tool is intended to work alongside dotfiles e.g. .bash_aliases
or .functions
but is slightly more portable if rsync
isn't preferred.
Much of the code has been heavily inspired by the wonderful Unix password manager pass. At its core, claw is basically pass
without GPG.
Claw was the name for a similar command-line tool project of mine that never saw it past the design phase. The current feature-set is just a fraction of what was initially planned. That project may still happen or eventually be merged into this tool. Recycling is cool.
- Installation
- Usage
- Useful tips
- Spaces
- Git support
- Environment variables
- Development
- Inspiration
- TODO
apt install claw
brew install claw
Claw uses what is defined in $EDITOR
, so be sure to configure this.
bash
tree
xclip
gnu-getopt
(if on MacOS)git
(optional, but recommended)fzf
(optional, for better search functionality)
claw init [dirname]
By default, a directory at $HOME/.claw/_default/
will be created. To use another name, or to create another space, specify a directory name.
For full usage information, run
claw help
claw create foo/bar
This will create a new file in the currently active space.
claw show foo/bar
Add the -c
flag to copy the command directly to the clipboard.
claw show -c foo/bar
Use the -p
flag to display the full path to the saved command.
claw show -p foo/bar
claw edit foo/bar
claw search query
claw create foo/bar "$(echo !!)"
source $(claw show -p work/env)
Use hjkl
or arrow keys to navigate the tree. Commands are displayed on the left, with paging.
Hit enter to
- Copy to clipboard
.sh -> $ /path/to/script.sh
- No file extension: just paste contents into command line
### Commands with environment variables
Environment variables are detected. If any variable is not defined, then we display a message and/or prompt for input.
If using claw create
inline, be sure to escape $
symbols.
Spaces are a simple way to organise commands and scripts for different environments. You may have multiple projects on the go and each will have its own set of commands to run, e.g. for NodeJS or database administration.
Here is a more illustrative example:
- ``
claw git init [dirname]
Runs git init
in $HOME/.claw/_default/
. Providing dirname
will track the given local directory.
To track another repository, run
claw git clone git@url/to/remote:repo.git
By default, this will clone the remote repository into $HOME/.claw/repo/
. To provide another name use the following
claw git clone git@url/to/remote:repo.git another_name
Any extra git repositories are automatically made into a space. On the other hand, any space can be made into a git repository.
The following environment variables are available to use:
CLAW_DIR
: The base directory to store all claw related files. Default:$HOME/.claw/
CLAW_DEFAULT_SPACE
: Name of the default space. Default:_default
.
- Clone repo:
git clone https://github.com/gobbledygook88/claw.git
apt install shellcheck
orbrew install shellcheck
pip install bashate
- Run test scripts
./tests/staticanalysis.sh
./tests/run_all.sh
pass
: The Standard Unix Password Storepgcli
- Bash autocompletion
- Git flow
- Interactive prompt
- Packaging for unix repositories and MacOS brew
- Easy creation of man pages for saved commands