#alias #shell #jsonc #yaml #generate #zsh #bash #fish #power-shell

bin+lib shaka

Generate shell aliases and functions from YAML/JSONC config files

4 releases

Uses new Rust 2024

0.0.3 Apr 12, 2026
0.0.2 Apr 12, 2026
0.0.1 Apr 12, 2026
0.0.0 Apr 12, 2026

#425 in Unix APIs

MIT license

25KB
518 lines

SHAKA

One config for every shell shortcut.

Generate aliases and functions for bash, zsh, fish, and PowerShell from a single YAML or JSONC config.

Why you should choose shaka?

Managing shell shortcuts across multiple shells (bash, zsh, fish, PowerShell) becomes fragmented and hard to maintain. Aliases defined in .zshrc don't apply to bash, project-specific commands scatter across different files, and keeping them in sync is tedious.

shaka solves this by letting you define all your shortcuts once in a single YAML or JSONC file and generate the appropriate shell-specific output. Benefits include:

  • Single source of truth for all commands
  • Automatic generation for bash, zsh, fish, and PowerShell
  • Project-level overrides for repository-specific commands
  • Built-in PowerShell compatibility (no manual alias conflict resolution)

Quick Start

The example below uses zsh, but the same workflow applies to the other supported shells.

  1. Create a global config file at ~/.config/shaka.yaml:
dc: docker compose
gs: git status
  1. Ask shaka to generate shell code for your shell:
shaka zsh

Example output:

alias dc='docker compose'
alias gs='git status'
  1. Evaluate that output in your shell so the aliases become available in the current session:
eval "$(shaka zsh)"
  1. Use the alias:
gs

Example behavior:

$ gs
git status
On branch main
nothing to commit, working tree clean

To make this automatic every time you open a shell, add the same eval "$(shaka zsh)" line to your shell profile.

Installation

Install from the current source checkout:

cargo install --path .

If shaka is published on crates.io, install it as a package:

cargo install shaka

Build and run locally during development:

cargo run -- zsh

Usage

shaka prints shell code to standard output:

shaka <bash|fish|pwsh|pwsh-conflict|zsh>

Typical usage:

  • bash

    eval "$(shaka bash)"
    
  • zsh

    eval "$(shaka zsh)"
    
  • fish

    shaka fish | source
    
  • pwsh

    Invoke-Expression (& shaka pwsh | Out-String)
    

If the shell argument is missing or unsupported, shaka exits with an error and prints the expected usage string.

Supported Shells

  • bash
  • fish
  • pwsh
  • zsh

Configuration

shaka loads configuration files in the following order. Later files override earlier files.

Global

User-level configuration:

  • ~/.config/shaka.yaml
  • ~/.config/shaka.json
  • ~/.shaka.yaml
  • ~/.shaka.json

Project

Project-level configuration from the current directory. These files have higher priority than global configuration:

  • ./.shaka.yaml
  • ./.shaka.json

Configuration Format

shaka accepts either YAML or JSONC.

Map form:

dc: docker compose
gs: git status

Pair-list form:

- [dc, docker compose]
- [gs, git status]

JSONC form:

{
  // comments are allowed
  "dc": "docker compose",
  "gs": "git status",
}

Precedence

shaka loads global configuration first and then applies project-level configuration on top of it. In practice, this means your personal defaults can live in your home directory, while a repository can override or add commands locally without changing your global setup.

For example, you might keep this in your global config:

# ~/.config/shaka.yaml
dc: docker compose
ls: eza

Then, inside a specific project, you might define:

# ./.shaka.yaml
dc: docker compose -f dev.yml
test: cargo test

When shaka merges these files, the project value for dc replaces the global one, while the other commands remain available. The final result behaves as if you had written:

ls: eza
dc: docker compose -f dev.yml
test: cargo test

Output

shaka outputs shell code that you evaluate in your shell profile or startup script.

For the config:

dc: docker compose

bash, zsh, and fish render aliases:

alias dc='docker compose'

PowerShell renders functions:

Remove-Alias -Name dc -Force -ErrorAction SilentlyContinue
function dc { docker compose @args }

PowerShell Modes

By default, shaka pwsh removes an existing alias with the same name before defining the function. This avoids conflicts with built-in aliases.

If you want to keep built-in aliases and only emit functions, use:

Invoke-Expression (& shaka pwsh-conflict | Out-String)

That renders:

function dc { docker compose @args }

shaka uses Remove-Alias for cleanup in PowerShell mode.

PowerShell Environment Variable Expansion

In pwsh output mode, shaka expands environment variables inside command values before rendering functions. This is useful when your shortcuts depend on machine-specific locations such as your home directory or application install paths.

  • Supported forms: $NAME and $env:NAME
  • Missing variables are left unchanged
  • Expansion is only applied for pwsh; bash, fish, and zsh outputs are unchanged

Example use case:

You want a shortcut that opens your projects directory in your editor without hardcoding your user-specific home path.

Example config:

n: $HOME/.local/bin/node

Generated PowerShell function:

function n { C:/User/.local/bin/node @args }

This keeps the config portable while still producing a concrete command at render time. It is helpful when the command should stay the same logically, but the underlying absolute path differs from one machine to another.

Dependencies

~2.1–3.5MB
~70K SLoC