Blazing fast terminal commands with customizable leader-key combos and project-specific keybinds. For Zsh and Nushell.
nushell support is limited to leader-key functionality at present.
Note: All the keybinds shown are defined in the
blzconfig, and fully customizable.
With blaze-keys you can:
- Easily assign hotkeys to execute commands in Zsh, like setting
Alt+gto rungit status.- Define different hotkeys for different projects generically, which automatically reassign as you move between projects.
- Define leader key combos in Zsh/Nushell which can:
- Execute commands with minimal key presses, and without leaving the home row - useful for commands like
git statusorcargo build --release. - Expand into the current line to allow you to add arguments - useful for commands like
git commit -amorgit checkout -b. - Run zsh builtins, like the useful
push-line.
- Execute commands with minimal key presses, and without leaving the home row - useful for commands like
- Easily customise hotkeys and leader combos to your preferences.
- Set multiple leader keys which activate different combos.
- Explore your leader key combos with the TUI, which is only ever one hotkey away.
For example, maybe you want to be able to use Shift+Alt+B to run cargo build in a Rust project, but you want the same shortcut to run make in a C project. blaze-keys allows you to easily configure this, without needing to run any commands when you cd between projects.
Tip:
blaze-keysalso works in Vim mode; callbindkey -vbefore activatingblaze-keysin your~/.zshrc.
- Improve macOS support (please see the issue).
- It should work fine on macOS (it has been tested briefly), but I'm in no position to guarantee this - especially for different terminal emulators.
- Support other shells, such as
fish(please upvote the issue if you're interested).- Preliminary support for
nushelladded. Limitations:blzonly supports leader keys innushell; top-level keybinds are not yet supported.
- Preliminary support for
You can try out blaze-keys without installing it, by using the Docker image.
blaze-keys uses two types of configuration:
- The
globalconfiguration:- Contains keybindings which are always applied.
- Defines profiles which contain sets of keybindings for different types of projects.
- Profiles can define
conditionswhich are used to determine whether they should be applied when youcdinto a project.
- Profiles can define
- Defines leader-key combos.
localconfigurations (optional):- Contain keybindings which are applied only when the
localconfiguration is in your current working directory. - Can
inherita profile from the global config.
- Contain keybindings which are applied only when the
After completing the setup steps below, you can follow the brief tutorial.
blz is a single executable file in a tarball, which you can download from the release page. Extract blz from the tarball and make sure it's on your PATH.
You can alternatively install with cargo (Rust 1.88 or newer):
cargo install --locked --bin blz blaze-keysRun blz -g to edit the global config (creating from template if not present). The repo includes an example which demonstrates many of the available features: global.all.yml. I would suggest that you use the all config when prompted, then (after completing step 3 below) follow the tutorial to familiarise yourself with the usage; then you can modify the config as you wish.
Warning: After adding a new leader key to the global config, you need to source your config (in Zsh) or open a new shell for the new keybinds to take effect.
⚠️ macOS users: You will need to configure your terminal emulator to use theOptionkey asAlt. Please see the macOS terminal setup guide for more information.
For zsh, add a line to your .zshrc file and source it:
echo 'source <(blz --zsh-hook)' >> ~/.zshrc
source ~/.zshrcIf using nushell, first you need to generate the file which will hold the leader-key keybindings:
# Important: Run manually before adding the block to the nu config.
blz porcelain generate-nu-sourceThen run config nu to edit the shell config, and paste in the following block:
### blaze-keys: start v1
blz porcelain generate-nu-source
source ~/.config/blaze-keys/.leader_keys.nu
$env.BLZ_SHELL = "nu"
$env.BLZ_LEADER_STATE = (blz porcelain print-leader-state)
$env.config.hooks.pre_execution = $env.config.hooks.pre_execution | append { ||
if ((commandline) | str contains "source") {} else if ((commandline) | str contains "env.BLZ") {} else {
blz porcelain check-leader-state
}
}
### blaze-keys: endThen open a new shell. You will need to use a new terminal tab/window to ensure it doesn't inherit the environment from the first shell.
Note: Local configs are optional, and I would typically recommend creating a profile in the global config instead.
You can use blz -l to edit (creating if not present) a local config in any directory, which will be stored as .blz.yml. It will be applied only when you cd to that directory.
# Optional: You can inherit a profile from the global config.
# This isn't necessary if one of the profile's 'conditions' evaluates to true.
inherits:
- Rust
keybinds:
- key: "Ctrl-l"
command: "ls -la"
- key: "C-g"
# '^M' can be used as the `Enter` key. This is useful here because `blz` applies only one `^M`,
# which in this case expands `!!` to the last executed command;
# another 'Enter' is required to execute the expanded last command.
command: "!!^M"
- key: "F10"
command: "cargo run"
The leader-key functionality is supported in nushell, but top-level keybinds are not yet.
Every time you cd, blz will emit the appropriate keybindings based on the local config, if present, and any profiles in the global config, if applicable. It does not explicitly unset any keybindings when a local config or profile becomes non-applicable, so your keybindings will remain set until a conflicting keybind is applied.
- You can 'overload' aliases by putting them behind different leader keys, to avoid clashes e.g. where you would like
ccto runcargo checkorconan create. - You can execute commands without needing to move your hand to reach the Enter key (
execmode). In my experience, this reduces strain on my wrist significantly. - You can use an alias which expands into the current command line (
abbrmode). Unlike an alias, the full command will appear in your history. - You can create postfix aliases, e.g. if you often work with a Docker image
localhost/my-private-image, you can create an alias withblaze-keyswhich can be used after typing the initial command, likedocker save -o out.tar <trigger blaze-keys to insert 'localhost/my-private-image'>. - The
blaze-keysTUI makes it easier to find an alias which you've forgotten, rather than searching for it in thealiasoutput. - Subjectively, using
blaze-keysjust feels like you have a more direct interface with the terminal. It feels smoother and more fluid, partly because the Enter key becomes more obsolete.
If your top-level keybindings are not working as expected, you can see what keybindings are being emitted by running blz -v:
$ blz -v
Ctrl-P -----> 'push-line' (zle builtin)
Alt-l -----> 'ls -lah'
F2 -----> 'git log'
Alt-B -----> 'cargo build'
Alt-X -----> 'cargo run'
...Note: This is directory-dependent and will include all keybindings from profiles active in your current working directory, or local configs.
You can run blz -B to see the raw bindkey commands which are being executed, in Zsh syntax. You can then manually try to run these bindkey commands to see if they work.
If your TUI is not appearing when triggering a leader key, check for a .panic.blz file in the current working directory.
If you need to view blz logs, you can export BLZ_LOG=debug and view the log file at /tmp/blz.log.
It's possible for another process to inject into the command which is completed with blz, if specifically engineered to do so. However, this is no greater risk than that of a program overwriting your ~/.zshrc to reassign some aliases to malicious commands.
As a precaution, blz will not run as root unless an environment variable (BLZ_ALLOW_ROOT) is explicitly set.