{ lib, stdenv, little-things, installShellFiles, fzf, }: stdenv.mkDerivation (finalAttrs: { pname = "little-things-script"; version = "0-unstable-2026-01-12"; buildInputs = [ little-things ]; src = little-things; buildPhase = '' mkdir $out $out/bin echo '#!/usr/bin/env bash ltb="${little-things}/bin" if [ "$#" -lt 1 ]; then "$0" __comp__ | ${fzf}/bin/fzf -m | sed "s,^,little-things ," exit 127; else cmd="$1" shift fi if [ "$cmd" == "__comp__" ]; then ls -1 "$ltb" elif [ -x "$ltb/$cmd" ]; then exec "$ltb/$cmd" "$@" else echo "$cmd is not executable or not a file" >&2 exit 127; fi' >$out/bin/little-things chmod +x $out/bin/little-things ''; nativeBuildInputs = [ installShellFiles ]; postInstall = '' compfuns() { echo '_generate_little-things_completions() { local idx=$1; shift local words=( "$@" ) local current_word=''${words[idx]} local array=() while IFS= read -r line; do array+=("$line") done < <(little-things __comp__) for elem in "''${array[@]}"; do if [[ $elem == "$current_word"* ]]; then echo "$elem"; fi done } _complete_little-things_bash() { local raw=($(_generate_little-things_completions "$COMP_CWORD" "''${COMP_WORDS[@]}")) COMPREPLY=( "''${raw[@]}" ) } _complete_little-things_zsh() { local -a raw raw=($(_generate_little-things_completions "$CURRENT" "''${words[@]}")) compadd -- $raw } if [ -n "''${ZSH_VERSION:-}" ]; then autoload -Uz compinit compinit compdef _complete_little-things_zsh little-things elif [ -n "''${BASH_VERSION:-}" ]; then complete -F _complete_little-things_bash little-things fi' } installShellCompletion --cmd little-things \ --bash <(compfuns) \ --zsh <(compfuns) ''; meta = little-things.meta; })