Last active
December 7, 2025 15:37
-
-
Save baldwindavid/61ae3ee514dc49a8fb7e47d021b6fe8a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ##################################################### | |
| # COMMANDS | |
| # Commands are under "space space". | |
| # | |
| # Most commands may be run in a floating (f), down (j), or right (l) pane. | |
| # The "j" and "l" align with the movement keys (i.e. h,j,k,l). | |
| # | |
| # For example, to run a test under cursor in a pane below: | |
| # | |
| # "tab" = open command menu | |
| # "t" = test type menu | |
| # "l" = test line | |
| # "j" = run in pane "down" | |
| # | |
| # If a pane already exists in the desired position, it will be run there. | |
| # If no pane exists in the desired position, one will be created and run there. | |
| # Any "new" pane will always be set to close on exit. Commands run in an | |
| # existing pane will only close on exit if the pane was originally set to | |
| # close on exit. | |
| # | |
| # Commands run in floating windows will always be set to close on exit. | |
| # | |
| # The run.sh command is a thin wrapper around the `wezterm cli` commands. | |
| # It provides the "move to or create" pane functionality and passes the | |
| # arguments along. | |
| ###################################################### | |
| # Rerun - "tab" for "rerun" (double tap) | |
| # Rerun last command executed | |
| ################################################## | |
| [keys.normal.space.space] | |
| "ret" = ":sh ~/.config/helix/rerun.sh" | |
| # Search and Replace - "s" for "search and replace" | |
| ################################################## | |
| [keys.normal.space.",".s] | |
| i = ":sh ~/.config/helix/run.sh --in-place --close-on-exit -- scooter --no-stdin" | |
| f = ":sh ~/.config/helix/run.sh --floating --close-on-exit -- scooter --no-stdin" | |
| j = ":sh ~/.config/helix/run.sh --direction down --close-on-exit -- scooter --no-stdin" | |
| l = ":sh ~/.config/helix/run.sh --direction right --close-on-exit -- scooter --no-stdin" | |
| # Tests - "t" for "test" | |
| ################################################## | |
| # Test at line - "l" for "line" | |
| [keys.normal.space.t.l] | |
| i = ":sh ~/.config/helix/run.sh --in-place -- ~/.config/helix/go_test_at_line.sh %{buffer_name}:%{cursor_line}" | |
| f = ":sh ~/.config/helix/run.sh --floating -- ~/.config/helix/go_test_at_line.sh %{buffer_name}:%{cursor_line}" | |
| j = ":sh ~/.config/helix/run.sh --direction down -- ~/.config/helix/go_test_at_line.sh %{buffer_name}:%{cursor_line}" | |
| l = ":sh ~/.config/helix/run.sh --direction right -- ~/.config/helix/go_test_at_line.sh %{buffer_name}:%{cursor_line}" | |
| # Test file - "f" for "file" | |
| [keys.normal.space.t.f] | |
| i = ":sh ~/.config/helix/run.sh --in-place -- ~/.config/helix/go_test_file.sh %{buffer_name}" | |
| f = ":sh ~/.config/helix/run.sh --floating -- ~/.config/helix/go_test_file.sh %{buffer_name}" | |
| j = ":sh ~/.config/helix/run.sh --direction down -- ~/.config/helix/go_test_file.sh %{buffer_name}" | |
| l = ":sh ~/.config/helix/run.sh --direction right -- ~/.config/helix/go_test_file.sh %{buffer_name}" | |
| # Test package - "p" for "package" | |
| [keys.normal.space.t.p] | |
| i = ":sh ~/.config/helix/run.sh --in-place -- ~/.config/helix/go_test_package.sh %{buffer_name}" | |
| f = ":sh ~/.config/helix/run.sh --floating -- ~/.config/helix/go_test_package.sh %{buffer_name}" | |
| j = ":sh ~/.config/helix/run.sh --direction down -- ~/.config/helix/go_test_package.sh %{buffer_name}" | |
| l = ":sh ~/.config/helix/run.sh --direction right -- ~/.config/helix/go_test_package.sh %{buffer_name}" | |
| # Test suite - "s" for "suite" | |
| [keys.normal.space.t.s] | |
| i = ":sh ~/.config/helix/run.sh --in-place -- ~/.config/helix/go_test_suite.sh %{buffer_name}" | |
| f = ":sh ~/.config/helix/run.sh --floating -- ~/.config/helix/go_test_suite.sh %{buffer_name}" | |
| j = ":sh ~/.config/helix/run.sh --direction down -- ~/.config/helix/go_test_suite.sh %{buffer_name}" | |
| l = ":sh ~/.config/helix/run.sh --direction right -- ~/.config/helix/go_test_suite.sh %{buffer_name}" | |
| # Git - "g" for "git" | |
| ################################################## | |
| # Lazygit - "g" for "git" (double tap) | |
| [keys.normal.space.space.g] | |
| i = ":sh ~/.config/helix/run.sh --in-place --close-on-exit -- lazygit" | |
| f = ":sh ~/.config/helix/run.sh --floating --close-on-exit -- lazygit" | |
| j = ":sh ~/.config/helix/run.sh --direction down --close-on-exit -- lazygit" | |
| l = ":sh ~/.config/helix/run.sh --direction right --close-on-exit -- lazygit" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Wrapper around wezterm cli that adds move-or-create behavior for directional panes | |
| # Usage: run.sh [OPTIONS] -- <command> [args...] | |
| # | |
| # Key options: | |
| # --floating Open in a new window (wezterm equivalent of floating) | |
| # --direction <dir> Open in direction (up, down, left, right) | |
| # --close-on-exit Close pane when command exits (for new panes only) | |
| # --in-place Run in current pane | |
| # --cwd <path> Set working directory | |
| # | |
| # For --direction, will reuse existing pane if one exists in that direction, | |
| # otherwise creates a new pane. | |
| # | |
| # Caches the last command per-directory for rerun functionality. | |
| set -e | |
| # Cache the command for rerun functionality | |
| CACHE_DIR="/tmp/helix_last_command_$USER" | |
| mkdir -p "$CACHE_DIR" | |
| # Use PWD hash for per-directory caching (portable across macOS and Linux) | |
| if command -v md5sum &> /dev/null; then | |
| PWD_HASH=$(echo -n "$PWD" | md5sum | cut -d' ' -f1) | |
| elif command -v md5 &> /dev/null; then | |
| PWD_HASH=$(echo -n "$PWD" | md5) | |
| else | |
| # Fallback: use base64-encoded path (less elegant but works everywhere) | |
| PWD_HASH=$(echo -n "$PWD" | base64 | tr -d '=\n' | tr '/' '_') | |
| fi | |
| CACHE_FILE="$CACHE_DIR/$PWD_HASH" | |
| # Save all args and PWD to cache file | |
| cache_command() { | |
| { | |
| echo "PWD=$PWD" | |
| echo -n "ARGS=(" | |
| printf '%q ' "$@" | |
| echo ")" | |
| } > "$CACHE_FILE" | |
| } | |
| # Cache the command with all original arguments | |
| cache_command "$@" | |
| # Parse args to find --floating, --in-place, or --direction | |
| is_floating=false | |
| is_in_place=false | |
| direction="" | |
| remaining_args=() | |
| while [ "$#" -gt 0 ]; do | |
| case "$1" in | |
| --floating|-f) | |
| is_floating=true | |
| remaining_args+=("$1") | |
| shift | |
| ;; | |
| --in-place) | |
| is_in_place=true | |
| remaining_args+=("$1") | |
| shift | |
| ;; | |
| --direction|-d) | |
| direction="$2" | |
| remaining_args+=("$1" "$2") | |
| shift 2 | |
| ;; | |
| *) | |
| remaining_args+=("$1") | |
| shift | |
| ;; | |
| esac | |
| done | |
| # For in-place, run command in current pane using bash -c | |
| if [ "$is_in_place" = true ]; then | |
| # Find the command after "--" | |
| found_separator=false | |
| command_parts=() | |
| for arg in "${remaining_args[@]}"; do | |
| if [ "$found_separator" = true ]; then | |
| command_parts+=("$arg") | |
| elif [ "$arg" = "--" ]; then | |
| found_separator=true | |
| fi | |
| done | |
| command_str="${command_parts[*]}" | |
| cd "$PWD" | |
| exec bash -c "$command_str" | |
| fi | |
| # For floating, spawn in a new window (wezterm's equivalent of floating) | |
| if [ "$is_floating" = true ]; then | |
| # Remove --floating and --close-on-exit flags for wezterm | |
| final_args=() | |
| for arg in "${remaining_args[@]}"; do | |
| if [ "$arg" != "--floating" ] && [ "$arg" != "-f" ] && [ "$arg" != "--close-on-exit" ]; then | |
| final_args+=("$arg") | |
| fi | |
| done | |
| # Find the command after "--" | |
| found_separator=false | |
| command_parts=() | |
| for arg in "${final_args[@]}"; do | |
| if [ "$found_separator" = true ]; then | |
| command_parts+=("$arg") | |
| elif [ "$arg" = "--" ]; then | |
| found_separator=true | |
| fi | |
| done | |
| command_str="${command_parts[*]}" | |
| # Spawn new window with default shell, then send command | |
| new_pane_id=$(wezterm cli spawn --new-window --cwd "$PWD") | |
| sleep 0.1 | |
| wezterm cli send-text --pane-id "$new_pane_id" --no-paste "cd '$PWD' && $command_str"$'\n' | |
| exit 0 | |
| fi | |
| # If no direction specified, spawn in current tab | |
| if [ -z "$direction" ]; then | |
| # Find the command after "--" | |
| found_separator=false | |
| command_parts=() | |
| for arg in "${remaining_args[@]}"; do | |
| if [ "$found_separator" = true ]; then | |
| command_parts+=("$arg") | |
| elif [ "$arg" = "--" ]; then | |
| found_separator=true | |
| fi | |
| done | |
| command_str="${command_parts[*]}" | |
| # Spawn new tab with default shell, then send command | |
| new_pane_id=$(wezterm cli spawn --cwd "$PWD") | |
| sleep 0.1 | |
| wezterm cli send-text --pane-id "$new_pane_id" --no-paste "cd '$PWD' && $command_str"$'\n' | |
| exit 0 | |
| fi | |
| # For directional targets, implement move-or-create behavior | |
| # Map direction to Wezterm format | |
| case "$direction" in | |
| up) wezterm_direction="Up"; split_flag="--top" ;; | |
| down) wezterm_direction="Down"; split_flag="--bottom" ;; | |
| left) wezterm_direction="Left"; split_flag="--left" ;; | |
| right) wezterm_direction="Right"; split_flag="--right" ;; | |
| esac | |
| # Check if a pane exists in the specified direction | |
| existing_pane=$(wezterm cli get-pane-direction "$wezterm_direction" 2>/dev/null || echo "") | |
| # Remove --direction, --close-on-exit from remaining_args | |
| final_args=() | |
| skip_next=false | |
| for arg in "${remaining_args[@]}"; do | |
| if [ "$skip_next" = true ]; then | |
| skip_next=false | |
| continue | |
| fi | |
| if [ "$arg" = "--direction" ] || [ "$arg" = "-d" ]; then | |
| skip_next=true | |
| continue | |
| fi | |
| if [ "$arg" = "--close-on-exit" ]; then | |
| continue | |
| fi | |
| final_args+=("$arg") | |
| done | |
| # Find the command after "--" | |
| found_separator=false | |
| command_parts=() | |
| for arg in "${final_args[@]}"; do | |
| if [ "$found_separator" = true ]; then | |
| command_parts+=("$arg") | |
| elif [ "$arg" = "--" ]; then | |
| found_separator=true | |
| fi | |
| done | |
| command_str="${command_parts[*]}" | |
| if [ -n "$existing_pane" ]; then | |
| # Existing pane - send command directly to it by pane ID | |
| wezterm cli send-text --pane-id "$existing_pane" --no-paste "cd '$PWD' && $command_str"$'\n' | |
| # Optionally activate it so user can see the output | |
| wezterm cli activate-pane-direction "$wezterm_direction" | |
| else | |
| # No pane exists - create new one with default shell, then send command | |
| # Note: --percent doesn't work reliably over SSH domains, just use default 50% split without --top-level | |
| new_pane_id=$(wezterm cli split-pane "$split_flag" --cwd "$PWD") | |
| # Give the shell a moment to start | |
| sleep 0.1 | |
| # Send the command to the new pane | |
| wezterm cli send-text --pane-id "$new_pane_id" --no-paste "cd '$PWD' && $command_str"$'\n' | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Generic wrapper to run a command in a terminal pane in a specific direction | |
| # Usage: run_in_terminal_pane.sh <direction> <command> [args...] | |
| # Direction: up, down, left, right | |
| # If a pane exists in that direction, use it; otherwise create a new one | |
| set -e | |
| # Check if direction argument was provided (new behavior) | |
| # If not, default to "down" for backward compatibility | |
| if [[ "$1" =~ ^(up|down|left|right)$ ]]; then | |
| direction="$1" | |
| shift | |
| else | |
| # Backward compatibility: if first arg isn't a direction, assume "down" | |
| direction="down" | |
| fi | |
| HELIX_CWD="$(pwd)" | |
| full_command="$@" | |
| # Map Helix directions to Wezterm directions | |
| case "$direction" in | |
| up) wezterm_direction="Up" ;; | |
| down) wezterm_direction="Down" ;; | |
| left) wezterm_direction="Left" ;; | |
| right) wezterm_direction="Right" ;; | |
| esac | |
| # Check if a pane exists in the specified direction | |
| existing_pane=$(wezterm cli get-pane-direction "$wezterm_direction" 2>/dev/null || echo "") | |
| if [ -z "$existing_pane" ]; then | |
| # No pane exists, create a new one with default shell, then send command | |
| # Map direction to split-pane flags | |
| case "$direction" in | |
| up) split_flag="--top" ;; | |
| down) split_flag="--bottom" ;; | |
| left) split_flag="--left" ;; | |
| right) split_flag="--right" ;; | |
| esac | |
| new_pane_id=$(wezterm cli split-pane "$split_flag" --cwd "$HELIX_CWD") | |
| sleep 0.1 | |
| wezterm cli send-text --pane-id "$new_pane_id" --no-paste "cd '$HELIX_CWD' && $full_command"$'\n' | |
| else | |
| # Pane exists, activate it and send the command | |
| wezterm cli activate-pane-direction "$wezterm_direction" | |
| wezterm cli send-text --no-paste "cd '$HELIX_CWD' && $full_command"$'\n' | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Generic wrapper to run any command in a wezterm floating window | |
| # Usage: run_in_floating_pane.sh <command> [args...] | |
| # Note: Wezterm doesn't have floating panes, so we use a new window instead | |
| HELIX_CWD="$(pwd)" | |
| # Build the full command to run | |
| full_command="$@" | |
| # Use wezterm to spawn in a new window with default shell, then send command | |
| # This is the closest equivalent to Zellij's floating pane | |
| new_pane_id=$(wezterm cli spawn --new-window --cwd "$HELIX_CWD") | |
| sleep 0.1 | |
| wezterm cli send-text --pane-id "$new_pane_id" --no-paste "cd '$HELIX_CWD' && $full_command"$'\n' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Reruns the last command executed via run.sh in the current directory | |
| # Shows an error message if no previous command exists | |
| set -e | |
| # Find the cached command for this directory | |
| CACHE_DIR="/tmp/helix_last_command_$USER" | |
| # Use same hash logic as run.sh (portable across macOS and Linux) | |
| if command -v md5sum &> /dev/null; then | |
| PWD_HASH=$(echo -n "$PWD" | md5sum | cut -d' ' -f1) | |
| elif command -v md5 &> /dev/null; then | |
| PWD_HASH=$(echo -n "$PWD" | md5) | |
| else | |
| # Fallback: use base64-encoded path (less elegant but works everywhere) | |
| PWD_HASH=$(echo -n "$PWD" | base64 | tr -d '=\n' | tr '/' '_') | |
| fi | |
| CACHE_FILE="$CACHE_DIR/$PWD_HASH" | |
| # Check if cache file exists | |
| if [ ! -f "$CACHE_FILE" ]; then | |
| echo "No previous command to rerun in this directory" >&2 | |
| exit 1 | |
| fi | |
| # Source the cache file to get PWD and ARGS as an array | |
| source "$CACHE_FILE" | |
| # Change to the cached directory and re-execute run.sh | |
| cd "$PWD" | |
| # Re-execute run.sh with the cached arguments (ARGS is now an array) | |
| exec "$(dirname "$0")/run.sh" "${ARGS[@]}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| # Usage: go_test_package.sh <file> | |
| # Runs all tests in the package containing the file | |
| input="${1:-}" | |
| if [[ -z "$input" ]]; then | |
| echo "Error: No file provided" | |
| exit 1 | |
| fi | |
| # Validate file exists | |
| if [[ ! -f "$input" ]]; then | |
| echo "Error: File not found: $input" | |
| exit 1 | |
| fi | |
| # Get the directory of the file (the package directory) | |
| package_dir=$(dirname "$input") | |
| # Change to the package directory and run all tests | |
| cd "$package_dir" | |
| # Run all tests in the package with gotestsum testdox format | |
| # Always exit 0 so Helix shows the output even on test failures | |
| gotestsum --format testdox || true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment