mirror of
https://github.com/ethauvin/sdkman-for-fish.git
synced 2025-04-25 05:17:11 -07:00
Offer to install SDKMAN! if not already installed.
Fixes issue #26 Also: - Change language in README to clarify that SDKMAN! is not included. - Polishes to `.editorconfig`.
This commit is contained in:
parent
47ec1e3847
commit
e41ccb9ce8
4 changed files with 50 additions and 11 deletions
|
@ -1,9 +1,36 @@
|
|||
# Guard: SDKMAN! needs to be installed
|
||||
if not test -f "$__fish_sdkman_init"
|
||||
exit 0
|
||||
end
|
||||
|
||||
# Declare the sdk command for fish
|
||||
function sdk -d "Manage SDKs"
|
||||
__fish_sdkman_run_in_bash "source \"$__fish_sdkman_noexport_init\" && sdk $argv"
|
||||
# Guard: SDKMAN! needs to be installed
|
||||
if not test -f "$__fish_sdkman_init"
|
||||
# Propose to install SDKMAN!
|
||||
|
||||
function read_confirm
|
||||
while true
|
||||
read -l -P "$argv[1] [y/N] " confirm
|
||||
|
||||
switch $confirm
|
||||
case Y y
|
||||
return 0
|
||||
case '' N n
|
||||
return 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if read_confirm "You don't seem to have SDKMAN! installed. Install now?"
|
||||
if not which curl > /dev/null
|
||||
echo "curl required"
|
||||
return 1
|
||||
end
|
||||
if not which bash > /dev/null
|
||||
echo "bash required"
|
||||
return 1
|
||||
end
|
||||
|
||||
curl -s "https://get.sdkman.io" | bash | sed '/All done!/q'
|
||||
echo "Please open a new terminal/shell to load SDKMAN!"
|
||||
end
|
||||
else
|
||||
# Declare the _actual_ sdk command for fish
|
||||
__fish_sdkman_run_in_bash "source \"$__fish_sdkman_noexport_init\" && sdk $argv"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue