A smart command runner with directory-scoped history by default.
gas helps you run commands and scripts without having to remember the exact syntax every time. By default, it stores and reuses commands for the current directory. If you add a -label, you can run that command from any directory.
It's particularly handy when you're jumping between different projects that all have their own build commands, test runners, or scripts.
gas(no flags): runs the last command saved for the current directory only.gas -run "<command>": runs and saves that command for the current directory.gas -run <label>: resolves a labeled command and can run it from any directory.- If the same label exists in multiple directories,
gasprefers the one from your current directory.
- If the same label exists in multiple directories,
- Smart command history - remembers commands per directory
- Label commands - give frequently used commands memorable names
- Interactive selection - browse your command history with fzf
- Environment variables - save environment settings with commands
go install github.com/sisoe24/gas@latestOptional but recommended:
Run a command and remember it:
gas -run "npm test"Re-run the last command in this directory only:
gasGive a command a label so you can run it from anywhere:
gas -run "go test ./..." -label "test-all"
gas -run test-all # labeled command; works from any directoryBrowse and pick from your history:
gas -browse # commands from current directory
gas -browse-all # commands from all directoriesSome real-world usage patterns:
# Set up a build command with a label
gas -run "make build && make test" -label "build-test"
# Run a script with specific environment variables
gas -run ./deploy.sh -env "ENV=staging" -label "deploy-staging"
# Run with interactive shell (loads your .bashrc/.zshrc, etc.)
gas -run myfunction -shell
# Just run a one-off command
gas -run "find . -name '*.go' | xargs wc -l"
# Add a command without running it
gas -add "echo 'hello world'" -label "greet"
# Later, just type gas to repeat the last command
gasgas -last # show info about the last command
gas -delete-directory-commands # delete command history for current directory
gas -delete-all-commands # delete all command history
gas -db-path # show where the history database is stored
gas -db-table # show database table nameWhen using -browse or -browse-all, you get an interactive fzf interface with these keyboard shortcuts:
- ENTER - Run the selected command
- CTRL+D - Delete the selected command
- CTRL+E - Edit the selected command
- CTRL+Y - Copy command to clipboard
- F1 - Show help
- ESC - Cancel and exit
-
SHELLorGAS_SHELL- Determines which shell
gasuses to run commands. For Unix-like systems,SHELLis typically set automatically. On Windows, setGAS_SHELLto your preferred shell (e.g.powershell.exeorpwsh)
[!TIP] Powershell:
$env:GAS_SHELL=(Get-Process -Id $PID).path - Determines which shell
-
EDITORorGAS_EDITOR- Required to open files in your default text editor for editing commands. For Unix-like systems,
EDITORis typically set automatically. On Windows, setGAS_EDITORto your preferred editor.
- Required to open files in your default text editor for editing commands. For Unix-like systems,
-
GAS_DB_PATH- Overrides the default database file path (
~/.config/gas/gas.sqlite).
- Overrides the default database file path (
-
GAS_FZF_PREVIEW_CMD- Custom preview command for fzf when browsing command history. The command data is passed as base64-encoded string to handle multiline content.
- Default:
echo {2} | base64 -d - If
batexists:echo {2} | base64 -d | bat --language=yaml --color=always
[!TIP] Powershell:
$env:GAS_FZF_PREVIEW_CMD="powershell -Command '[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String(''{2}''))'"or use WSL:wsl echo {2} | wsl base64 -d
If you find bugs or want to add features, feel free to open an issue or submit a pull request. The code is pretty straightforward Go.
To run tests:
go test -v