dotfiles/terminal/fish/functions/try_subst.fish
2017-10-15 20:50:00 +02:00

15 lines
341 B
Fish
Executable File

function try_subst
# Use s/word/replacement<tab> 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