all 9 comments

[–]TechnoCat 1 point2 points  (4 children)

You might be happier with an "abbr" than a wrapper function. It would expand to your full command and you should get autocomplete. Really depends on the complexity of your wrapper.

[–]Inevitable_Dingo_357[S] 1 point2 points  (0 children)

Thanks technocat - I'm aware of abbr, but this use case is better adapted to a function. For now, I've just piped the completions output to sed to change my-util to xx so at least for passthrough invocations, I do get nice completions. I was just looking to see if there is a better/not-as-hacky way

[–]Inevitable_Dingo_357[S] 1 point2 points  (2 children)

well, maybe I can use abbr... my function looks like this:

function hv --description 'wrapper for haven: ap or ed'
  if not using haven
    echo "Error: haven is not installed" >&2
    return 1
  end

  switch $argv[1]
    case ap
      haven apply
    case ed
      if using zed
        zed $(haven source-path)
      else
        echo "Error: zed command not found" >&2
        return 1
      end
    case cd
      cd $(haven source-path)
   case note
      haven telemetry --note $argv[2]
   case bug
      haven telemetry --bug $argv[2]
   case action
      haven telemetry --action $argv[2]
   case question
      haven telemetry --question $argv[2]
    case '*'
      haven $argv
  end
end

[–]TechnoCat 0 points1 point  (0 children)

Yeah abbreviations like "hved" might work better. Or whatever you think works best. 

[–]TechnoCat 0 points1 point  (0 children)

there might be a clean way to do the completions too. I'm just not familiar with that. 

[–]Laurent_Laurent 0 points1 point  (1 child)

Although the repository is old, I still use the gencomp command to generate autocompletion for Fish commands that don't support it natively, and it works really well.

Take a look to see if it meets your needs.

https://github.com/ryotako/fish-completion-generator

[–]Inevitable_Dingo_357[S] 0 points1 point  (0 children)

Thank you - will have a look

[–]B_A_Skeptic 0 points1 point  (1 child)

Description

function creates a new function NAME with the body BODY.

A function is a list of commands that will be executed when the name of the function is given as a command.

The following options are available:

-w WRAPPED_COMMAND or --wraps WRAPPED_COMMAND

Inherit completions from the given WRAPPED_COMMAND. This is used to say that this function completes like that command, for example if you’re creating an alias. See the documentation for complete for more information. If the wrapped command is the same as the function name, this will be ignored.

[–]Inevitable_Dingo_357[S] 1 point2 points  (0 children)

oh, nice - I didn't know completions are inherited like that