mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-19 21:41:07 +01:00
feat(adwnode): add plugin
This commit is contained in:
parent
aca048814b
commit
dc019bc3ec
4 changed files with 55 additions and 0 deletions
21
plugins/adwnode/LICENSE
Normal file
21
plugins/adwnode/LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2023-present Adrian Wojdat
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
14
plugins/adwnode/README.md
Normal file
14
plugins/adwnode/README.md
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# NodeJs - Scripts autocomplete
|
||||||
|
|
||||||
|
<p align="center"><img src="https://drive.google.com/uc?id=183iJtqEywucyUWWJYv_PTg-Tb2bKlZLN" alt="NodeJs Autocompleter"></p>
|
||||||
|
|
||||||
|
## Instalation
|
||||||
|
To use it, add `adwnode` to the plugins array in your .zshrc file:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
plugins=(... adwnode)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
Just start typing `yarn` or `npm run` inside NodeJs app directory and double press tab key to start autocompleter.
|
||||||
|
<p align="center"><img src="https://drive.google.com/uc?id=1kQFPM2i4MzuICihUMSiKGRo14nQwr5rS" alt="NodeJs Autocompleter"></p>
|
17
plugins/adwnode/_adwnode
Normal file
17
plugins/adwnode/_adwnode
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
_load_nodejs_scripts() {
|
||||||
|
local read_package_json_scripts_command="try { Object.keys(require('./package.json').scripts).join('\n').replace(/:/g, '\\\:') } catch {''}"
|
||||||
|
nodejs_scripts=("${(@f)$(node -pe ${read_package_json_scripts_command} | sort)}")
|
||||||
|
}
|
||||||
|
|
||||||
|
_adwnode() {
|
||||||
|
if command -v node >/dev/null 2>&1; then
|
||||||
|
if [ -f ./package.json ]; then
|
||||||
|
_load_nodejs_scripts
|
||||||
|
|
||||||
|
|
||||||
|
if [[ ! ${#nodejs_scripts[@]} -eq 0 ]]; then
|
||||||
|
_describe '' nodejs_scripts
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
3
plugins/adwnode/adwnode.plugin.zsh
Normal file
3
plugins/adwnode/adwnode.plugin.zsh
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
autoload -Uz _adwnode
|
||||||
|
compdef _adwnode yarn
|
||||||
|
compdef _adwnode npm run
|
Loading…
Reference in a new issue