Coder Social home page Coder Social logo

withfig / autocomplete Goto Github PK

View Code? Open in Web Editor NEW
24.3K 87.0 5.4K 27.6 MB

IDE-style autocomplete for your existing terminal & shell

Home Page: https://fig.io

License: MIT License

JavaScript 0.01% Shell 0.01% TypeScript 100.00% Dockerfile 0.01%
autocomplete terminal shell macos zsh bash fish iterm2 cli typescript

autocomplete's Introduction

Fig logo Fig logo


Badge: macOS Badge: Sign up (public beta) Badge: Documentation Badge: contributors Badge: Join the Discord server Badge: Follow on Twitter

Fig makes the command line easier for individuals and more collaborative for teams.

Our most popular product is Autocomplete. As you type, Fig pops up subcommands, options, and contextually relevant arguments in your existing terminal.

⚡️ Installation

NOTE: Once it's downloaded, launch the app to set up Fig!


Demo of Fig's visual autocomplete in a terminal


👋 What are "completion specs"?

A completion spec is a declarative schema that specifies the subcommands, options and args for a CLI tool. Fig uses these schemas to generate suggestions.


😎 Contribute your first spec in < 3 minutes

Use the steps below or follow our getting started guide: fig.io/docs

Prerequisites:

  • Download Fig for macOS
  • Node and Pnpm

Steps

  1. Make sure you have pnpm installed, as that's the package manager used in this repo.

  2. Click here to fork this repo.

  3. Clone your forked repo and create an example spec

    # Replace `YOUR_GITHUB_USERNAME` with your own GitHub username
    git clone https://github.com/YOUR_GITHUB_USERNAME/autocomplete.git fig-autocomplete
    cd fig-autocomplete
    
    # Add withfig/autocomplete as a remote
    git remote add upstream https://github.com/withfig/autocomplete.git
    
    # Install packages
    pnpm install
    
    # Create an example spec (call it "abc")
    pnpm create-spec abc
    
    # Turn on "dev mode"
    pnpm dev
  4. Now go to your terminal and type abc[space]. Your example spec will appear. 😊

Other things to know

  • Edit your spec in TypeScript in the src/ folder
  • On save, specs are compiled to the build/ folder
  • In dev mode, specs are read from the build folder, and generators run every keystroke.

🪄 Add AI to completions

You can use Fig's autocomplete for your own tools too. Here's how to create private completions:

import { ai } from "@fig/autocomplete-generators"

...

generators: [
  ai({
    // the prompt
    prompt: "Generate a git commit message",
    
    // Send any relevant local context.
    message: async ({ executeShellCommand }) => {
      return executeShellCommand("git diff")
    },
    
    // turn each newline into a suggestion (can specify instead a `postProcess1 function if more flexibility is required)
    splitOn: "\n",
  })
]

📦 Other available package.json commands

# Typecheck all specs in the src/ folder
pnpm test

# Compile typescripts specs from src/ folder to build/ folder
pnpm build

# Lint and fix issues
pnpm lint:fix

🔥 Contributions

We would love contributions for:

  • new completion specs
  • errors with existing completion specs (e.g. missing subcommands, options, or arguments)
  • generators for argument suggestions
  • better descriptions, icons etc
  • themes!

If you aren't able to contribute, please feel free to open an issue.

😊 Need Help?

Join our community
Discord logo

🧑‍💻 Teams / Enterprise

Want to use Fig to add autocomplete internal CLI tools? Or want to use Fig at work but have security / compliance concerns?

We would love to help get you set up. Please email [email protected]

🙋‍♀️ FAQ

What terminals does Fig work with?

Fig works with the native macOS Terminal app, iTerm, Tabby, Hyper, Kitty, WezTerm, and Alacritty. It also works in the integrated terminals of VSCode, JetBrains IDEs, Android Studio, and Nova.

Want to see another terminal included? Check our issue tracker and add your support for it!

How does Fig work?

Fig uses the Accessibility API on Mac to position the window, and integrates with your shell to read what you've typed.

Does Fig work on Windows or Linux?

Not yet, Fig is only available on macOS for now. Windows and Linux support is in progress!

How can I download Fig?

Run brew install fig or, downloading the app at fig.io/download. Then, launch the Fig app!

Can I use Fig to build autocomplete for my team's internal scripts and CLI tools?

Yes! Check out our guide on how to get started building autocomplete specs.

How do I submit a PR?

Check out our How to Contribute guide. Many of Fig's 200+ contributors made their first open source contribution to Fig!

Fig doesn't work for me!

Join the Discord server and we'll debug it. Fixing Fig in your setup will fix it for other people too! 🙂

Did we miss something?

Get in touch at [email protected] or chat with us on Discord.


✨ Contributors

Grid of profile icons of the 200+ contributors

autocomplete's People

Contributors

a7medev avatar ankithm28 avatar bogdaaamn avatar brendanfalk avatar clo4 avatar cstrnt avatar dannyaziz avatar dependabot[bot] avatar fedeci avatar fig-io avatar fwesss avatar geenva avatar gh-action-bump-version avatar grant0417 avatar jubeki avatar kailan avatar lsh avatar mamercad avatar mrhappyma avatar mschrage avatar nmassardot avatar nutlope avatar quiibz avatar rmorey avatar rolandtshen avatar sullivan-sean avatar whobutsb avatar withfig-bot avatar yavko avatar zeko369 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

autocomplete's Issues

Create Boilerplate not working

Just following the instruction works until npm run dev. The npm run create-boilerplate says there isn't a script with that name.

Subcommands should inherit the icon property

Completion Spec

What completion spec does this enhancement refer to? Or is it Fig itself?
Fig itself

Description

When assigning a root command an icon the subcommands (and sub-subcommands) also need to define the same icon property in order to have the same icon.

Describe the issue that you're seeing.

Steps to reproduce

  1. Create a spec
  2. add icon property at root level
  3. add subcommand
  4. subcommand doesn't show the icon

Expected result

The icon should be inherited

Actual result

It is not inherited

Introduce an complete-on-demand option in addition to autocomplete

Completion Spec

Fig itself

Description

whenever I use a shell command supported by fig (e.g. git) autocomplete strikes immediately sometimes interrupting my thought process.

Steps to reproduce

core behavior

Expected result

An option to summon the completion suggestions on demand would be great
(Like hitting the TAB key in a standard shell)

Actual result

autocomplete always strikes

Suggestion window height is constant for git and ssh

Description:

I set the height to 1000 and the window size is now constant rather than form-fitting for git and ssh. It does form-fit for fig.
Screen Shot 2021-04-21 at 8 36 50 AM

Details:

macOS Fig Shell
10.16.0 Version 1.0.40 (B188) /bin/zsh
fig diagnostic

Version 1.0.40 (B188)
UserShell: /bin/zsh
Bundle path: /Applications/Fig.app
Autocomplete: true
Settings.json: true
CLI installed: true
CLI tool path: /Users/carlowan/.fig/bin/fig
Accessibility: true
Number of specs: 77
SSH Integration: true
Tmux Integration: true
Keybindings path: /Users/carlowan/.fig/user/keybindings
iTerm Integration: true
Hyper Integration: false
VSCode Integration: true
Docker Integration: false
Symlinked dotfiles: false
Only insert on tab: false
Installation Script: true
PseudoTerminal Path: 
SecureKeyboardInput: false
SecureKeyboardProcess: 
Current active process: /bin/zsh (96635) - ttys001
Current working directory: /Users/carlowan
Current window identifier: 36075/1C2C1D59C-338A-42CB-B136-F3FCF145C696% (com.googlecode.iterm2)

Autocomplete over all the aliases and CLI tools

Right now, autocomplete only works from the second command. It would be nice to get autocomplete right from first command.

Usecase:
If I have following aliases:

g=git
ga='git add'
gaa='git add --all'
gap='git apply'
gapa='git add --patch'
gau='git add --update'
gav='git add --verbose'
gb='git branch'

When I type g, I should be able to get autocomplete for all these aliases.
It would be even better if we are also able to see the related expansion of the aliases in the autocomplete itself. Something like g(git), ga(git add), ....

Fuzzy search for zsh

Completion Spec

Enhancement to fig's overall autocompletion. It's not mission-critical but since I'm so used to how zsh's autocomplete works, I feel like it should at least be put up for consideration.

Description

For zsh the tabbed autocomplete uses a fuzzy search, instead of fig's current substr-style.

Steps to reproduce

Using oh-my-zsh, go to a folder. For example containing the following:

~ ls
project-name-one
project-name-two
~ cd two

Expected result

If you now press "tab", it will auto-complete to project-name-two

Actual result

In this scenario, Fig would show no available autocompletions

Fig inserts filename with incorrect case when using `git reset`

I was working with bundler and git. I wanted to git revert changes to our Gemfile. I kept tab completing to get to the file, but when I was done, the filename changed from Gemfile to gemfile and I would have to go back and manually fix it on my own.

[sed] request for spec

CLI Tool

sed

Useful Links

https://www.gnu.org/software/sed/manual/sed.html

Top Workflows

What are the most used commands or workflows in that CLI tool (for you)?

Generally just text management and formatting! I use Obsidian for my notes, so all of my work is in text files and I would love an easier way to write commands for sed!

`cp` (and potentially other commands like `mv`) should accept both files and folders for destination argument

Completion Spec

cp

Description

I want to copy a file to a folder (eg. cp ~/path/to/file ~/path/to/another/folder) which is valid - however the second argument of the cp completion spec seems to only accept a filepath. The red arrow that allows me to run the command immediately does not appear.

System Information

Fig Version: 1.0.39

OS: 10.15.7 (19H2)

Device: MacBook Pro

Potential Solution

Add folder to templates in completion spec.

Descriptions show in a tooltip or some other method to see completely instead of side scrolling.

Completion Spec

Any spec that has a long description.

Description

A long description for a command or sub-command in a spec can be very long when they are gathered from an outside source (Mask descriptions for commands). For me, the side scrolling to view the entire description is a bit difficult to maneuver.

Steps to reproduce

look at a description for and command that is long and you have to side scroll to see it all

`expo web` command not recognized

expo web is an unrecognized alias for expo start:web

Matt tells me it should be a simple fix: just finding the start:web subcommand and then convert the name property from a string to an array ("start:web" → ["start:web", "web"])!

[git] git add to offer a wildcard extension

When I update the docs for one of my GitHub projects (md2pptx as it happens) I generate a bunch of user_guide.* files. It's my practice to add them with the following command:

git add user_guide.*

Today autocomplete offers each file individually. In my case I have several I want to add all at once. I like the individual file prompting but I'd like autocomplete to also offer the generic user_guide.*.

autocomplete area is showing on other screen

autocomplete panel is showing (I THINK) on first screen when using on other screen and full size mode. Not happening when terminal size is normal mode.

FULL SIZE

Screen Shot 2021-03-14 at 17 31 42


NORMAL SIZE

Screen Shot 2021-03-14 at 17 31 32

[git] Aliases from .gitconfig should be suggested first over default commands

Completion Spec

What completion spec does this enhancement refer to? Or is it Fig itself?
subcommands

Description

Aliases from files such as .gitconfig are shown at the bottom of suggested autocompletes until used and then they are only shown as recently used. These commands should take priority over default commands.

Ex: git st should take priority over git stash

Expected result

git st would be shown as the first suggested command over git stash as well as any other applicable subcommands that have aliases

Actual result

git stash is suggested first unles git st was recently used

Do not suggest the same option after it has been already autocompleted

Completion Spec

What completion spec does this enhancement refer to? Or is it Fig itself?
Fig itself

Description

Currently fig suggest the same option as many times as one types --

example:
command subcommand --option1 foo --option1

Describe the issue that you're seeing.

Steps to reproduce

Clear steps describing how to reproduce the issue. Please link to a reproduction, this makes your issue much easier to diagnose (seriously).

Expected result

What should happen?
If an option has been already autocompleted, do not suggest it again

Actual result

What happened.

Autocompletion when using ENV variables.

Completion Spec

Fig itself? I don't really know, sorry! 🙈

Description

When using ENV variables before any command, the autocomplete stops working.

Steps to reproduce

  • FIG should be running;
  • Open any configured terminal;
  • Type ENV=1 or any combination of {name}={value};
  • Start typing the actual command.

Expected result

We should see the autocomplete window for what I'm typing.

Actual result

image

[go] request for spec

CLI Tool

What CLI tool is missing autocompletion in Fig?
go

Useful Links

Please add some links to the docs of that tool or the --helptext

Go is a tool for managing Go source code.

Usage:

	go <command> [arguments]

The commands are:

	bug         start a bug report
	build       compile packages and dependencies
	clean       remove object files and cached files
	doc         show documentation for package or symbol
	env         print Go environment information
	fix         update packages to use new APIs
	fmt         gofmt (reformat) package sources
	generate    generate Go files by processing source
	get         add dependencies to current module and install them
	install     compile and install packages and dependencies
	list        list packages or modules
	mod         module maintenance
	run         compile and run Go program
	test        test packages
	tool        run specified go tool
	version     print Go version
	vet         report likely mistakes in packages

Use "go help " for more information about a command.

Top Workflows

What are the most used commands or workflows in that CLI tool (for you)?

I am not a heavy go user (yet)!

shift+tab should cycle through autocomplete in reverse order

Completion Spec

Fig itself

Description

shift+tab should cycle through autocomplete in reverse order

Steps to reproduce

Enable tab navigation:

fig settings autocomplete.tab navigate

Press shift and tab. It won't cycle in reverse order

Expected result

Should cycle in reverse order

Actual result

Cycled in normal order

Docksal's `fin` client

CLI Tool

What CLI tool is missing autocompletion in Fig?

fin (Docksal's CLI)

Useful Links

Please add some links to the docs of that tool or the --helptext

https://docs.docksal.io/fin/fin-help/

Top Workflows

What are the most used commands or workflows in that CLI tool (for you)?

fin restart
fin project reset cli
fin start
fin stop
fin <custom_command> (found in .docksal/commands/*

Support for custom icons

Description

Would be really cool to see a plugin for custom icons for folders, file types, etc, similar to VS Code's custom icon extensions like this.

Support for file redirection

Description

Fig does not present filepath suggestions when using file redirects.

Steps to reproduce

After typing pbpaste > Fig should pop up suggestions for filespaths. (Similar behavior should exists for 2>, <, >>, etc)

Duplicate `example`, `examples` and `_examples` folder in specs

Completion Spec

master branch issue

Description

The specs directory contains two identic folders, _examples and examples which exist by default, and a third one: the example folder which is generated after the build command

Steps to reproduce

Run the build script and open the specs folder

Expected result

There should be only one example folder

Actual result

There are three folders, _examples and examples which exist by default, and example which is generated after the build command

Potential Solution

Delete the specs/_examples and specs/examples folders, and run the build script once to generate the examples in the specs/example directory

Screenshots

specs directory by default in the master branch:
Screenshot 2021-05-05 at 08 56 17

After running the build script:
Screenshot 2021-05-05 at 08 56 37

Switch to TypeScript?

Hi,

I think that the autocomplete specs are really powerful and customizable. But writing them in plain JS is pain without auto-completion from IDEs. Do you plan to switch to TypeScript in the future?

I really think that it could help a lot of peoples to contribute to new autocomplete specs.

[git] have remote icon based on where repo is hosted (eg. Github, Gitlab or other)

Completion Spec

git

Description

Currently, Fig just shows the default icon for remote suggestions.

Fig should show the icons associated with where I host my repo. For instance, withfig/autocomplete is hosted on Github, so when I type git push the origin suggestion should have a Github icon.

The remote URL can be determined by running git remote -v

origin	https://github.com/withfig/cdn.git (fetch)
origin	https://github.com/withfig/cdn.git (push)
staging	https://git.heroku.com/fig-cdn-staging.git (fetch)
staging	https://git.heroku.com/fig-cdn-staging.git (push)

support for jetbrains terminal

I know that the various integrations are still a work in progress, but is integration with jetbrains' terminal (IntelliJ / PHPstorm / Rider / ...) somewhere on the roadmap?

Git Issues [testing]

Git

The stupid content tracker

Subcommands

fetch

Issue Title Contributor
#54 Update git fetch @mattschrage

add

Issue Title Contributor
#73 offer a wildcard extension @mattschrage
#81 already staged files should have lower priority @mattschrage

Generators

#37 Add quotes around args with spaces - @mattschrage

Dynamically generate subcommands (with their own nested subcommands and flags)

Several CLI tools enable users to add their own commands (rails, laravel, fin).

Currently, Fig's completion spec standard supports dynamically listing suggestions for arguments, but not generating nested structures (like subcommands and options).

Request: Can we add the ability to add nested suggestions (with their own subcommands and flags) to the completion spec at runtime.

kubectl

Add completions for the following:

-n
get (many options)
    -l
edit
exec
delete (many options)
logs
apply -f
describe
port-forward
config
    set-context
    use-context
    view
cordon
cp
create (MANY options)
replace
top
version

[ripgrep] and [grep] request for specs

CLI Tool

What CLI tool is missing autocompletion in Fig?

ripgrep and grep

Useful Links

Please add some links to the docs of that tool or the --helptext

https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md

https://www.gnu.org/software/grep/manual/grep.html

Top Workflows

What are the most used commands or workflows in that CLI tool (for you)?

Searching text within directories and providing the appropriate amount of context before and after. Piping that into other outputs.

The commands `npm run dev`, `npm copy` and `npm copy:all` don't work.

Description

The commands npm run dev, npm copy and npm copy:all don't work.

Steps to reproduce

  • Run either of those commands with Node version > 15 and npm version > 7

Expected result

The commands just work fine

Actual result

They don't work

System Information

Node Version: v15.3.0
NPM Version: 7.0.14

Potential Solution

Use $(pwd) instead of $INIT_CWD

[Bug] autocomplete specs does not show with sudo

Completion Spec

What completion spec does this bug refer to? Or is it Fig itself?

Fig itself

Description

Describe the issue that you're seeing.

No autocomplete

Steps to reproduce

Clear steps describing how to reproduce the issue. Please link to a reproduction, this makes your issue much easier to diagnose (seriously).

Use sudo before any command

Expected result

What should happen?

Should ignore sudo or change permission to run the script and then ignore sudo and run autocomplete specs with sudo permission

Actual result

What happened.

No autocomplete spec

System Information

Fig Version: 1.0.40 (B188)

OS: macOS Big Sur 11.3

Device: macBook

Potential Solution

(optional) What could be a solution to solve this bug?

Should ignore sudo or change permission to run the script and then ignore sudo and run autocomplete specs with sudo permission

Specific git shorthand commands show autocomplete for flags

OS: macOS Big Sur - 11.2.3
Terminal: iTerm2 w/ ZSH

To change branches, I usually run the command:

git checkout -

git-checkout-shorthand

However, since the command is just the dash, Fig thinks I want to use a flag.

I would love for flags to maybe work like specific executables work (where the first option is to run the command):

code-executable

I know I can press esc to hide the autocomplete, so this is a solution; just not ideal for this command.

This might be by design, and I know this is might be an edge case, but wanted to bring it up!

Thanks for all the hard work, Fig is great.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.