mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
edit_command_buffer: also detect aliases with arguments
For example complete my-vim --wraps 'vim -x'
This commit is contained in:
parent
3f6b009870
commit
5fa743337c
1 changed files with 9 additions and 4 deletions
|
@ -30,11 +30,16 @@ function edit_command_buffer --description 'Edit the command buffer in an extern
|
|||
end
|
||||
set col (math $offset + 1)
|
||||
|
||||
set -l basename (string match -r '[^/]+$' -- $editor[1])
|
||||
set -l wrap_targets (complete -- $basename | string replace -rf '^complete [^/]+ --wraps (.+)$' '$1')
|
||||
set -l editor_basename (string match -r '[^/]+$' -- $editor[1])
|
||||
set -l wrapped_commands
|
||||
for wrap_target in (complete -- $editor_basename | string replace -rf '^complete [^/]+ --wraps (.+)$' '$1')
|
||||
set -l tmp
|
||||
string unescape -- $wrap_target | read -at tmp
|
||||
set -a wrapped_commands $tmp[1]
|
||||
end
|
||||
set -l found false
|
||||
for alias in $basename $wrap_targets
|
||||
switch $alias
|
||||
for editor_command in $editor_basename $wrapped_commands
|
||||
switch $editor_command
|
||||
case vi vim nvim
|
||||
set -a editor +$line +"norm! $col|" $f
|
||||
case emacs emacsclient gedit kak
|
||||
|
|
Loading…
Reference in a new issue