Giter Club home page Giter Club logo

zsh-yarn-autocompletions's Introduction

zsh-yarn-autocompletions

license Github Releases

You may also like:

Supported yarn commands

  • yarn run
  • yarn remove
  • yarn add
  • yarn why

You can customize the autocompletion of yarn add command. It's configurable.

Installation

Manually

Download

Please go to the GitHub releases page and download the latest binary files.

Note that you should choose correct file according to your OS.

Add as a Zsh plugin

Unzip the compressed file you downloaded.

For 1.x (or above) users, please run:

$ ./install.sh $ZSH_CUSTOM/plugins

For 0.2 users, please run:

$ ./install.sh $ZSH_CUSTOM

Next please edit your .zshrc file. Add yarn-autocompletions to plugins section.

Like this:

plugins=(
  # ... your other plugins
+ yarn-autocompletions
)

Restart your terminal.

Fig

Fig adds apps, shortcuts, and autocomplete to your existing terminal.

Install zsh-yarn-autocompletions in just one click.

With a plugin manager

Update your .zshrc file with the following line:

zinit ice atload"zpcdreplay" atclone'./zplug.zsh'
zinit light g-plane/zsh-yarn-autocompletions

Update your .zshrc file with the following line:

zplug "g-plane/zsh-yarn-autocompletions", hook-build:"./zplug.zsh", defer:2

Customize the autocompletion of yarn add command

Since v1.0.0

This plugin support adding your favorite packages name for autocompletion of yarn add and yarn add --dev command.

Adding a configuration file

First, put a new file called .yarn-autocompletions.yml in your home directory.

For example:

$ touch ~/.yarn-autocompletions.yml

This file is in YAML format.

Adding your favorite packages

We assume you want to add vue and react. So you can edit that file like this:

dependencies:
  - vue
  - react

And dev_dependencies:

dev_dependencies:
  - vue-loader
  - parcel-bundler

Excluding some packages

In fact, this plugin has some builtin packages autocompletion which can provide out-of-the-box experience, such as vue or react.

However you don't like those builtin packages.

So you can add it to exclude section:

exclude:
  - react

Now you won't see react in autocompletion.

All sections are optional

Now the whole configuration file looks like:

dependencies:
  - vue
  - react
dev_dependencies:
  - vue-loader
  - parcel-bundler
exclude:
  - react

Keep in mind that any sections are optional.

Build from source

Make sure that you've installed rustup first and use rustup to install Rust.

Next, follow the steps below:

git clone https://github.com/g-plane/zsh-yarn-autocompletions.git
cd zsh-yarn-autocompletions
cargo build --release
mkdir -p $ZSH_CUSTOM/plugins/yarn-autocompletions
cp ./yarn-autocompletions.plugin.zsh $ZSH_CUSTOM/plugins/yarn-autocompletions/
cp ./target/release/yarn-autocompletions $ZSH_CUSTOM/plugins/yarn-autocompletions/

Then, edit your .zshrc like this:

plugins=(
  # ... your other plugins
+ yarn-autocompletions
)

Restart your terminal.

Contribution

Any contributions are welcome.

License

MIT License

Copyright (c) 2018-present Pig Fang

zsh-yarn-autocompletions's People

Contributors

arthurdenner avatar azure-pipelines[bot] avatar banyan avatar danielbayerlein avatar g-plane avatar ibayramli avatar josh- avatar jounqin avatar nguymin4 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

zsh-yarn-autocompletions's Issues

Not working - shows file autocomplete instead

Is there any way to debug the plugin? If I type yarn run and press tab, I get a list of files in the directory.
~:projects:frontend 2020-04-28 10-23-03

I've installed the latest version, my .zshrc contains plugins=(git yarn-autocompletions) and there's no error when I start the shell.

Lose the "-latest" in zplug.zsh.

You are a careless man. You lose the "-latest" in url="https://github.com/g-plane/zsh-yarn-autocompletions/releases/download/v$version/yarn-autocompletions_$platform.zip". So installed by plugin-manager show 404.
It should be:

url="https://github.com/g-plane/zsh-yarn-autocompletions/releases/download/v$version/yarn-autocompletions_$platform-latest.zip

Include instructions for building from source?

Hi, thanks for this project, very cool!

I wanted to install this by building from source instead of installing the pre-packaged binary.

Is this the right way to do it (on macOS, from the root directory of the repo)?

brew install rust
cargo build --release
cp target/release/yarn-autocompletions ./
./install.sh $ZSH_CUSTOM/plugins
# Trust program from Unidentified developer (macOS Catalina Gatekeeper)
spctl --add $ZSH_CUSTOM/plugins/yarn-autocompletions/yarn-autocompletions
rm yarn-autocompletions

Auto completion for: yarn <a built-in command>

Hey, this is a very cool plugin!
However when I type yarn a it doesn't autocomplete it to yarn add. This is a pitty, as autocompletion for custom yarn scripts works just fine. Would it be possible to add the built-in commands like add and remove to the list?

This should be the complete list of built-in commands:

access, add, audit, autoclean, bin, cache, check,
config, create, exec, generate-lock-entry, global,
help, import, info, init, install, licenses, link,
list, login, logout, node, outdated, owner, pack,
publish, remove, run, tag, team, unlink, unplug,
upgrade, upgrade-interactive, version, versions,
why, workspace, workspaces

Adding frequently installed packages

Since v1.0.0 this plugin supports yarn add command, like this:
Untitled.gif

Now I am going to add more frequently installed packages, which will provide better out-of-the-box for most users.

Those packages can be both dependencies and dev_dependencies (in package.json it is devDependencies).

Anyone can add comments to share some frequently installed packages or famous packages.

Also you can send a PR directly. The packages names are defined in https://github.com/g-plane/zsh-yarn-autocompletions/blob/master/src/deps/packages.rs . Remember adding trailing comma for better git diff.

Publish the compiled files

Hi, @g-plane. Thanks for this plugin, it's really useful.

I was just wondering, why you didn't publish the compiled files?
I'm not sure if everyone will be willing to install Rust in order to use the plugin. (I was, but a co-worker wasn't, I sent him the compiled files and he's using it too)

Doesn't display commands with : in their names

Pressing yarn run <tab> <tab> does not list commands that have a : in their name. For example a package.json with the following scripts does not display the start:dev and test:watch commands.

{
  "scripts": {
	"start": "node .",
	"start:dev": "webpack-dev-server",
	"test": "jest",
    "test:watch": "yarn test --watch",
  }
}

Install script can't work

Hi,
I'm seeing your install.sh.
It can't work if you don't specify the $ZSH_CUSTOM folder as argument.

if [ ! -d $1/plugins/yarn-autocompletions ]
then
mkdir $1/plugins/yarn-autocompletions
fi

Maybe you should update the doc (or the script!).

Thanks for you work.

Error `exec format error`

$ yarn _yarn_autocompletions_scripts:1: exec format error: /Users/mathieutu/.oh-my-zsh/custom/plugins/yarn-autocompletions/yarn-scripts
_yarn_autocompletions_scripts:1: exec format error: /Users/mathieutu/.oh-my-zsh/custom/plugins/yarn-autocompletions/yarn-scripts
_yarn_autocompletions_scripts:1: exec format error: /Users/mathieutu/.oh-my-zsh/custom/plugins/yarn-autocompletions/yarn-scripts
yarn

Just after installing the plugin and restarting zsh.

$ la $ZSH_CUSTOM/plugins/yarn-autocompletions
total 20992
-rw-r--r--@ 1 mathieutu  staff   1.0K Mar 21 09:43 LICENSE
-rw-r--r--@ 1 mathieutu  staff   796B Mar 21 09:43 README.md
-rw-r--r--@ 1 mathieutu  staff   1.1K Mar 21 09:43 yarn-autocompletions.plugin.zsh
-rwxr-xr-x@ 1 mathieutu  staff   5.1M Mar 21 09:43 yarn-deps*
-rwxr-xr-x@ 1 mathieutu  staff   5.1M Mar 21 09:43 yarn-scripts*

How do I enable using Fig?

I just installed Fig on my Macbook and it's working as expected. I then installed this package using the "community plugins" section in Fig. After installing the package I restarted the terminal. However, I can't get this to work. There's no autocomplete at all.

example.mov

What did I do wrong?

Latest (V2.0.0) yarn-autocompletions_linux.tar.gz does not have latest code changes

Download https://github.com/g-plane/zsh-yarn-autocompletions/releases/download/v2.0.0/yarn-autocompletions_linux.tar.gz
Extract files, and look at the contents of yarn-autocompletions.plugin.zsh.
It does not contain the fix made in #22.
Actual content of file is:

YARN_AUTO_COMP_PATH="$(dirname $0)/yarn-autocompletions"            
                                                                    
_yarn_autocompletions() {                                           
    compls=$($YARN_AUTO_COMP_PATH $1)                               
    completions=(${=compls})                                        
    compadd -- $completions                                         
}                                                                   
                                                                    
_yarn() {                                                           
    case $words[2] in                                               
        add)                                                        
            if [[ $words[3] == "--dev" ]]                           
            then                                                    
                _yarn_autocompletions "add-dev"                     
            else                                                    
                _yarn_autocompletions "add"                         
            fi                                                      
            ;;                                                      
        remove)                                                     
            _yarn_autocompletions "remove"                          
            ;;                                                      
        upgrade)                                                    
            _yarn_autocompletions "remove"                          
            ;;                                                      
        why)                                                        
            _yarn_autocompletions "why"                             
            ;;                                                      
        *)                                                          
            _yarn_autocompletions "scripts"                         
            ;;                                                      
    esac                                                            
}                                                                   

I haven't checked the other release artifacts, but they could have the same problem?

Zplug installation broken for v2.0.0

The release workflow using github actions doesn't insert the version in the filename for the release assets. This breaks the zplug.sh hook build script.

Also, looks like the OS in the file names generated by the release workflow have a -latest suffix as well.

homebrew install

Will be great to automate installation as Homebrew formulare distribution, so it could be installed on Mac OS with one command brew install zsh-yarn-autocompletions.

zplug compatibility

I'm by no means a zsh expert but I've been using zplug lately. I wanted to install your plugin using zplug and I ran into some issues:

  1. I was able to run the build manually by adding this to my .zshrc:
zplug "g-plane/zsh-yarn-autocompletions", hook-build:"mkdir -p src && mv yarn-deps src/ && mv yarn-scripts src/ && cd src/yarn-deps && cargo build --release && cd ../yarn-scripts && cargo build --release && cd ../.. && mv src/yarn-deps/target/release/yarn-deps . && mv src/yarn-scripts/target/release/yarn-scripts ."

In order to move the compiled yarn-deps and yarn-scripts to the plugin's root folder, the folders of the same name can't exist, so I'm moving those to src. It's kind of hacky so a better way would be nice.

  1. If I type yarn and hit tab, I get:
_yarn_autocompletions_scripts:1: no such file or directory: /plugins/yarn-autocompletions/yarn-scripts
_yarn_autocompletions_scripts:1: no such file or directory: /plugins/yarn-autocompletions/yarn-scripts
_yarn_autocompletions_scripts:1: no such file or directory: /plugins/yarn-autocompletions/yarn-scripts

Looking at the code, it's interpolating $ZSH_CUSTOM to the empty string, so I guess that's not supported by default. The plugin gets installed to ~/.zplug/repos/g-plane/zsh-yarn-autocompletions so $ZSH_CUSTOM/plugins/yarn-autocompletions, like the plugin code currently uses, doesn't seem like the generic approach.

Happy to have a stab at a PR but I wanted to check first. ๐Ÿ™‚

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.