function try_subst # Use s/word/replacement to replace word with replacement # in last command commandline | read -l saved_commandline set -l pattern '^s/..*/.*$' if commandline -t | grep -E -q "$pattern" commandline -tr (echo -n "$history[1]" | sed -e (commandline -t)/g) else commandline -f complete end end