Created
October 15, 2019 04:44
-
-
Save alialrahahleh/0738969d28f4e340dc0d6ab6216bcc4c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env fish | |
# | |
# Copyright 2017 Marco Vermeulen | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# | |
function __sdkman_echo_debug | |
if test $sdkman_debug_mode | |
echo $argv[1] | |
end | |
end | |
function __sdkman_export_candidate_home | |
set -l candidate_name "$argv[1]" | |
set -l candidate_dir "$argv[2]" | |
set -l candidate_home_var (string join '_' (string upper $candidate_name) "HOME") | |
set -x $candidate_home_var $candidate_dir | |
end | |
function __sdkman_determine_candidate_bin_dir | |
set -l candidate_dir "$argv[1]" | |
if test -d "$candidate_dir/bin" | |
echo "$candidate_dir/bin" | |
else | |
echo "$candidate_dir" | |
end | |
end | |
function __sdkman_prepend_candidate_to_path | |
set -l candidate_dir "$argv[1]" | |
set -l candidate_bin_dir (__sdkman_determine_candidate_bin_dir "$candidate_dir") | |
set -gx PATH $candidate_bin_dir $PATH | |
end | |
set SDKMAN_PLATFORM (uname) | |
if test "$SDKMAN_PLATFORM" = 'Linux' | |
if test (uname -m) = 'i686' | |
set SDKMAN_PLATFORM string join "" SDKMAN_PLATFORM '32' | |
else | |
set SDKMAN_PLATFORM string join "" SDKMAN_PLATFORM '64' | |
end | |
end | |
export SDKMAN_PLATFORM | |
if [ -z "$SDKMAN_VERSION" ] | |
export set SDKMAN_VERSION "5.7.3+337" | |
end | |
if [ -z "$SDKMAN_CANDIDATES_API" ] | |
export set SDKMAN_CANDIDATES_API "https://api.sdkman.io/2" | |
end | |
if [ -z "$SDKMAN_DIR" ] | |
export set SDKMAN_DIR "$HOME/.sdkman" | |
end | |
set SDKMAN_CANDIDATES_DIR "$SDKMAN_DIR/candidates" | |
export SDKMAN_CANDIDATES_DIR | |
# OS speciendc support (must be 'true' or 'false'). | |
set cygwin false | |
set darwin false | |
set solaris false | |
set freebsd false | |
# Determine shell | |
set zsh_shell false | |
set bash_shell false | |
if test -n "$ZSH_VERSION" | |
set zsh_shell true | |
else | |
set bash_shell true | |
end | |
# Load the sdkman config if it exists. | |
if test -f "$SDKMAN_DIR/etc/config.fish" | |
source "$SDKMAN_DIR/etc/config.fish" | |
end | |
# Create upgrade delay file if it doesn't exist | |
if test ! -f "$SDKMAN_DIR/var/delay_upgrade" | |
touch "$SDKMAN_DIR/var/delay_upgrade" | |
end | |
# set curl connect-timeout and max-time | |
if test -z "$sdkman_curl_connect_timeout" | |
set sdkman_curl_connect_timeout 7 | |
end | |
if test -z "$sdkman_curl_max_time" | |
set sdkman_curl_max_time 10 | |
end | |
# set curl retry | |
if test -z "$sdkman_curl_retry" | |
set sdkman_curl_retry 0 | |
end | |
# set curl retry max time in seconds | |
if test -z "$sdkman_curl_retry_max_time" | |
set sdkman_curl_retry_max_time 60 | |
end | |
# set curl to continue downloading automatically | |
if test -z "$sdkman_curl_continue" | |
set sdkman_curl_continue true | |
end | |
# Read list of candidates and set array | |
set SDKMAN_CANDIDATES_CACHE "$SDKMAN_DIR/var/candidates" | |
set SDKMAN_CANDIDATES_CSV (cat $SDKMAN_CANDIDATES_CACHE) | |
__sdkman_echo_debug "Setting candidates csv: $SDKMAN_CANDIDATES_CSV" | |
for candidate_name in (echo $SDKMAN_CANDIDATES_CSV | string split ',') | |
set candidate_dir "$SDKMAN_CANDIDATES_DIR/$candidate_name/current" | |
if test -h "$candidate_dir" -o -d "$candidate_dir" | |
__sdkman_export_candidate_home "$candidate_name" "$candidate_dir" | |
__sdkman_prepend_candidate_to_path "$candidate_dir" | |
end | |
end | |
export PATH |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set sdkman_auto_answer false | |
set sdkman_auto_selfupdate false | |
set sdkman_insecure_ssl false | |
set sdkman_curl_connect_timeout 7 | |
set sdkman_curl_max_time 10 | |
set sdkman_beta_channel false | |
set sdkman_debug_mode false | |
set sdkman_colour_enable true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment