Questions tagged [bash-completion]

Questions about command completion in the Bash Unix shell.

310 questions
11
votes
2 answers

Detect the presence of Bash completion in bash

What is the way to detect if bash completion package is loaded in my bash shell? As of version 2.1 of bash-completion (included in Debian 8), there is no shell variable to indicate this except BASH_COMPLETION_COMPAT_DIR, which is not a reliable…
Wirawan Purwanto
  • 3,613
  • 3
  • 28
  • 28
11
votes
5 answers

bash tab completion with spaces

I'm having a problem with bash-completion when the possible options may contain spaces. Let's say I want a function which echoes the first argument: function test1() { echo $1 } I generate a list of possible completion options (some have…
geronimo
  • 839
  • 1
  • 9
  • 19
11
votes
1 answer

pip install with shell completion

I am writing a command line tool in python and using pip to distribute it. I have written some scripts (one for bash and one for zsh) to allow the tool to have tab completion. Is there a way to get pip to install these scripts when someone does a…
Nick Humrich
  • 14,905
  • 8
  • 62
  • 85
11
votes
1 answer

How to make bash tab-completion work like windows' cmd.exe?

Say I have a folder with files in it with names like this: log_1.log log_2.log log_2.gz And I want to perform some operation, let's say move, on log_2.gz. In Windows cmd.exe, I am used to performing these steps: Type move (and nothing else)…
Matt Faus
  • 6,321
  • 2
  • 27
  • 43
11
votes
1 answer

Conditional trailing space with bash programmable completion

I'm creating a function to provide programmable completion for a command that I use (with much help from http://www.debian-administration.org/articles/317). The shell script usage is as follows: script.sh command [command options] where command can…
Ceri Morgan
  • 155
  • 1
  • 6
10
votes
1 answer

Bash completion - how to get rid of unneeded tab presses?

I use cur="${COMP_WORDS[COMP_CWORD]}" opts=`sqlite3 test.db "${QUERY[COMP_CWORD]}"` SAVEIFS="$IFS" IFS=$'\n' COMPREPLY=( $(compgen -S"'" -P"'" -W "${opts}" $cur) ) IFS="$SAVEIFS" to get possible variants from the database and complete them…
sknaumov
  • 500
  • 4
  • 14
10
votes
4 answers

Git bash-completion with filename support?

is there a bash-completion script that supports filename completion? I use mostly mercurial and there I can type: hg diff test/test_ and it will show/complete all modified test files. It works for most subcommands, i.e. hg add will…
olt
  • 2,267
  • 1
  • 19
  • 13
10
votes
1 answer

Command-line autocompletion for python -m module

Is it possible to get command-line autocompletion of python -m package.subpackage.module? This is similar to, but not the same as, python ./package/subpackage/module.py, which does autocomplete the directory and file paths. However with -m, python…
Hatshepsut
  • 5,962
  • 8
  • 44
  • 80
10
votes
3 answers

Git autocomplete for custom bash functions

In my .bash_profile, I have a lot of functional shortcuts for git. For example: function gitpull() { branch="$1" if [[ -z $branch ]]; then current_branch=`git symbolic-ref -q --short HEAD` git pull origin $current_branch; …
Nxt3
  • 1,970
  • 4
  • 30
  • 52
10
votes
3 answers

Bash will not auto-complete (Tab) with files

Auto-completion in bash (with Tab) works on folders, but not with files. I'm running Ubuntu 13.10 I haven't touched my .bashrc file This is how the bottom part of the .bashrc file looks, with the bash-completion part installed and updated: #…
Finn
  • 168
  • 2
  • 3
  • 15
10
votes
6 answers

Git completion and PS1 not working: "__git_ps1: command not found" on "sudo -s" or "sudo su" on Ubuntu 12.04

I installed git and git-flow completion adding these line to .bashrc of root and a normal_user on a Ubuntu 12.04 machine: source /etc/git-completion.bash source…
Chris Cinelli
  • 4,679
  • 4
  • 28
  • 40
9
votes
2 answers

Unexpected bash directory listing with *

I have a issue with case sensitive directory listing in my bash. for example $ touch nohupa nohuPb $ ls nohup* nohupa nohuPb However I do expect it only list nohupa not nohuPb. because nohuPb has capital P. I don't know what variable…
ARH
  • 1,355
  • 3
  • 18
  • 32
9
votes
1 answer

Installing data_files in setup.py with pip install -e

I'm trying to provide a bash completion script for my CLI tool that is written in Python. According to the Python Packaging Authority, data_files in setup.py is exactly what I need: Although configuring package_data is sufficient for most needs, in…
Bastian Venthur
  • 12,515
  • 5
  • 44
  • 78
9
votes
3 answers

How to cache a variable used inside a Bash Completion Script for the current session

Inside my Bash Completion file, i'm looking up completion-strings by an external script, which takes some time (1-2 seconds). Since these strings mostly stay the same for the rest of the time the current shell runs, i want to cache them and when the…
Wolkenarchitekt
  • 20,170
  • 29
  • 111
  • 174
9
votes
2 answers

Human friendly bash auto-completion with sudo

My system is Manjaro Linux based on Arch Linux, I use bash and bash-completion. It works perfectly when I type something as regular user (no sudo) $ rfkill block event help list unblock but when I type it with sudo $ sudo…
1 2
3
20 21