Coder Social home page Coder Social logo

nix-bash-completions's People

Contributors

hedning avatar jumper149 avatar sajith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nix-bash-completions's Issues

Upstream Nix completion conflict

It seems that both this project and upstream Nix provides completion for the nix command. From my testing, having modern Nix (e.g., 2.7.0) and nix-bash-completions installed breaks bash completion in the following way:

$ nix build<cursor>    # pressing TAB+TAB erases the whole line

I guess this project added completion support for nix before upstream did? I can submit a PR to remove nix completion from this project, if you like.

Complete `<...>` syntax

Ideally we should complete the correct files when using <...> syntax.

To do this correctly is a bit of work though, as we need to need to merge several directories and resolve any ambiguity using the order of NIX_PATH.

Cannot complete `nix-build -A ...` more than three levels deep

To reproduce, add this expression to e.g. ./test.nix:

with import <nixpkgs> {};

{
  a.b.c.d.e.f.g.h = bash;
}

and try to complete. It will stop at the third level, like here:

$ nix-build ./test.nix -A a.b.c.

I guess it's not that common to need more than three levels in nixpkgs, but I personally could really use it for:

  • Digging into nixos attrset, I would like to go deeper here: nix-build '<nixpkgs/nixos>' -A config.system.build.
  • Some non-nixpkgs code.

Support bash completion for regex (escape character)

As described in this issue, I can't uninstall package such as libc++ with nix-env --uninstall libc++
Instead, I have to add escape character like nix-env --uninstall 'libc\+\+ or nix-env --uninstall libc\\+\\+ to get desired result.

However, current bash completion suggests libc++, so It's hard to notice that it requires escape character to match correct package. So I think it could be very helpful if bash completion suggests appropriate regex (like 'libc\+\+) instead of raw package name (libc++) since nix-env takes regex.

This issue once reported to NixOS/nix repository but bjornfor informed me that this repo is more appropriate place to claim

Can't get this working with XDG base location set for nix

I am using nix as a package manager (not NixOS) and I have set the nix files to be in XDG base locations.

$ cat /etc/nix/nix.conf
use-xdg-base-directories = true
experimental-features = nix-command flakes

I initialise nix like this (for bash):

if [ -e "$XDG_STATE_HOME"/nix/profile/etc/profile.d/nix.sh ]; then
  source "$XDG_STATE_HOME"/nix/profile/etc/profile.d/nix.sh
  XDG_DATA_DIRS="$XDG_STATE_HOME/nix/profile/share:$XDG_DATA_DIRS"
fi

I don't have any problem apart from this package not working. I can't think of any other reason why it wouldn't be working.

I use zsh usually and everything works fine in that, but I'd like to fix this for bash just for completeness.

Error if extended globbing is not enabled in shell

I source _nix in my bashrc. I was getting this error when starting a new shell (on MacOS only):

bash: /Users/s/.nix-profile/share/bash-completion/completions/_nix: line 496: syntax error near unexpected token `('
bash: /Users/s/.nix-profile/share/bash-completion/completions/_nix: line 496: `                --install|-*([a-zA-Z])i*([a-zA-Z]))'

The code around line 496 is:

case "$word" in
                --install|-*([a-zA-Z])i*([a-zA-Z]))        # <-- this is line 496
                    command_options=(
                        ${nix_env_common_opts[*]}
                        ${nix_env_b[*]} $nix_env_from_profile
                        '(--preserve-installed|-P)'{--preserve-installed,-P}
                        '(--remove-all|-r)'{--remove-all,-r}
                        '(-A|--attr)'{-A,--attr}
                        ':*->installed_packages')

                    break
                    ;;

This pattern (and others in the file) use Bash Extended Globbing which was not in my shell, hence the error. The error was happening with bash installed with homerew and with nix. Interestingly on my linux machine I don't see the same error but possibly something else in my config there is enabling extended globbing.

The fix was to add this line to my bashrc before sourcing _nix:

shopt -s extglob

Not sure if it makes sense to just add that line to _nix itself. If not I think this error message and solution should be added to the readme.

Parse the alias flags too, like zsh

It should be possible to check if eg. nix-env is an alias to eg. nix-env -f '<nixpkgs> and parse that too, so do an ad-hoc implementation of how zsh handles aliasing.

It doesn't seem like completions for nixops are actually working

I tried:

  1. Setting programs.bash.enableCompletion = true; in my nixos config. This appears to enable completions for most nix related commands, but nothing for nixops.
  2. With enableCompletion = true still, cloning this repo and sourcing _nix, which doesn't change anything for nixops.
  3. Rebuilding with enableCompletion = false (and verifying that I no longer have completions for any nix commands), and attempting to source _nix leads to bash: _nix: line 496: syntax error near unexpected token '('.

Related: NixOS/nixops#849

Syntax error on OSX

I'm getting syntax errors when trying to run the bash completion scripts on OSX. I have 0.6.4 installed with bash version 3.2.57(1). Any ideas what might be wrong?

nix: line 342: syntax error near unexpected token `;;'
nix: line 342: `            ;;'
nix: line 343: syntax error near unexpected token `)'
nix: line 343: `        -*)'

Completion on available packages

Hi, I installed nix 1.11.15 with $ curl https://nixos.org/nix/install | sh on Fedora 26 and used it to install nix-bash-completions.

After sourcing the _nix file, nix-env --install <tab> shows only the installed packages, not the available packages in the store.

The installed version is 0.5. So I downloaded the master version f821d3a from this github repo and tried again. The problem is still here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.