A bash utility script that wraps commands in Zellij panes when available, with graceful fallback to regular bash execution.
zellij-run allows you to execute bash commands either in a new Zellij pane or with regular bash if Zellij isn't available. It's designed as a drop-in replacement for bash -c that automatically leverages Zellij's pane system when possible.
- Run commands in a new Zellij pane when inside a Zellij session
- Gracefully fall back to regular bash execution when Zellij isn't available
- Compatible with
bash -csyntax for easy integration with other tools - Customizable pane naming
- Works correctly with detached Zellij sessions
- Save the script to a directory in your PATH:
# Create ~/bin if it doesn't exist
mkdir -p ~/bin
# Download the script
curl -o ~/bin/zellij-run https://path-to-raw-script/zellij-run
# or manually create and paste the script content
# Make it executable
chmod +x ~/bin/zellij-run
# Add to PATH if needed (for bash)
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile# Install using homebrew
brew tap yourusername/tap ~/homebrew-tap
brew install zellij-run# Run a simple command
zellij-run 'echo "Hello World"'
# Run multiple commands
zellij-run 'ls -la && echo "Done listing files"'
# Using -c flag (bash -c compatibility)
zellij-run -c 'find . -name "*.txt"'# Set a custom pane name
zellij-run -n "File Search" 'find . -name "*.txt"'
# Combined with -c flag
zellij-run -n "System Status" -c 'top -b -n 1'| Option | Description |
|---|---|
-c 'command' |
Specify the command to run (bash -c compatibility) |
-n 'name' |
Set a custom pane name (default: "Command Output") |
-h |
Display help information |
k9s:
plugins:
podlogs:
shortCut: Shift-L
description: "Pod logs in Zellij"
scopes:
- pods
command: zellij-run
args:
- -n
- "Pod: $NAME"
- -c
- "kubectl logs $NAME -n $NAMESPACE -f"- Inside Active Zellij Session: Creates a new pane with your command
- Detached Zellij Sessions: Falls back to regular bash execution
- No Zellij Available: Executes command with standard bash
If you encounter issues:
- Ensure Zellij is properly installed (
zellij --version) - Check if the script is executable (
chmod +x path/to/zellij-run) - Verify the script is in your PATH (
which zellij-run) - For pane creation issues, make sure you're in an active Zellij session (
echo $ZELLIJ)
This script is released under the GNU General Public License v3.0 (GPL-3.0).
Feel free to contribute improvements or report issues!