[Nix-dev] Why Bash and Nix-Shell have no completion?

Anderson Torres torres.anderson.85 at gmail.com
Tue Jan 27 18:44:04 CET 2015


Em 26/01/2015 04:37, "Marc Weber" <marco-oweber at gmx.de> escreveu:
>
> It got implemented somewhen in the past, some people told about
> bash completion being annoying in some cases (-> [1]) .. which means the
perfect
> solutions means conditional opt-in/out eventually.
>
> bash.nix has:
>
>       interactiveShellInit = ''
>         [...]
>         ${bashCompletion}
>
> I personally have patches putting a
>
>   source /etc/bash/setup-all
>
> in ~/.bashrc as default which means:
>   1) user can edit .bashrc (because its not a symlink)
>   2) user can opt-out easily
>   3) user can look at setup-all which allows him/her to opt-in/out from
>     individual features or completion scripts, such as individual
>     completion scripts..
>   -> [1]
>
> those patches change quite a lot - and I'm unsure whether its worth
> merging them into master.
>
> I want to say: Builders should be as clean as possible eventually.
> Thus opt-in makes sense - look at ~/.bashrc and source that script
> to enable default behaviour ?
>
> Marc Weber
>
> [1] This is the sample code of my /etc/bash/nix-bash-lib which gets
> sourced by /etc/bash/setup-all, it opts-out from gnu utils which was
> reported to be annoying long time ago - so it might be outdated.
>
> You could use such in your .bashrc
>
>   NIX_COMPL_SCRIPT_SOURCED["ALL"] = anything
>   NIX_COMPL_SCRIPT_SOURCED[the-individual-compl-script] = anything
>   source /etc/bash/setup-all
>
> to opt-out.
>
>
>   declare -A NIX_COMPL_SCRIPT_SOURCED
>
>   # potential problems (-rev 20179)
>   #  - It doesn't support filenames with spaces.
>   #  - It inserts a space after the filename when tab-completing in an
>   #    "svn" command.
>   #  - Many people find it annoying that tab-completion on commands like
>   #    "tar" only matches filenames with the "right" extension.
>   #  - Lluís reported bash apparently crashing on some tab completions.
>   # comment: Does this apply to complete.gnu-longopt or also to
bash_completion?
>   NIX_COMPL_SCRIPT_SOURCED[complete.gnu-longopt]=1

Here my shell is failing: bash has no completion enabled :(

>   if shopt -q progcomp &>/dev/null; then
>     # bash supports completion:
>     nix_add_profile_completion(){
>       local profile="$1"
>
>       # origin: bash_completion, slightly adopted
>       # source script only once - allow user to use
NIX_COMPL_SCRIPT_SOURCED to
>       # opt out from bad scripts. If a user wants to reload all he can
clear
>       # NIX_COMPL_SCRIPT_SOURCED
>
>       local nullglobStatus=$(shopt -p nullglob)
>       shopt -s nullglob
>       for s in "$profile"/etc/bash_completion.d/*
"$p/share/bash-completion/completions/"*; do
>         local base="${s/*\//}"
>         [[
>           -z "${NIX_COMPL_SCRIPT_SOURCED[$base]}" &&
>           -z "${NIX_COMPL_SCRIPT_SOURCED[ALL]}"
>         ]] && { . "$s"; NIX_COMPL_SCRIPT_SOURCED[$base]=1; }
>
>       done
>       eval "$nullglobStatus"
>     }
>   else
>     nix_add_profile_completion(){ :; }
>   fi
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20150127/bb716d6e/attachment.html 


More information about the nix-dev mailing list