Merge pull request #262232 from Sohalt/babashka-completions
babashka: Install shell completions
This commit is contained in:
commit
a75a35caa8
5 changed files with 30 additions and 2 deletions
|
@ -0,0 +1,5 @@
|
|||
_bb_tasks() {
|
||||
COMPREPLY=( $(compgen -W "$(bb tasks |tail -n +3 |cut -f1 -d ' ')" -- ${COMP_WORDS[COMP_CWORD]}) );
|
||||
}
|
||||
# autocomplete filenames as well
|
||||
complete -f -F _bb_tasks bb
|
|
@ -0,0 +1,9 @@
|
|||
function __bb_complete_tasks
|
||||
if not test "$__bb_tasks"
|
||||
set -g __bb_tasks (bb tasks |tail -n +3 |cut -f1 -d ' ')
|
||||
end
|
||||
|
||||
printf "%s\n" $__bb_tasks
|
||||
end
|
||||
|
||||
complete -c bb -a "(__bb_complete_tasks)" -d 'tasks'
|
|
@ -0,0 +1,6 @@
|
|||
_bb_tasks() {
|
||||
local matches=(`bb tasks |tail -n +3 |cut -f1 -d ' '`)
|
||||
compadd -a matches
|
||||
_files # autocomplete filenames as well
|
||||
}
|
||||
compdef _bb_tasks bb
|
|
@ -4,6 +4,7 @@
|
|||
, removeReferencesTo
|
||||
, fetchurl
|
||||
, writeScript
|
||||
, installShellFiles
|
||||
}:
|
||||
|
||||
let
|
||||
|
@ -20,7 +21,7 @@ let
|
|||
|
||||
executable = "bb";
|
||||
|
||||
nativeBuildInputs = [ removeReferencesTo ];
|
||||
nativeBuildInputs = [ removeReferencesTo installShellFiles ];
|
||||
|
||||
extraNativeImageBuildArgs = [
|
||||
"-H:+ReportExceptionStackTraces"
|
||||
|
@ -42,6 +43,9 @@ let
|
|||
# graalvm-ce anyway.
|
||||
postInstall = ''
|
||||
remove-references-to -t ${graalvmDrv} $out/bin/${executable}
|
||||
installShellCompletion --cmd bb --bash ${./completions/bb.bash}
|
||||
installShellCompletion --cmd bb --zsh ${./completions/bb.zsh}
|
||||
installShellCompletion --cmd bb --fish ${./completions/bb.fish}
|
||||
'';
|
||||
|
||||
passthru.updateScript = writeScript "update-babashka" ''
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
, babashka-unwrapped
|
||||
, callPackage
|
||||
, makeWrapper
|
||||
, installShellFiles
|
||||
, rlwrap
|
||||
, clojureToolsBabashka ? callPackage ./clojure-tools.nix { }
|
||||
, jdkBabashka ? clojureToolsBabashka.jdk
|
||||
|
@ -23,7 +24,7 @@ stdenvNoCC.mkDerivation (finalAttrs: {
|
|||
dontUnpack = true;
|
||||
dontBuild = true;
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
nativeBuildInputs = [ makeWrapper installShellFiles ];
|
||||
|
||||
installPhase =
|
||||
let unwrapped-bin = "${babashka-unwrapped}/bin/bb"; in
|
||||
|
@ -37,6 +38,9 @@ stdenvNoCC.mkDerivation (finalAttrs: {
|
|||
--set-default DEPS_CLJ_TOOLS_DIR $out/clojure_tools \
|
||||
--set-default JAVA_HOME ${jdkBabashka}
|
||||
|
||||
installShellCompletion --cmd bb --bash ${babashka-unwrapped}/share/bash-completion/completions/bb.bash
|
||||
installShellCompletion --cmd bb --zsh ${babashka-unwrapped}/share/fish/vendor_completions.d/bb.fish
|
||||
installShellCompletion --cmd bb --fish ${babashka-unwrapped}/share/zsh/site-functions/_bb
|
||||
'' +
|
||||
lib.optionalString withRlwrap ''
|
||||
substituteInPlace $out/bin/bb \
|
||||
|
|
Loading…
Reference in a new issue