Files
fish-config/functions/_smart_execute.fish
T
rootiest 1341e2559e docs(functions): standardize all function doc blocks to UNIX man-page style
Replace all ad-hoc inline comments between license headers and function
declarations with consistent SYNOPSIS / DESCRIPTION / ARGUMENTS / RETURNS /
EXAMPLE blocks across all 99 project-owned functions/ files. No executable
logic, variable names, or exit codes were modified.

Completes Task #6 from AGENTS.md (Retroactive Function Documentation
Standardization).
2026-06-05 20:18:49 -04:00

40 lines
1.1 KiB
Fish

# Copyright (C) 2026 Rootiest
# SPDX-License-Identifier: AGPL-3.0-or-later
# SYNOPSIS
# _smart_execute
#
# DESCRIPTION
# Bound to Enter, dispatches based on the current commandline buffer.
# Buffers ending in = are evaluated as qalc expressions via _qalc_eval.
# Empty buffers and all other input fall through to normal execution.
# Intended to be bound to a key in key_bindings.fish.
#
# EXAMPLE
# bind \r _smart_execute
function _smart_execute --description 'Execute different functions based on the command line content'
# Get the current command line buffer
set -l cmd (commandline)
# 1. Handle empty buffer (Standard Enter behavior)
if test -z "$cmd"
commandline -f execute
return
end
# 2. Dispatch based on buffer content
switch "$cmd"
case '*='
# If it ends in =, run qalc; fall back to normal execute if qalc is absent
_qalc_eval; or commandline -f execute
# case 'g *'
# # EXAMPLE FUTURE EXTENSION
# _some_git_helper
case '*'
# Default: execute the command line as-is
commandline -f execute
end
end