Re: [Nix-dev] Why Bash and Nix-Shell have no completion?
Em 26/01/2015 04:37, Marc Weber marco-owe...@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@lists.science.uu.nl http://lists.science.uu.nl/mailman/listinfo/nix-dev ___ nix-dev mailing list nix-dev@lists.science.uu.nl http://lists.science.uu.nl/mailman/listinfo/nix-dev
Re: [Nix-dev] Why Bash and Nix-Shell have no completion?
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 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@lists.science.uu.nl http://lists.science.uu.nl/mailman/listinfo/nix-dev
[Nix-dev] Why Bash and Nix-Shell have no completion?
Hello Nixers! Can someone help me? I have updated my Nixos to the most recent release, Dingo, using Unstable channel. But when I use nix-shell, or even plain Bash, it just comes with no fancy completion. Can someone help me? ___ nix-dev mailing list nix-dev@lists.science.uu.nl http://lists.science.uu.nl/mailman/listinfo/nix-dev