mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-08-27 03:42:49 +00:00
zsh completion; Fix leading ~ in filenames being quoted on insertion into commandline
This commit is contained in:
parent
035c3de4bb
commit
c83a8b0773
2 changed files with 26 additions and 2 deletions
|
|
@ -24,3 +24,18 @@ func QuoteStringForFish(x string) string {
|
|||
x = strings.ReplaceAll(x, "'", "\\'")
|
||||
return "'" + x + "'"
|
||||
}
|
||||
|
||||
// Escapes common shell meta characters
|
||||
func EscapeSHMetaCharacters(x string) string {
|
||||
const metachars = "\\|&;<>()$'\" \n\t"
|
||||
ans := strings.Builder{}
|
||||
ans.Grow(len(x) + 32)
|
||||
for _, ch := range x {
|
||||
switch ch {
|
||||
case '\\', '|', '&', ';', '<', '>', '(', ')', '$', '\'', '"', ' ', '\n', '\t':
|
||||
ans.WriteRune('\\')
|
||||
}
|
||||
ans.WriteRune(ch)
|
||||
}
|
||||
return ans.String()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue