mirror of
				https://github.com/ohmybash/oh-my-bash.git
				synced 2024-05-11 05:55:37 +00:00 
			
		
		
		
	* OMB - Major Refactor - Aliases and completions now works like plugins (need to enabled in .bashrc) - Removed the compatible check in spectrum.sh, OMB now works with Bash v3.x like the old days. - Removed core plugin, added those bash functions into base.sh and load during startup. - Updated OSH template for new installations - Added history config and few other stuff from #17 @TODO: Added a shell script to update old version of .bashrc to new one. * Fixed ShellCheck issues * Fixed ShellCheck issues
		
			
				
	
	
		
			62 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			62 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
_sdkman_complete()
 | 
						|
{
 | 
						|
  local CANDIDATES
 | 
						|
  local CANDIDATE_VERSIONS
 | 
						|
 | 
						|
  COMPREPLY=()
 | 
						|
 | 
						|
  if [ $COMP_CWORD -eq 1 ]; then
 | 
						|
    COMPREPLY=( $(compgen -W "install uninstall rm list ls use current outdated version default selfupdate broadcast offline help flush" -- ${COMP_WORDS[COMP_CWORD]}) )
 | 
						|
  elif [ $COMP_CWORD -eq 2 ]; then
 | 
						|
    case "${COMP_WORDS[COMP_CWORD-1]}" in
 | 
						|
      "install" | "uninstall" | "rm" | "list" | "ls" | "use" | "current" | "outdated" )
 | 
						|
        CANDIDATES=$(echo "${SDKMAN_CANDIDATES_CSV}" | tr ',' ' ')
 | 
						|
        COMPREPLY=( $(compgen -W "$CANDIDATES" -- ${COMP_WORDS[COMP_CWORD]}) )
 | 
						|
        ;;
 | 
						|
      "offline" )
 | 
						|
        COMPREPLY=( $(compgen -W "enable disable" -- ${COMP_WORDS[COMP_CWORD]}) )
 | 
						|
        ;;
 | 
						|
      "selfupdate" )
 | 
						|
        COMPREPLY=( $(compgen -W "force" -P "[" -S "]" -- ${COMP_WORDS[COMP_CWORD]}) )
 | 
						|
        ;;
 | 
						|
      "flush" )
 | 
						|
        COMPREPLY=( $(compgen -W "candidates broadcast archives temp" -- ${COMP_WORDS[COMP_CWORD]}) )
 | 
						|
        ;;
 | 
						|
      *)
 | 
						|
        ;;
 | 
						|
    esac
 | 
						|
  elif [ $COMP_CWORD -eq 3 ]; then
 | 
						|
    case "${COMP_WORDS[COMP_CWORD-2]}" in
 | 
						|
      "install" | "uninstall" | "rm" | "use" | "default" )
 | 
						|
        _sdkman_candidate_versions ${COMP_WORDS[COMP_CWORD-1]}
 | 
						|
        COMPREPLY=( $(compgen -W "$CANDIDATE_VERSIONS" -- ${COMP_WORDS[COMP_CWORD]}) )
 | 
						|
        ;;
 | 
						|
      *)
 | 
						|
        ;;
 | 
						|
    esac
 | 
						|
  fi
 | 
						|
 | 
						|
  return 0
 | 
						|
}
 | 
						|
 | 
						|
_sdkman_candidate_versions(){
 | 
						|
 | 
						|
  CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions $1)
 | 
						|
  if [ "$SDKMAN_OFFLINE_MODE" = "true" ]; then
 | 
						|
    CANDIDATE_VERSIONS=$CANDIDATE_LOCAL_VERSIONS
 | 
						|
  else
 | 
						|
    CANDIDATE_ONLINE_VERSIONS="$(curl -s "${SDKMAN_SERVICE}/candidates/$1" | tr ',' ' ')"
 | 
						|
    CANDIDATE_VERSIONS="$(echo $CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS |sort | uniq ) "
 | 
						|
  fi
 | 
						|
 | 
						|
}
 | 
						|
 | 
						|
__sdkman_cleanup_local_versions(){
 | 
						|
 | 
						|
  __sdkman_build_version_csv $1
 | 
						|
  echo $CSV | tr ',' ' '
 | 
						|
 | 
						|
}
 | 
						|
 | 
						|
complete -F _sdkman_complete sdk
 |