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
1.1 KiB
Fish
28 lines
1.1 KiB
Fish
# Execute expand_typo_sub
|
|
function expand_typo_sub --description 'Execute expand_typo_sub'
|
|
# Opinionated guard (C3): no expansion when overrides are disabled.
|
|
__fish_config_op_enabled __fish_config_op_overrides; or return 1
|
|
|
|
# In newer Fish, the matched token is often passed as $argv[1]
|
|
# if the abbr is set up correctly. We'll fallback to commandline just in case.
|
|
set -l last_cmd $history[1]
|
|
set -l current_token $argv[1]
|
|
if test -z "$current_token"
|
|
set current_token (commandline -t)
|
|
end
|
|
|
|
if string match -qr '\^([^^]+)\^([^^]*)' -- "$current_token"
|
|
set -l captured (string match -r '\^([^^]+)\^([^^]*)' -- "$current_token")
|
|
set -l old $captured[2]
|
|
set -l new $captured[3]
|
|
|
|
if test -n "$old"
|
|
# Using -- to ensure strings starting with '-' aren't treated as flags
|
|
echo -- (string replace -a -- "$old" "$new" "$last_cmd")
|
|
end
|
|
else
|
|
# Return the token itself so it doesn't vanish
|
|
echo -- "$current_token"
|
|
end
|
|
end
|