https://github.com/purarue/shortcuts
creates arbitrary shell scripts from a configuration file; shortcuts
https://github.com/purarue/shortcuts
cli shell shell-scripting
Last synced: about 2 months ago
JSON representation
creates arbitrary shell scripts from a configuration file; shortcuts
- Host: GitHub
- URL: https://github.com/purarue/shortcuts
- Owner: purarue
- License: mit
- Created: 2019-12-15T08:00:39.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2026-01-23T22:35:10.000Z (5 months ago)
- Last Synced: 2026-01-24T11:10:34.252Z (5 months ago)
- Topics: cli, shell, shell-scripting
- Language: Python
- Homepage:
- Size: 62.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# shortcuts
Creates arbitrary shell scripts from a configuration file; shortcuts
The scripts are described as a [`toml`](https://github.com/toml-lang/toml) file, see [`sample-config.toml`](./sample-config.toml) for an example. You can specify the interpreter, and any links (just copies of the script) you'd want to create, and the command itself. Running `shortcuts create` creates individual shell scripts at `~/.shortcuts`.
A similar functionality could be created with aliases, but those aren't on your \$PATH; aren't visible to other scripts or accessible by system utilities like [`rofi`](https://github.com/davatorium/rofi) (the major inspiration for writing this). You should add the shortcut directory to your path, by adding `export PATH=$PATH:$HOME/.shortcuts` to your shell profile. If you want to use the scripts generated with system utilities, I'd recommend setting your path in `~/.profile` in a `#!/bin/sh` script, and then running `source ~/.profile` in your corresponding `bash`/`zsh` startup files.
This allows me to create/change short/one liner shell scripts in one place, instead of creating/deleting/linking/copying files around in some bin directory manually.
For a more extensive example, see [my `shortcuts.toml` file](https://purarue.xyz/d/shortcuts.toml?redirect)
If you edit this in vim, you can put the following line in your configuration, so that `shortcuts create` runs whenever you save the file:
```vim
autocmd BufWritePost shortcuts.toml !shortcuts create
```
or in neovim with lua:
```lua
vim.api.nvim_create_autocmd("BufWritePost", {
command = "!shortcuts create",
group = vim.api.nvim_create_augroup("shortcuts", { clear = true }),
pattern = { "shortcuts.toml" },
desc = "create shortcuts script when I save config file",
})
```
### Install
Requires python 3.10+
`python3 -m pip install git+https://github.com/purarue/shortcuts`
Should be accessible as `shortcuts` or `python3 -m shortcuts`
### Usage
```
Usage: shortcuts create [OPTIONS]
Create the shell scripts!
Options:
--debug / --quiet Log shortcut files being created
--conf PATH specify a configuration file
--shortcuts-dir PATH specify a shortcuts directory
--help Show this message and exit.
```
You can also set the environment variables `SHORTCUTS_CONFIG` and `SHORTCUTS_DIR`, instead of passing `--conf` and `--shortcuts-dir`.