mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
bash: remove quoted completions while sorting possible portability issue
This commit is contained in:
@ -37,7 +37,6 @@ fn writeBashCompletions(writer: anytype) !void {
|
||||
const pad4 = pad3 ++ pad1;
|
||||
|
||||
try writer.writeAll(
|
||||
\\
|
||||
\\# -o nospace requires we add back a space when a completion is finished
|
||||
\\# and not part of a --key= completion
|
||||
\\addSpaces() {
|
||||
@ -46,40 +45,6 @@ fn writeBashCompletions(writer: anytype) !void {
|
||||
\\ done
|
||||
\\}
|
||||
\\
|
||||
\\_fonts() {
|
||||
\\ local IFS=$'\n'
|
||||
\\ mapfile -t COMPREPLY < <( compgen -P '"' -S '"' -W "$($ghostty +list-fonts | grep '^[A-Z]' )" -- "$cur")
|
||||
\\}
|
||||
\\
|
||||
\\_themes() {
|
||||
\\ local IFS=$'\n'
|
||||
\\ mapfile -t COMPREPLY < <( compgen -P '"' -S '"' -W "$($ghostty +list-themes | sed -E 's/^(.*) \(.*$/\1/')" -- "$cur")
|
||||
\\}
|
||||
\\
|
||||
\\_files() {
|
||||
\\ mapfile -t COMPREPLY < <( compgen -o filenames -f -- "$cur" )
|
||||
\\ for i in "${!COMPREPLY[@]}"; do
|
||||
\\ if [[ -d "${COMPREPLY[i]}" ]]; then
|
||||
\\ COMPREPLY[i]="${COMPREPLY[i]}/";
|
||||
\\ fi
|
||||
\\ if [[ -f "${COMPREPLY[i]}" ]]; then
|
||||
\\ COMPREPLY[i]="${COMPREPLY[i]} ";
|
||||
\\ fi
|
||||
\\ done
|
||||
\\}
|
||||
\\
|
||||
\\_dirs() {
|
||||
\\ mapfile -t COMPREPLY < <( compgen -o dirnames -d -- "$cur" )
|
||||
\\ for i in "${!COMPREPLY[@]}"; do
|
||||
\\ if [[ -d "${COMPREPLY[i]}" ]]; then
|
||||
\\ COMPREPLY[i]="${COMPREPLY[i]}/";
|
||||
\\ fi
|
||||
\\ done
|
||||
\\ if [[ "${#COMPREPLY[@]}" == 0 && -d "$cur" ]]; then
|
||||
\\ COMPREPLY=( "$cur " )
|
||||
\\ fi
|
||||
\\}
|
||||
\\
|
||||
\\config="--help"
|
||||
\\config+=" --version"
|
||||
\\
|
||||
@ -102,13 +67,13 @@ fn writeBashCompletions(writer: anytype) !void {
|
||||
try writer.writeAll(pad2 ++ "--" ++ field.name ++ ") ");
|
||||
|
||||
if (std.mem.startsWith(u8, field.name, "font-family"))
|
||||
try writer.writeAll("_fonts ;;")
|
||||
try writer.writeAll("return ;;")
|
||||
else if (std.mem.eql(u8, "theme", field.name))
|
||||
try writer.writeAll("_themes ;;")
|
||||
try writer.writeAll("return ;;")
|
||||
else if (std.mem.eql(u8, "working-directory", field.name))
|
||||
try writer.writeAll("_dirs ;;")
|
||||
try writer.writeAll("return ;;")
|
||||
else if (field.type == Config.RepeatablePath)
|
||||
try writer.writeAll("_files ;;")
|
||||
try writer.writeAll("return ;;")
|
||||
else {
|
||||
const compgenPrefix = "mapfile -t COMPREPLY < <( compgen -W \"";
|
||||
const compgenSuffix = "\" -- \"$cur\" ); addSpaces ;;";
|
||||
@ -218,7 +183,7 @@ fn writeBashCompletions(writer: anytype) !void {
|
||||
},
|
||||
else => {
|
||||
if (std.mem.eql(u8, "config-file", opt.name)) {
|
||||
try writer.writeAll("_files ;;");
|
||||
try writer.writeAll("return ;;");
|
||||
} else try writer.writeAll("return;;");
|
||||
},
|
||||
}
|
||||
@ -266,12 +231,6 @@ fn writeBashCompletions(writer: anytype) !void {
|
||||
\\ else prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
\\ fi
|
||||
\\
|
||||
\\ # current completion is double quoted add a space so the curor progresses
|
||||
\\ if [[ "$2" == \"*\" ]]; then
|
||||
\\ COMPREPLY=( "$cur " );
|
||||
\\ return;
|
||||
\\ fi
|
||||
\\
|
||||
\\ case "$COMP_CWORD" in
|
||||
\\ 1)
|
||||
\\ case "${COMP_WORDS[1]}" in
|
||||
@ -284,12 +243,6 @@ fn writeBashCompletions(writer: anytype) !void {
|
||||
\\ case "$prev" in
|
||||
\\ -e | --help | --version) return 0 ;;
|
||||
\\ *)
|
||||
\\ if [[ "=" != "${COMP_WORDS[COMP_CWORD]}" && $prevWasEq != true ]]; then
|
||||
\\ # must be completing with a space after the key eg: '--<key> '
|
||||
\\ # clear out prev so we don't run any of the key specific completions
|
||||
\\ prev=""
|
||||
\\ fi
|
||||
\\
|
||||
\\ case "${COMP_WORDS[1]}" in
|
||||
\\ --*) _handleConfig ;;
|
||||
\\ +*) _handleActions ;;
|
||||
|
Reference in New Issue
Block a user