From 3ebd9b84f46b144e92996d5c2d1a94446efd640e Mon Sep 17 00:00:00 2001 From: Rishikesh Darandale Date: Mon, 11 May 2020 12:59:06 +0530 Subject: [PATCH] plugins: added nvm and sdkman (#150) * feat(plugins): added sdkman plugin * feat(plugins): added nvm plugin * fix: fixed the codacy issues --- plugins/nvm/README.md | 40 +++++++++++++++++++++++++++++++++ plugins/nvm/nvm.plugin.sh | 12 ++++++++++ plugins/sdkman/README.md | 25 +++++++++++++++++++++ plugins/sdkman/sdkman.plugin.sh | 9 ++++++++ 4 files changed, 86 insertions(+) create mode 100644 plugins/nvm/README.md create mode 100644 plugins/nvm/nvm.plugin.sh create mode 100644 plugins/sdkman/README.md create mode 100644 plugins/sdkman/sdkman.plugin.sh diff --git a/plugins/nvm/README.md b/plugins/nvm/README.md new file mode 100644 index 0000000..882187d --- /dev/null +++ b/plugins/nvm/README.md @@ -0,0 +1,40 @@ +# nvm plugin + +This plugin automatically source nvm[1] + +## Installation + +### Install nvm + +Lets install[2] the nvm without updaing shell config! + +```bash +export NVM_DIR="$HOME/.nvm" && ( + git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR" + cd "$NVM_DIR" + git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)` +) && \. "$NVM_DIR/nvm.sh" +``` + +### Include nvm as plugin + +```bash +plugins=( + git + nvm +) +``` + +## nvm completion configuration + +```bash +completions=( + git + composer + ssh + nvm +) +``` + +[1]: https://github.com/nvm-sh/nvm +[2]: https://github.com/nvm-sh/nvm#manual-install diff --git a/plugins/nvm/nvm.plugin.sh b/plugins/nvm/nvm.plugin.sh new file mode 100644 index 0000000..28d8bb2 --- /dev/null +++ b/plugins/nvm/nvm.plugin.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# Set NVM_DIR if it isn't already defined +[[ -z "$NVM_DIR" ]] && export NVM_DIR="$HOME/.nvm" + + +# Try to load nvm only if command not already available +if ! type "nvm" &> /dev/null; then + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm + # This is done as part of completions!!! + # [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion +fi diff --git a/plugins/sdkman/README.md b/plugins/sdkman/README.md new file mode 100644 index 0000000..e52d952 --- /dev/null +++ b/plugins/sdkman/README.md @@ -0,0 +1,25 @@ +# sdkman plugin + +This plugin automatically source sdkman[1] + +## Installation + +### Install sdkman + +Lets install[2] the sdkman without updaing shell config! + +```bash +$ curl -s "https://get.sdkman.io?rcupdate=false" | bash +``` + +### Include sdkman as plugin + +```bash +plugins=( + git + sdkman +) +``` + +[1]: https://sdkman.io/ +[2]: https://sdkman.io/install diff --git a/plugins/sdkman/sdkman.plugin.sh b/plugins/sdkman/sdkman.plugin.sh new file mode 100644 index 0000000..08a6c11 --- /dev/null +++ b/plugins/sdkman/sdkman.plugin.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# Set NVM_DIR if it isn't already defined +[[ -z "$SDKMAN_DIR" ]] && export NVM_DIR="$HOME/.sdkman" + +# Try to load sdk only if command not already available +if ! type "sdk" &> /dev/null; then + [[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh" +fi