Giter Site home page Giter Site logo

scop / bash-completion Goto Github PK

View Code? Open in Web Editor NEW
2.8K 55.0 374.0 8.04 MB

Programmable completion functions for bash

License: GNU General Public License v2.0

Emacs Lisp 0.02% CMake 0.04% Python 28.32% Makefile 2.31% Shell 68.71% Perl 0.17% M4 0.04% Dockerfile 0.22% Awk 0.18%
bash shell completion behavior

bash-completion's Introduction

bash-completion

CI

Introduction

bash-completion is a collection of command line command completions for the Bash shell, collection of helper functions to assist in creating new completions, and set of facilities for loading completions automatically on demand, as well as installing them.

Installation

The easiest way to install this software is to use a package; refer to Repology for a comprehensive list of operating system distributions, package names, and available versions.

Depending on the package, you may still need to source it from either /etc/bashrc or ~/.bashrc (or any other file sourcing those). If you have only bash >= 4.2 installed, you can do this by simply using:

# Use bash-completion, if available
[[ $PS1 && -f /usr/share/bash-completion/bash_completion ]] && \
    . /usr/share/bash-completion/bash_completion

If you have older bash versions in use, their loading of bash_completion should be prevented. See further for more info.

If you don't have the package readily available for your distribution, or you simply don't want to use one, you can install bash completion using the standard commands for GNU autotools packages:

autoreconf -i      # if not installing from prepared release tarball
./configure
make               # GNU make required
make check         # optional
make install       # as root
make installcheck  # optional, requires python3 with pytest >= 3.6, pexpect

These commands install the completions and helpers, as well as a profile.d script that loads bash_completion where appropriate.

If your system does not use the profile.d directory (usually below /etc) mechanism (i.e., does not automatically source shell scripts in it), you can source the $sysconfdir/profile.d/bash_completion.sh script in /etc/bashrc or ~/.bashrc.

The profile.d script provides a configuration file hook that can be used to prevent loading bash_completion on per user basis when it's installed system wide. To do this:

  1. Turn off programmable completion with shopt -u progcomp in $XDG_CONFIG_HOME/bash_completion (or ~/.config/bash_completion if $XDG_CONFIG_HOME is not set)
  2. Turn it back on (for example in ~/.bashrc) if you want to use programmable completion for other purposes.

macOS (OS X)

If you're using macOS (formerly OS X), /etc/bashrc is apparently not sourced at all. In that case, you can put the bash_completion file in /sw/etc and add the following code to ~/.bash_profile:

if [ -f /sw/etc/bash_completion ]; then
   . /sw/etc/bash_completion
fi

Troubleshooting

If you find that a given function is producing errors or does not work as it should under certain circumstances when you attempt completion, try running set -x or set -v prior to attempting the completion again. This will produce useful debugging output that will aid us in fixing the problem if you are unable to do so yourself. Turn off the trace output by running either set +x or set +v.

If you are filing an issue, please attach the generated debugging output in set -x mode copy-pasted to a separate, attached file in the report. Before doing so, be sure to review the output for anything you may not want to share in public, and redact as appropriate.

To debug dynamic loading of a completion, tracing needs to be turned on before the debugged completion is attempted the first time. The easiest way to do this is to start a new shell session, and to turn tracing on in it before doing anything else there.

Known problems

  1. Many of the completion functions assume GNU versions of the various text utilities that they call (e.g. grep, sed, and awk). Your mileage may vary.

FAQ

Q. The bash completion code inhibits some commands from completing on files with extensions that are legitimate in my environment. Do I have to disable completion for that command in order to complete on the files that I need to?

A. No. If needed just once in a while, use M-/ to (in the words of the bash man page) attempt file name completion on the text to the left of the cursor. This will circumvent any file type restrictions put in place by the bash completion code. If needed more regularly, see the next question:

Q. How can I override a completion shipped by bash-completion?

A. Install a local completion of your own appropriately for the desired command, and it will take precedence over the one shipped by us. See the next answer for details where to install it, if you are doing it on per user basis. If you want to do it system wide, you can install eagerly loaded files in compatdir (see a couple of questions further down for more info. To get the path of compatdir for the current system, the output of pkg-config bash-completion --variable compatdir can be used) and install a completion for the commands to override our completion for in them.

If you want to use bash's default completion instead of one of ours, something like this should work (where $cmd is the command to override completion for): complete -o default -o bashdefault $cmd

Q. Where should I install my own local completions?

A. Put them in the completions subdir of $BASH_COMPLETION_USER_DIR (defaults to $XDG_DATA_HOME/bash-completion or ~/.local/share/bash-completion if $XDG_DATA_HOME is not set) to have them loaded automatically on demand when the respective command is being completed. See also the next question's answer for considerations for these files' names, they apply here as well. Alternatively, you can write them directly in ~/.bash_completion which is loaded eagerly by our main script.

Q. I author/maintain package X and would like to maintain my own completion code for this package. Where should I put it to be sure that interactive bash shells will find it and source it?

A. [ Disclaimer: Here, how to make the completion code visible to bash-completion is explained. We do not require always making the completion code visible to bash-completion. In what condition the completion code is installed should be determined at the author/maintainers' own discretion. ]

Install it in one of the directories pointed to by bash-completion's pkgconfig file variables. There are two alternatives:

  • The recommended directory is completionsdir, which you can get with pkg-config --variable=completionsdir bash-completion. From this directory, completions are automatically loaded on demand based on invoked commands' names, so be sure to name your completion file accordingly, and to include (for example) symbolic links in case the file provides completions for more than one command. The completion filename for command foo in this directory should be either foo, or foo.bash. (Underscore prefixed _foo works too, but is reserved for bash-completion internal use as a deprecation/fallback marker.)
  • The other directory which is only present for backwards compatibility, its usage is no longer recommended, is compatdir (get it with pkg-config --variable=compatdir bash-completion). From this directory, files are loaded eagerly when bash_completion is loaded.

For packages using GNU autotools the installation can be handled for example like this in configure.ac:

PKG_CHECK_VAR(bashcompdir, [bash-completion], [completionsdir], ,
  bashcompdir="${sysconfdir}/bash_completion.d")
AC_SUBST(bashcompdir)

...accompanied by this in Makefile.am:

bashcompdir = @bashcompdir@
dist_bashcomp_DATA = your-completion-file # completion files go here

For cmake we ship the bash-completion-config.cmake and bash-completion-config-version.cmake files. Example usage:

find_package(bash-completion)
if(BASH_COMPLETION_FOUND)
  message(STATUS
    "Using bash completion dir ${BASH_COMPLETION_COMPLETIONSDIR}")
else()
  set (BASH_COMPLETION_COMPLETIONSDIR "/etc/bash_completion.d")
  message (STATUS
    "Using fallback bash completion dir ${BASH_COMPLETION_COMPLETIONSDIR}")
endif()

install(FILES your-completion-file DESTINATION
  ${BASH_COMPLETION_COMPLETIONSDIR})

In bash-completion >= 2.12, we search the data directory of bash-completion under the installation prefix where the target command is installed. When one can assume that the version of the target bash-completion is 2.12 or higher, the completion script can actually be installed to $PREFIX/share/bash-completion/completions/ under the same installation prefix as the target program installed under $PREFIX/bin/ or $PREFIX/sbin/. For the detailed search order, see also "Q. What is the search order for the completion file of each target command?" below.

Example for Makefile.am:

bashcompdir = $(datarootdir)/bash-completion/completions
dist_bashcomp_DATA = your-completion-file

Example for CMakeLists.txt:

install(FILES your-completion-file DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/bash-completion/completions")

Q. When completing on a symlink to a directory, bash does not append the trailing / and I have to hit <Tab> again. I don't like this.

A. This has nothing to do with bash_completion. It's the default for completing symlinks to directories since bash 2.05a, and was added because sometimes you want to operate on the symlink itself, rather than what it points to.

You can get the pre-2.05a behaviour back by putting set mark-symlinked-directories on in your /etc/inputrc or ~/.inputrc file.

Q. Completion goes awry when I try to complete on something that contains a colon.

A. This is actually a 'feature' of bash. bash recognises a colon as starting a new completion token, which is often what you want when completing something like a PATH variable:

export PATH=/bin:/sbin:/usr<Tab>

Without the special treatment of the colon, the above wouldn't work without programmable completion, so it has long been a feature of the shell.

Unfortunately, you don't want the colon to be treated as a special case when doing something like:

man File::B<Tab>

Here, the colons make bash think that it's completing a new token that begins with 'B'.

Unfortunately, there's no way to turn this off. The only thing you can do is escape the colons with a backslash.

Q. Why is rpm completion so slow with -q?

A. Probably because the database is being queried every time and this uses a lot of memory.

You can make this faster by pregenerating the list of installed packages on the system. Make sure you have a readable file called /var/log/rpmpkgs. It's generated by /etc/cron.daily/rpm on some Red Hat and Mandrake and derivative Linux systems.

If you don't have such a cron job, make one:

#!/bin/sh

rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}.rpm\n' 2>&1 \
        | sort >/var/log/rpmpkgs

rpm completion will use this flat text file instead of the RPM database, unless it detects that the database has changed since the file was created, in which case it will still use the database to ensure accuracy.

Q. bash-completion interferes with my command_not_found_handle function (or the other way around)!

A. If your command_not_found_handle function is not intended to address (possibly missing) commands invoked during bash programmable completion functions, you can account for this in the function by, for example, testing if the $COMP_LINE variable is set and taking appropriate action, typically returning early and silently with success.

Q. Can tab completion be made even easier?

A. The readline(3) library offers a few settings that can make tab completion easier (or at least different) to use.

For example, try putting the following in either /etc/inputrc or ~/.inputrc:

set show-all-if-ambiguous on

This will allow single tab completion as opposed to requiring a double tab. This makes things much more pleasant, in our opinion.

set visible-stats on

This will suffix each returned file completion with a character denoting its type, in a similar way to ls(1) with -F or --classify.

set page-completions off

This turns off the use of the internal pager when returning long completion lists.

Q. Is bash the be-all-and-end-all of completion as far as shells go?

A. Absolutely not. zsh has an extremely sophisticated completion system that offers many features absent from the bash implementation. Its users often cannot resist pointing this out. More information can be found at https://www.zsh.org/.

Q. What is the search order for the completion file of each target command?

A. The completion files of commands are looked up by the shell function __load_completion. Here, the search order in bash-completion >= 2.12 is explained.

  1. BASH_COMPLETION_USER_DIR. The subdirectory completions of each paths in BASH_COMPLETION_USER_DIR separated by colons is considered for a completion directory.
  2. The location of the main bash_completion file. The subdirectory completions in the same directory as bash_completion is considered.
  3. The location of the target command. When the real location of the command is in the directory <prefix>/bin or <prefix>/sbin, the directory <prefix>/share/bash-completion/completions is considered.
  4. XDG_DATA_DIRS (or the system directories /usr/local/share:/usr/share if empty). The subdirectory bash-completion/completions of each paths in XDG_DATA_DIRS separated by colons is considered.

The completion files of the name <cmd> or <cmd>.bash, where <cmd> is the name of the target command, are searched in the above completion directories in order. The file that is found first is used. When no completion file is found in any completion directories in this process, the completion files of the name _<cmd> is next searched in the completion directories in order.

bash-completion's People

Contributors

a1346054 avatar aaronkrogers avatar akinomyoga avatar algorythmic avatar cdleonard avatar code5hot avatar dpaleino avatar felixonmars avatar fvue avatar garik avatar github-actions[bot] avatar guillomovitch avatar inconstante avatar inigomartinez avatar jakseb avatar jakuje avatar kevinoid avatar lekensteyn avatar mattulbrich avatar mgorny avatar mlichvar avatar renovate-bot avatar renovate[bot] avatar rogach avatar rrthomas avatar sathieu avatar scop avatar sftp avatar tobiasbrunner avatar yedayak 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  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  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

bash-completion's Issues

cryptsetup completion out of date

What's the update process - is there a maintainer for a specific app like cryptsetup to be pinged here, or just open a pull request personally?

alias completion broken

Hi,

i've been tinkering with aliases lately and noticed some strange behavior when it comes to tab completion:

my (demo) ~/.bash_completion looks like this:
complete -F _git gitalias

when i type
gitalias <tab>
i get gitalias bash: completion: function '_git' not found

but
git <tab>
prints the expected stuff.
Also when i type gitalias <tab> again, bash finds _git and prints the expected output.

I am using bash-completion v2.3
Do you need more info? Am I doing something wrong or is this a bug?

-bash: 404:: command not found after installation

I just installed it on a fresh MacOS 10.12.1 with brew and the only lines in my ~/.bash_profile are

if [ -f $(brew --prefix)/etc/bash_completion ]; then
    . $(brew --prefix)/etc/bash_completion
fi

the output in a new terminal is -bash: 404:: command not found
I'm not sure how to fix this or what went wrong :/

`_command_offset` allows completions on bash built-ins

When fixing the completion function for ccache, it was pointed out to me that it's possible to complete a shell built-in (e.g. read) for which there is no corresponding command. Obviously, this makes no sense for command wrappers such as ccache.

I'm not sure where the bug really is, but it seems to me that _command_offset, which is typically used in such cases, should ensure that builtins are not completed, by filtering out -b.

dequote function allows to execute arbitrary commands

I'd like to report a security issue with the dequote function inside bash, since it uses eval it allows to execute commands from the parameters passed to it. The name suggests it should only dequote and it could create security issues if somebody trust that it only does that. I'll be reporting the issue to OSS-SEC list and request for a CVE identifier which you can use when a new release is available.

# dequote  "hola"
hola
# dequote ';id'
uid=0(root) gid=0(root) groups=0(root)

Credit: Marcelo Echeverria, Fernando Muñoz

This issue was first identified on 2014 [1] but nobody cared to report it here.

[1] https://lists.gnu.org/archive/html/bug-bash/2014-04/msg00058.html

Completion for killall doesn't work

The completion for killall has a number of issues, one of them is the linux kernel 16-byte process name limitation.
Also, processes started from a directory with a space in their name, or with a space in their process name, fail.

I haven't really looked into how to write bash completion scripts, but here's how you could get a better process name list:
cut -z -d "" -f 1 /proc/*/cmdline | xargs -0 -n1 basename

long option support for tar broken with version 2.4

Try

tar --create --file test.tar <TAB>

does show only option but no files nor directories

tar --create -f test.tar -<TAB>
-A -c -d -r -t -u -x

... the same for mixed options

tar --create -f test.tar <TAB>
tar --create f test.tar <TAB>

ssh not completing from known_hosts

I've installed 2.1 from homebrew on osx, and for some reason the ssh completer for known hosts is not being run (or registered, I think). I was using an older version 1 that correctly completed via known hosts.

To confuse the matter, if I try to complete after sshfs <TAB>, that will successfully load from known_hosts. It seems that once known_hosts has been triggered, then regular ssh <TAB> will correctly list all known hosts.

The same behaviour occurs whether or not a hostname is partially written already, such as ssh dat<TAB> produces no output (unless another known_hosts completer has executed).

Bash version is 4.3.42:

$ bash -version
GNU bash, version 4.3.42(1)-release (x86_64-apple-darwin14.5.0)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

I know this isn't much to go by, so if I can provide anything extra please let me know and I'll do so happily.

Here's an example from a new terminal session:

smeatonj ~/Development
$ complete -p | grep ssh
github.com' ssh
complete -F _known_hosts ssh-installkeys

smeatonj ~/Development
$ ssh <TAB>
private.com.au github.com

smeatonj ~/Development
$ complete -p | grep ssh
github.com' ssh
complete -F _known_hosts ssh-installkeys

smeatonj ~/Development
$ sshfs <TAB>
Display all 387 possibilities? (y or n)

smeatonj ~/Development
$ complete -p | grep ssh
complete -F _ssh ssh
complete -o nospace -F _sshfs sshfs
complete -F _known_hosts ssh-installkeys
complete -F _ssh autossh
complete -F _ssh slogin

smeatonj ~/Development
$ ssh <TAB>
Display all 387 possibilities? (y or n)

allow user to complete filenames after 'set --'

User wishes to have filenames completed when hit hits TAB at

$ set -- filena<TAB>

however he is thwarted.
The only choices are

$ set -- <TAB>
allexport             functrace             interactive-comments  noglob                physical              vi
braceexpand           hashall               keyword               nolog                 pipefail              xtrace
emacs                 histexpand            monitor               notify                posix
errexit               history               noclobber             nounset               privileged
errtrace              ignoreeof             noexec                onecmd                verbose

Pray tell what good are they after --?

Why can't you let me complete filenames anymore?

bash-completion:
Installed: 1:2.1-4.3

Tests use completion files in home directory

When preparing a patch, I had unexpected test failures, which I tracked to bash-completion using BASH_COMPLETION_HOME_DIR. Presumably the test suite should clear that variable before running tests.

_file prepends "argetm" to symlinks

When completing files using _file, entries that are symlinks are prepended with "argetm" and a tab that ruins the column spacing. This seems to be because my LS_COLORS has ln=target, which indicates that symlinks should be colored the color of their target. What appears to happen is that it tries to print \e[targetm as opposed to \e[01;36m for eg, and \e[t expands to a tab character, and the rest is simply printed in front of the file name. This only happens when listing files in a directory, not when adding actual text to the command.

Reproducing:
dircolors -p >> ~/.dircolors if it doesn't already exist
edit .dircolors so that ln=target
if your .bashrc evaluates .dircolors (the default bashrc does), source your .bashrc, otherwise, run eval "$(dircolors -b ~/.dircolors)"
make sure there's a symlink in the current directory. it doesn't matter if it's dangling or not
use tab completion to list the files in the current directory, e.g., file <tabx2>
the symlink should have "argetm" at the front of its name and a tab before it, changing the column spacing

ssh: Test suite failure in Travis

https://travis-ci.org/scop/bash-completion/builds/109218638

Running ./completion/ssh.exp ...
FAIL: First argument should complete partial hostname
^C
/@_known_hosts_real ''''; echo_array COMPREPLY
::1
192.30.252.129
192.30.252.129
192.30.252.141
192.30.252.141
192.30.252.149
fe00::0
ff00::0
ff02::1
ff02::2
gist.github.com
gist.github.com
github.com
github.com
ip6-allnodes
ip6-allrouters
ip6-localhost
ip6-localnet
ip6-loopback
ip6-mcastprefix
localhost
localhost
ssh.github.com
testing-worker-linux-docker-849ac67d-3370-linux-3
testing-worker-linux-docker-849ac67d-3370-linux-3.prod.travis-ci.org
/@echo $?
0
/@ssh localhost FAIL: First argument should complete partial hostname

Not quite sure what the test is expecting, not just one "localhost" completion?

Installation location

Running on Ubuntu 16.04, the expected installation paths are different. For example

  • bash_completions was installed to /usr/local/share/bash-completion/bash_completion rather than /usr/share/bash-completion/bash_completion
  • Had to manually copy bash_completions.sh to etc/profile.d/

Unable to checkout repository on Windows

Checking out the repository using Git for Windows produces the below error:

$ git clone 'https://github.com/scop/bash-completion.git'
Cloning into 'bash-completion'...
remote: Counting objects: 22529, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 22529 (delta 2), reused 0 (delta 0), pack-reused 22519
Receiving objects: 100% (22529/22529), 3.27 MiB | 1.00 MiB/s, done.
Resolving deltas: 100% (16332/16332), done.
Checking connectivity... done.
fatal: cannot create directory at 'test/fixtures/_filedir/a"b': Invalid argument
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD'

I reported it on git-for-windows#828 but they pointed out that the repository contains files that are invalid on Windows.

These files are used in tests. Can these files be generated during the tests instead of being committed to the repository?

IFS='*' freezes bash

If you set IFS='*' then try tab completion, bash freezes and uses 100% CPU. The only way to stop it is kill -9.

I'm using Fedora 24 and bash-completion 2.3.

[RFE] allow easier reload of completions (upon updating/adding completion file)

My assumption was that after a package update that brings along it's own
completion file

source /etc/profile

would do the trick automatically in the current ssh session.

Unfortunately, that's not the case, because of
https://github.com/scop/bash-completion/blob/2.3/bash_completion.sh.in#L1:

# Check for interactive bash and that we haven't already been sourced.
if [ -n "${BASH_VERSION-}" -a -n "${PS1-}" -a -z "${BASH_COMPLETION_COMPAT_DIR-}" ]; then

where BASH_COMPLETION_COMPAT_DIR is marked as readonly variable, hence cannot be redefined/unset in the current shell session.

So while one could apparently do:

exec "$0" "$@"

it does not seem particularly appealing nor practical.

Is there a way to make bash-completion more reload-friendly?

Strange envrionment entry

Hi,

After sourcing /usr/share/bash-completion/bash_completion from bash-completion_2.1-4.3_all.deb my environment contains the entry "'><;|&(:. That prevents me from using dbus-update-activation-environment --systemd --all or systemctl --user import-environment.

make completion is slow for huge Makefiles (generated by Automake)

(This is a follow-up on the discussion of #63)

For huge Makefiles, as generated by Automake, bash completions becomes very slow (>10 seconds).

To reproduce, use huge_makefile_example.zip. Completion for make should take several seconds. On my machine, it takes about 4 seconds for the call to "make", and additionally more than 10 seconds for the call to "sed".

The archive also contains the Make database generated by

__BASH_MAKE_COMPLETION__=1 make -f Makefile -npq .DEFAULT 2>/dev/null 1>Makefile.db

README contains incomplete instructions for installation when starting from the git repo

The README says

If you don't have the package readily available for your distribution, or you simply don't want to use one, you can install bash completion using the standard commands for GNU autotools packages:

make
make check # optional, requires dejagnu and tcllib
make install # as root

but if you clone this repository, you won't find a ./configure in there.

There are two ways to improve this situation:

  1. Point the user to release tarballs that presumably have configure
  2. Tell the users to run autoconf after git clone, so a ./configure will be generated from configure.ac

I would prefer method 1, since I'm currently dealing with an RHEL machine without bash completion and with a really ancient autoconf that fails the version check.

Make completion results in sed error

When typing make and pressing <tab> for tab-completion, I get the following error:

sed: 46: /dev/fd/63: extra characters at the end of d command

This occurs for even the simplest Makefiles, e.g.

foo:

I am using bash-completion on OS X through the bash-completion2 Homebrew package, version 2.4.

OS X comes with BSD sed. This may be the cause:

Many of the completion functions assume GNU versions of the various text utilities that they call (e.g. grep, sed and awk). Your mileage may vary.

I also tried this without loading my .bashrc and .inputrc, but still encountered the issue. If no one is able to replicate the error, maybe I am unintentionally loading some other rc file...

For reference, tab-completion on make without bash-completion loaded works, although not as you would hope: it tries to complete with a list of files in the current directory.

macos 10.9

I have some error

$ source /usr/local/share/bash-completion/bash_completion
-bash: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
-bash: complete: -D: invalid option
complete: usage: complete [-abcdefgjksuv] [-pr] [-o option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [name ...]

MacOS

$ system_profiler SPSoftwareDataType
Software:

    System Software Overview:

      System Version: OS X 10.9.5 (13F1808)
      Kernel Version: Darwin 13.4.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal
      Computer Name: MacBook Pro - Mirocow
      User Name: Mirocow (mirocow)
      Secure Virtual Memory: Enabled
      Time since boot: 14 days 23:22

User

$ id
uid=501(mirocow) gid=20(staff) groups=20(staff),501(access_bpf),12(everyone),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),401(com.apple.sharepoint.group.1),33(_appstore),100(_lpoperator),204(_developer),398(com.apple.access_screensharing),399(com.apple.access_ssh)

Bash version

$ --version
GNU bash, version 4.3.42(1)-release (x86_64-apple-darwin13.4.0)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

vi tab completion doesn't work, if an file named "!" exists

I am on Ubuntu 16.04 LTS latest update. Among others I reinstall: aptitude reinstall bash-completion and I restored .bashrc: cp /etc/skel/.bashrc ~/..
The issue:
If a directory contains a file named "!" (exclamation mark), the vi tab completion shows only directories and no files. The tab completion works correct with commands like rm, cat, tail or more (even if a file named "!" exists in the directory). You can easily reproduce the issue.
Is this a problem of bash-completion?

SOLUTION:
The problem is solved by using the latest git in here!
@christian Brabandt: Thanks for the help!

Conflicts with CLICOLOR_FORCE

(The following has to do with the version of bash-completion that ships with OS X homebrew; apologies if it's not relevant to current versions.)

Various aspects of the completion scripts conflict with CLICOLOR_FORCE, an environment variable which forces ls to output terminal colour codes even when not obviously running interactively (useful for piping through less, etc).

The most glaring issue is in the have() function, which fails so that none of the completions get set up, but this only needs to happen when the bash-completion script is run, so can be fixed by setting the variable later on in the startup. But some of the scripts (e.g., for ssh) seem to rely on ls to generate filename lists on-the-fly which means that they come out mangled. For example:

$ scp .bas<tab>
^[\[34m.bash_sessions^[\[39\;49m^[\[0m/
.bashrc 

(Minor update: I've realised that for my own use case, which is really limited to needing CLICOLOR_FORCE for only one command, I've just added CLICOLOR_FORCE=1 into the function defined for it, so I don't need it globally. But this is still a minor bug, I think...)

man: not all man pages are listed if MANPATH environment is set

If MANPATH environment is set, only man pages located under directories specified by MANPATH are shown.

e.g.,

$ echo $MANPATH
/usr/share/man/openmpi-x86_64:/usr/share/lmod/lmod/share/man::
$ man ma(tab)
(no output)
$ man MPI(tab)
MPI
MPI_Abort
(snip)

$ unset MANPATH
$ man ma(tab)
mac2unix
machinectl
(snip)
$ man MPI(tab)
(no output)

As explained in manpath.1

If $MANPATH is set, manpath displays its value rather than determining it on the fly. If $MANPATH is prefixed by a colon, then the value of the variable is appended to the list determined from the content of the configuration files. If the colon comes at the end of the value in the variable, then the determined list is appended to the content of the variable. If the value of the variable contains a double colon (::), then the determined list is inserted in the middle of the value, between the two colons.

I think in the completion for man should use the output of manpath command.

I found this issue on Fedora 24 with Lmod package.

Missing wildcard support

given e.g. a directory with

graphviz-gvedit.spec
graphviz-plugins.spec
graphviz-smyrna.spec
graphviz.spec

ls *spec

does not work. That is that _longopt does not support wild cards nor the completion options are used to do that if _longopt does not return anything.

Source user's .bash_completion.d

Hello and thanks for this awesome project!

I was wondering if it is a good idea to source files from $HOME/bash_completion.d as well.

I have a couple of examples where I need to keep the files local to a single user with no access to /etc.

I know I have a single file in ~ but the script come separate and I'd like the idea to just dump stuff in a folder like in /etc.

Thanks a lot for your (and contributor's) work!

ssh: please don't complete hosts found after Hostname in .ssh/config

When there is a host configuration in ~/.ssh/config that's probably because some options should be applied when connecting to this host. So it's only sensible to complete names after "Host", but not after "Hostname" because when using the latter the options are not applied.

This is also reported to the Debian bugtracker as Bug 689585

make completion regression in 2.3

When invoked in a prepared PostgreSQL source dir, make completion no longer offers targets but falls back to filename completion. (https://bugzilla.redhat.com/show_bug.cgi?id=1352312)

The culprit is the 2nd hunk to completions/make in 4b209b0 -- if # * File is an is replaced with # File is an, the completion starts to produce good results again.

Reproducer files are available in https://scop.fedorapeople.org/bugs/make-completion-regression/make-completion-regression.tar

"tipc command<TAB>" should insert space

Hitting for example tipc socket<TAB> should insert a space and give tipc socket (i.e. a space after the trailing "t", not sure if it's visible here in browser), but currently doesn't; it does nothing. @rical, could you have a look?

Add completion for android tools

Thanks for starting adb completion file.

I've been using this completion that worked very well for me https://github.com/mbrubeck/android-completion

I see that @mbrubeck completion covers more use-cases than the one in this repo. Is it possible that you look at mbrubecks code and pull moreadb` use-cases?

There is also fastboot completion. Could you please add or pull mbrubeck's fastboot completion?

Completion script slowing down tmux startup

Every time I start tmux or open a new split/window there is a delay of about 7 seconds before the prompt appears. I'm pretty sure this is not about tmux misconfiguration, I've made a test with a blank .tmux-conf and the delay persists. On the other hand, commenting out the bit where I load bash-completion in my bashrc puts things back to normal.

This is not happening outside tmux.

Running Bash 4.3 and tmux 2.1 on OS X. Any help pointing me in the right direction would be much appreciated.

"tar tvf" and "tar xvf" do not autocomplete filenames since 2.2

[rworkman@liberty testdir]$ tar -tvf test.tar.gz
drwxr-xr-x rworkman/rworkman 0 2016-03-14 17:11 testdir/
-rw-r--r-- rworkman/rworkman 0 2016-03-14 17:11 testdir/file1
-rw-r--r-- rworkman/rworkman 0 2016-03-14 17:11 testdir/file3
-rw-r--r-- rworkman/rworkman 0 2016-03-14 17:11 testdir/file2
[rworkman@liberty testdir]$ tar tvf te
tar: te: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
[rworkman@liberty testdir]$ tar xvf te
tar: te: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now

tipc completion error

Just some random poking around tipc completion: tipc lin<TAB>ge<TAB>tol<TAB> gives tipc link get tolerance. Then hitting another tab there gives tipc link get tolerance link, and hitting another tab there spews an error:

error: No such file or directory
Unable to get TIPC nl family id (module loaded?)
error, message initialisation failed

This is on Fedora 23, non-root. @rical, could you have a look?

make completion: document how to improve relevance of results in huge Makefiles

(This is a follow-up on the discussion of #63 )

In the attached example, which is generated by Automake, the completion results contains lots of intermediate results (.o, .obj) files and the source files (.h, .cpp).

Here is the output (to reproduce, use huge_makefile_example.zip)

$ make 
Display all 2838 possibilities? (y or n)
aclocal.m4
all
all-am
am--fnord
am--force-recheck
am--refresh
attacks.cpp
attacks.h
auto_generated_cxx_root_runner__cxx.cpp
basic.cpp
basic.h
benchmark
benchmark-attacks.o
benchmark-attacks.obj
benchmark-basic.o
benchmark-basic.obj
benchmark-benchmark.o
benchmark-benchmark.obj
benchmark-bitbases.o
...

Improving the documentation about intermediate targets and noninteractive targets could help to understand how the user can improve the Makefile, so the non-relevant targets are not listed.

Unexpected EOF if $( preceded by anything

Commands like the following:

cat $(find ../<TAB>

will cause bash-completion to fail with unexpected EOF while looking for matching ')'. This is bash-completion 2.1-5 on Archlinux.

linux apt-get install no candidate package,but apt-get remove working normal!

I install bash-completion by apt-get install by apt-get install bash-completion,and then I set source /etc/share/bash-completion/completion in ~/.bashrc ,apt-get inst + tab will become apt-get install ,but
when I type apt-get install mysql+tab ,no candidate package for example mysql-server ;I hava run apt-get
update before!I am so depressed!can you give me some suggestion!

RubyGems support

It would be nice if bash-completion supported RubyGems. I just opened ticket with the script in RubyGems issue tracker, but since I am not sure where is the better place, I'll link it here as well, so I'll possible have feedback from both sides. Thx

[1] rubygems/rubygems#1627

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.