mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-07 18:21:16 -03:00
Allow restricting abbreviations to specific commands (#10452)
This allows making something like ```fish abbr --add gc --position anywhere --command git back 'reset --hard HEAD^' ``` to expand "gc" to "reset --hard HEAD^", but only if the command is git (including "command git gc" or "and git gc"). Fixes #9411
This commit is contained in:
@@ -157,3 +157,29 @@ sendline(r"""abbr LLL --position anywhere --set-cursor=!HERE! '!HERE! | less'"""
|
||||
expect_prompt()
|
||||
send(r"""echo LLL derp?""")
|
||||
expect_str(r"<echo derp | less >")
|
||||
|
||||
sendline(r"""abbr foo --command echo bar""")
|
||||
expect_prompt()
|
||||
sendline(r"""printf '%s\n' foo """)
|
||||
expect_prompt("foo")
|
||||
sendline(r"""echo foo """)
|
||||
expect_prompt("bar")
|
||||
sendline(r"""true; and echo foo """)
|
||||
expect_prompt("bar")
|
||||
sendline(r"""true; and builtin echo foo """)
|
||||
expect_prompt("bar")
|
||||
sendline(r"""abbr fruit --command={git,hg,svn} banana""")
|
||||
expect_prompt()
|
||||
sendline(r"""function git; echo git $argv; end; function hg; echo hg $argv; end; function svn; echo svn $argv; end""")
|
||||
expect_prompt()
|
||||
sendline(r"""git fruit""")
|
||||
expect_prompt("git banana")
|
||||
sendline(r"""abbr""")
|
||||
expect_prompt("abbr -a --position anywhere --command git --command hg --command svn -- fruit banana")
|
||||
sendline(r"""function banana; echo I am a banana; end""")
|
||||
expect_prompt()
|
||||
sendline(r"""abbr fruit --command={git,hg,svn,} banana""")
|
||||
expect_prompt()
|
||||
sendline(r"""fruit foo""")
|
||||
expect_prompt("I am a banana")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user