dc97892a29
C1 shadows (rm, cat, ls, less, du, bash, top, ping, ssh, rg, mkdir, help) fall back to the bare command when __fish_config_op_aliases is falsy; rm falls back to exact 'command rm' with no wrapper. C2 gates the auto-venv PWD hook. C3 gates smart_exit (composing with Task #4 logging), fish_right_prompt, and all six expand_bang_*/expand_typo_sub functions atomically with the bang-bang system. C4 integration commands (spwin, tab, split, hist, logs, upgrade) refuse with a colored stderr error when disabled. config.fish now also strips the CachyOS distro config's own bang-bang bindings, history override, and alias opinions per category, restoring fish stock functions where they exist.
28 lines
834 B
Fish
28 lines
834 B
Fish
# Execute expand_bang_string
|
|
function expand_bang_string --description 'Execute expand_bang_string'
|
|
# Opinionated guard (C3): no expansion when overrides are disabled.
|
|
__fish_config_op_enabled __fish_config_op_overrides; or return 1
|
|
|
|
# Fish 4.x passes the matched token as argv[1]
|
|
set -l token $argv[1]
|
|
if test -z "$token"
|
|
set token (commandline -t)
|
|
end
|
|
|
|
# Remove the '!' to get the search query
|
|
set -l query (string sub -s 2 -- $token)
|
|
|
|
if test -n "$query"
|
|
# Search history for a prefix match
|
|
set -l match (builtin history search --prefix --max=1 -- $query)
|
|
|
|
if test -n "$match"
|
|
echo -- $match
|
|
return
|
|
end
|
|
end
|
|
|
|
# If no match or empty query, return the token so it doesn't vanish
|
|
echo -- $token
|
|
end
|