Merge branch 'dev' into macos-compat

This commit is contained in:
Raphael Reitzig 2019-11-05 04:54:15 +01:00
commit 060169f5da
6 changed files with 56 additions and 15 deletions

View file

@ -1,5 +1,12 @@
root = true
[*] [*]
charset = utf-8
end_of_line = lf
indent_style = space indent_style = space
indent_size = 2 indent_size = 4
trim_trailing_whitespace = true trim_trailing_whitespace = true
insert_final_newline = true insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

View file

@ -47,4 +47,5 @@ script:
- ruby test/completion.rb - ruby test/completion.rb
- fish test/wrapper.fish - fish test/wrapper.fish
- fish test/reinitialize.fish - fish test/reinitialize.fish
- bash -c "sdk install crash 1.3.0; sdk uninstall crash 1.3.0"; fish test/10_zombies_new.fish - bash -c "source ${HOME}/.sdkman/bin/sdkman-init.sh && sdk install crash 1.3.0 && sdk uninstall crash 1.3.0" && fish test/10_zombies_new.fish
- bash -c "rm -rf ~/.sdkman && sed -i 's/^.*\(sdkman\|SDKMAN\).*$//g' ~/.bashrc && echo 'SDKMAN uninstalled'" && fish -c "echo 'y' | sdk" && fish -c "sdk version"

View file

@ -2,8 +2,8 @@
[![Build Status][travis-badge]][travis-link] [![Build Status][travis-badge]][travis-link]
Makes command `sdk` from [SDKMAN!] available in fish. Makes command `sdk` from [SDKMAN!] usable from fish, including auto-completion.
Also provides auto-completion and adds binaries from installed SDKs to the PATH. Also adds binaries from installed SDKs to the PATH.
Tested with fish 2.7.1 and 3.0.2, and SDKMAN! 5.7.3. Tested with fish 2.7.1 and 3.0.2, and SDKMAN! 5.7.3.
@ -15,7 +15,10 @@ With [fisher] (install separately):
fisher add reitzig/sdkman-for-fish fisher add reitzig/sdkman-for-fish
``` ```
_Note:_ Only compatible with fisher v3 upwards; v2 is no longer supported. _Note:_
- Only compatible with fisher v3 upwards; v2 is no longer supported.
- You have to install [SDKMAN!] separately.
## Usage ## Usage

View file

@ -78,6 +78,7 @@ end
# no initialization necessary. # no initialization necessary.
# Otherwise: # Otherwise:
if not set -q SDKMAN_DIR; or test (ls -ld "$SDKMAN_DIR" | awk '{print $3}') != (whoami) if not set -q SDKMAN_DIR; or test (ls -ld "$SDKMAN_DIR" | awk '{print $3}') != (whoami)
set -e SDKMAN_DIR
__fish_sdkman_run_in_bash "source $__fish_sdkman_init" __fish_sdkman_run_in_bash "source $__fish_sdkman_init"
end end

View file

@ -1,9 +1,36 @@
function sdk -d "Manage SDKs"
# Guard: SDKMAN! needs to be installed # Guard: SDKMAN! needs to be installed
if not test -f "$__fish_sdkman_init" if not test -f "$__fish_sdkman_init"
exit 0 # 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 end
# Declare the sdk command for fish if read_confirm "You don't seem to have SDKMAN! installed. Install now?"
function sdk -d "Manage SDKs" 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" __fish_sdkman_run_in_bash "source \"$__fish_sdkman_noexport_init\" && sdk $argv"
end end
end

View file

@ -16,10 +16,12 @@ begin
end end
begin begin
set SDKMAN_DIR "/" # belongs to root, who hopefully doesn't run this set -x SDKMAN_DIR "/" # belongs to root, who hopefully doesn't run this
set in_new_shell (fish -lc 'echo $SDKMAN_DIR') set in_new_shell (fish -lc 'echo $SDKMAN_DIR')
if [ "$in_new_shell" != "$proper_value" ] if [ "$in_new_shell" != "$proper_value" ]
echo "SDKMAN_DIR reinitialized to $in_new_shell instead of $proper_value" echo "SDKMAN_DIR reinitialized to $in_new_shell instead of $proper_value"
exit 1 exit 1
end end
end end
# TODO: add test that fails if `test` in conf.d/sdk.fish:80 errors (cf issue #28 et al.)