Speed dial for the CLI-phile.
Project description
sdial
Speed dial for the CLI-phile.
Features
- Speed-dial long commands by number
- Multi-line shell snippets/editing via $EDITOR
- No translation: your snippet is your script
- Fast, OS shell-agnostic
- Plain-text, backup-friendly storage
Installation
pip install sdial
After installation, run it as sdial.
Works on Linux, Mac, Windows (cmd.exe!), PowerShell, WSL. If Python runs somewhere, sdial probably does too.
Quick Start
Have a long command that you frequently type and execute?
Add it to sdial!
sdial add 'docker run --rm -it -v $(pwd)/src:/app/src -v ~/.config/myapp:/root/.config/myapp --name myapp_dev_container mycompany/myapp:latest bash'
# Output to stdout: 0
That output means your command can now be dialed with 0:
sdial dial 0
# Executes 'docker run --rm -it -v $(pwd)/src:/app/src -v ~/.config/myapp:/root/.config/myapp --name myapp_dev_container mycompany/myapp:latest bash'
Want to add another multi line, snippet to speed dial?
sdial add
# Opens $EDITOR, just like `git commit`.
# You type or paste your multi line snippet, then save and exit!
Say that you type the following:
while read file
do
# The $1 here allows `sdial` to pass arguments!
if grep -q "$1" "$file"
then
echo "$file"
fi
done
Say after saving, sdial tells you to dial 1 to run this command.
You can then dial and provide an argument for $1:
find . -name '*.py' | sdial dial 1 "TODO"
This allows you to use one pipe to filter all .py files under the current directory containing the string "TODO".
How does that work? sdial just launches:
$SHELL $snippet_file arg1 arg2 ...
That means your speed dial snippet gets executed by $SHELL as a script, with arguments in $1, $2, etc.
It's dead simple: $SHELL semantics, no translation layer. Anything you can do in a $SHELL script (loops, pipes, arguments) just works.
What if you forgot which commands have speed dial numbers, and what each command's number is?
sdial
This prints out something resembling the following CSV:
number,command
0,"docker run --rm -it -v $(pwd)/src:/app/src -v ~/.config/myapp:/root/.config/myapp --name myapp_dev_container mycompany/myapp:latest bash"
1,"while read file\ndo\n # The $1 here allows `sdial` to pass arguments!\n if grep -q \"$1 \"$file\"\n then\n echo \"$file\"\n fi\ndone"
What if you made a mistake when entering a command?
sdial edit 1
This opens $EDITOR and allows you to edit what number 1 speed dials.
What if you want to unregister a command?
sdial remove 1
In this case, if we remove command with number n, then:
- The commands originally with numbers
n + 1,n + 2, ... - Are reassigned the numbers
n,n + 1, ...
FAQ and Tips
Can I use variables, pipes, and advanced shell scripting?
Yes - your snippets are executed as $SHELL $snippet_file $args.... This means:
- All shell scripting works: variables ($1, $2), loops, functions, pipes, etc.
- You can use here docs, pipe to other commands, etc.
How do you store the commands?
- Each command is stored as a file under
~/.sdial/. The filenames are ordered using fractional base58 to allow easy insertion and deletion without renaming every file. - Listing (
sdial) reads their sorted names and shows the commands.
Does this work with cmd.exe or PowerShell?
- Yes! Just beware that cmd.exe and PowerShell have their own syntax and semantics.
Environment variables and context?
- Commands/scripts run with the current environment (
$PWD,$PATH, etc.) as when you invokesdial. - On Unix, use
VARIABLE=value sdial $nto set them.
How do I back up all my dials or share them?
- Simply copy
~/.sdial/- all your scripts are plain text files!
What if I want to reset or wipe all commands?
rm -rf ~/.sdial/
Or selectively delete individual files in there.
Why? Because Nobody Else Had The Guts.
- No one combined numbered launching, fractional indexing, $EDITOR multi-line, and Shell and OS-agnostic design.
- We did.
Contributing
Contributions are welcome! Please submit pull requests or open issues on the GitHub repository.
License
MIT - no nonsense, use it however you want.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sdial-0.1.0a3.tar.gz.
File metadata
- Download URL: sdial-0.1.0a3.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ac507c4b6ca8eb51b919f8c94ab43ef56978197674319fd93da35a2a751f971
|
|
| MD5 |
388eba8cfe2821fff72383f53d820367
|
|
| BLAKE2b-256 |
70dd744fb27ee81e6e6b9bbe5661abce3046b81ebe2ef4c834336f8af81c1e30
|
File details
Details for the file sdial-0.1.0a3-py2.py3-none-any.whl.
File metadata
- Download URL: sdial-0.1.0a3-py2.py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c7b28f719b63a202c6f6df62c2d3f21a6ff7b584a534bec866d718aed7e9a31
|
|
| MD5 |
5a3d16bcd8c3bc9ad797746ddea37ec3
|
|
| BLAKE2b-256 |
0059a03c0609913e716553a087736bf8ccc2129367db90d90d2ee50b9ea1f6d5
|