mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
git completions: Fix aliases with weird characters
A use for the new `string escape --style=var`. Fixes #4147.
This commit is contained in:
parent
db529f06b8
commit
3b5fdc3fb0
1 changed files with 3 additions and 2 deletions
|
@ -144,7 +144,8 @@ end
|
||||||
# This is because alias:command is an n:1 mapping (an alias can only have one corresponding command,
|
# This is because alias:command is an n:1 mapping (an alias can only have one corresponding command,
|
||||||
# but a command can be aliased multiple times)
|
# but a command can be aliased multiple times)
|
||||||
git config -z --get-regexp 'alias\..*' | while read -lz alias command _
|
git config -z --get-regexp 'alias\..*' | while read -lz alias command _
|
||||||
set alias (string replace 'alias.' '' -- $alias)
|
# Git aliases can contain chars that variable names can't - escape them.
|
||||||
|
set alias (string replace 'alias.' '' -- $alias | string escape --style=var)
|
||||||
set -g __fish_git_alias_$alias $command
|
set -g __fish_git_alias_$alias $command
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -156,7 +157,7 @@ function __fish_git_using_command
|
||||||
and return 0
|
and return 0
|
||||||
|
|
||||||
# Check aliases.
|
# Check aliases.
|
||||||
set -l varname __fish_git_alias_$cmd
|
set -l varname __fish_git_alias_(string escape --style=var -- $cmd)
|
||||||
contains -- "$$varname" $argv
|
contains -- "$$varname" $argv
|
||||||
and return 0
|
and return 0
|
||||||
return 1
|
return 1
|
||||||
|
|
Loading…
Reference in a new issue