fig
fig copied to clipboard
Add a way to replace input with new command
The current solution to this is to prefix insertValue with as many \b as necessary, or to create a utility function that does this.
const replace = (cmd: string) => "\b".repeat(40) + cmd;
// ...
subcommands: [
{
name: "My shortcut",
insertValue: replace("cd ~/.fig/autocomplete; npm run dev\n")
}
]
This is really easy to forget by accident. It could easily be handled by Fig, with something like a replaceCommand prop.
subcommands: [
{
name: "My shortcut",
replaceCommand: "cd ~/.fig/autocomplete; npm run dev\n"
}
]
I think this should be lower priority than insertValue if they can't be exclusive.
Order: insertValue → replaceCommand → name
@fedeci @mschrage thoughts?
It doesn't sound bad to me! Let's wait for @mschrage feedback.
Sorry I missed this. I like this API, if you want to add support for this @fedeci.
I'm not sure if this is worth opening a separate issue but the \b shortcut seems to be ignored when used in template literals ``. Which even seems unofficially recognized in the docs https://fig.io/docs/guides/personal-shortcuts#create-some-shortcuts
@joeyparis hmmm if \b is ignored then that's definitely a bug - JS treats it as an escape code for the backspace character (0x8). Could you open up a new issue and include your spec? I'll follow up there 🙂
@SeparateRecords absolutely!
Related #1615, I'm pretty against adding a new property to autocomplete now that we have workflows.
@fedeci replaceValue is necessary for functionality we want to enable for Mixins.
I was trying to make a mixin that runs a workflow. eg. I type "git" and it'll show a suggestion called "Create new feature branch", that just triggers a workflow