From e2687220c31419b0807d5c3b9c271a942206a286 Mon Sep 17 00:00:00 2001 From: Raphael R <4246780+reitzig@users.noreply.github.com> Date: Sat, 14 Jul 2018 16:08:18 +0200 Subject: [PATCH 1/3] Drafts a way to provide fish support Optionally, install sdkman-for-fish after installation was otherwise successful. * Does not pester users without fish. * Does not pester users which already have an `sdk.fish` file. (Would conflict.) * Asks before installing. Left to do: finish bash trickery; finalize wording. _Note:_ 1. The installation method is opinionated. 2. reitzig/sdkman-for-fish may have to mature a bit still. --- app/views/install.scala.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/views/install.scala.txt b/app/views/install.scala.txt index 15869e3..4e37fe8 100644 --- a/app/views/install.scala.txt +++ b/app/views/install.scala.txt @@ -286,6 +286,21 @@ if [[ -z $(grep 'sdkman-init.sh' "$sdkman_zshrc") ]]; then echo "Updated existing ${sdkman_zshrc}" fi +if [[ -d "${HOME}"/.config/fish && ! -f "${HOME}"/.config/fish/conf.d/sdk.fish ]]; then + echo "It seems you have fish installed. Unfortunately, SDKMAN! does not work with fish out of the box." + echo "Install third-party support now? [y/N/?]" + + # ? --> show what will be installed (necessary?) + + if [[ y ]]; then + if [[ ! -f "${HOME}"/.config/fish/functions/fisher.fish ]]; then + curl -Lo ~/.config/fish/functions/fisher.fish --create-dirs https://git.io/fisher + fi + + fisher reitzig/sdkman-for-fish + fi +fi + echo -e "\n\n\nAll done!\n\n" echo "Please open a new terminal, or run the following in the existing one:" From 79eed7432c7cc99f100049706e857dc6aaec2c19 Mon Sep 17 00:00:00 2001 From: Raphael R <4246780+reitzig@users.noreply.github.com> Date: Sun, 15 Jul 2018 10:10:27 +0200 Subject: [PATCH 2/3] Use fish to run fish code --- app/views/install.scala.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/install.scala.txt b/app/views/install.scala.txt index 4e37fe8..97e48f0 100644 --- a/app/views/install.scala.txt +++ b/app/views/install.scala.txt @@ -289,15 +289,19 @@ fi if [[ -d "${HOME}"/.config/fish && ! -f "${HOME}"/.config/fish/conf.d/sdk.fish ]]; then echo "It seems you have fish installed. Unfortunately, SDKMAN! does not work with fish out of the box." echo "Install third-party support now? [y/N/?]" + # prompt - # ? --> show what will be installed (necessary?) + while [[ ? ]]; do + # show what will be installed (necessary?) + # reprompt + done if [[ y ]]; then if [[ ! -f "${HOME}"/.config/fish/functions/fisher.fish ]]; then curl -Lo ~/.config/fish/functions/fisher.fish --create-dirs https://git.io/fisher fi - fisher reitzig/sdkman-for-fish + fish -c "fisher reitzig/sdkman-for-fish" fi fi From e97333cc2e39352bb17847d4ff4a2c5a9f52ba6c Mon Sep 17 00:00:00 2001 From: Raphael R <4246780+reitzig@users.noreply.github.com> Date: Thu, 7 Nov 2019 00:51:07 +0100 Subject: [PATCH 3/3] Installer for integration into fish complete. --- app/views/install.scala.txt | 49 ++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/app/views/install.scala.txt b/app/views/install.scala.txt index 97e48f0..f3a1985 100644 --- a/app/views/install.scala.txt +++ b/app/views/install.scala.txt @@ -288,21 +288,42 @@ fi if [[ -d "${HOME}"/.config/fish && ! -f "${HOME}"/.config/fish/conf.d/sdk.fish ]]; then echo "It seems you have fish installed. Unfortunately, SDKMAN! does not work with fish out of the box." - echo "Install third-party support now? [y/N/?]" - # prompt - - while [[ ? ]]; do - # show what will be installed (necessary?) - # reprompt + + while true; do + read -p "Install third-party support (fisher, sdkman-for-fish) now? [yN]: " yn + case $yn in + [Yy]* ) + if [[ -z ${XDG_CONFIG_HOME} ]]; then + XDG_CONFIG_HOME="${HOME}/.config" + fi + + if [[ ! -f "${HOME}"/.config/fish/functions/fisher.fish ]]; then + mkdir -p "${XDG_CONFIG_HOME}"/fish/functions/ + + echo -n "Downloading fisher ... " + curl_out=$(curl -fsSL \ + -o "${XDG_CONFIG_HOME}"/fish/functions/fisher.fish \ + --create-dirs https://git.io/fisher 2>&1) + + if [[ ${?} -gt 0 ]]; then + echo "FAILED" + echo "${curl_out}" + break + else + echo "OKAY" + fi + + unset curl_out + fi + + fish -c "fisher add reitzig/sdkman-for-fish" + break + ;; + * ) + break + ;; + esac done - - if [[ y ]]; then - if [[ ! -f "${HOME}"/.config/fish/functions/fisher.fish ]]; then - curl -Lo ~/.config/fish/functions/fisher.fish --create-dirs https://git.io/fisher - fi - - fish -c "fisher reitzig/sdkman-for-fish" - fi fi echo -e "\n\n\nAll done!\n\n"