Questions tagged [bash-completion]

Questions about command completion in the Bash Unix shell.

310 questions
9
votes
3 answers

Bash completion for path in argument (with equals sign present)

I used to be able to type the following: $> ./foo --arg= Where foo is any program I wrote, and it would give me a list of files in the current directory, just like tab-completion normally does. I didn't have to make any changes to…
Javaxtreme
  • 313
  • 4
  • 9
8
votes
1 answer

Does bash source bash completion files in /usr/local/etc/bash_completion.d by default?

I have a bunch of bash completion files in /usr/local/etc/bash_completion.d most of the scripts in there have something like this at the bottom of them: complete -F _tmux tmux the above is for tmux. My question is - it doesn't look like bash by…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
8
votes
2 answers

cp copy command with bash brace expansion

at the bash prompt I can perform this copy cp file.txt test1.txt but if I try to copy file.txt to several files like so cp file.txt test{2..4}.txt I get error cp: target `test4.txt' is not a directory
politus
  • 5,996
  • 1
  • 33
  • 42
8
votes
1 answer

bash completion and git commit --message

I use Git on the command line. I often develop new features in git branches which are named after the Jira issues (Wikipedia: JIRA) related to them, e.g. branch "new-123" for Jira ticket "NEW-123". I have a local git prepare-commit-msg hook which…
Mikko Koivunalho
  • 331
  • 2
  • 14
8
votes
2 answers

Branch autocompletion does not work with git alias for push

I am using Git with git-completion and everything works fine with a single exception: when I do git p some_remote [TAB] I get as autocomplete suggestions the files in the current directory (wrong). p is a Git alias: $ cat ~/.gitconfig [alias] p…
adrianp
  • 2,491
  • 5
  • 26
  • 44
7
votes
3 answers

Bash completion inside backticks or $() using complete

Consider this one-liner to activate bash completion for foobar: complete -F _known_hosts foobar This shows a list of completion options for > foobar but not for > $(foobar or > `foobar I think it makes a lot…
mnieber
  • 992
  • 9
  • 23
7
votes
1 answer

Zsh function: forward completion to subfunction

Many times I end up writting wrapper function around existing ones, for instance: function gl { some_computed_stuff=... git --no-pager log --reverse $some_computed_stuff "$@" } function m { make "$@" && notify-send success || notify-send…
bagage
  • 1,094
  • 1
  • 21
  • 44
7
votes
1 answer

bash tabbing for autocompletion escapes $

In shell (GNU bash, version 4.2.47(1)-release (x86_64-suse-linux-gnu)), when I hit tab for autocompletion, the "$" is escaped after the variable name is completed, but if there is no completion then it just bells. E.g. $ ls $JDK_H results in $…
Dinesh
  • 4,437
  • 5
  • 40
  • 77
7
votes
1 answer

How to extend bash-completion with the already exist completion in another file?

For example, there is bash-completion for rar on linux, I want to extend, make more completions for the same command - rar, maybe for my own filename extension, but I don't want to touch the already existing completion script, how to start…
user3620613
  • 151
  • 1
  • 7
7
votes
1 answer

Specifying two file extensions in bash complete

I am trying to modify bash complete properties. I can exclude a file extension for a command thusly: complete -f -X '*hi' vim I want to specify two file names for exclusion. How do I do this? Note: the following command did not work. complete -f -X…
user3458168
  • 97
  • 1
  • 4
7
votes
3 answers

Bash completion: compgen a wordlist as if they were paths - Only suggest up until next slash

I'm working on a bash completion script for a dot file management utility. The tool has a command dots diff [filename] that will show the difference between the installed dot file and the source dot file. It also has a command dots files which lists…
Evan Purkhiser
  • 683
  • 6
  • 16
7
votes
5 answers

Tcsh and/or bash directory completion with variable hidden root prefix

I'm trying to set up directory completion in tcsh and/or bash (both are used at my site) with a slight twist: for a particular command "foo", I'd like to have completion use a custom function to match the first /-delimited term to an actual subtree…
Jeremy Y.
7
votes
1 answer

Why the backslash in bash?

I exported a variable in ~/.bashrc as follows (followed by source ~/.bashrc) export w=/home/user/workspace/ When I'm on commandline I try to access sub-directories of $w in following way user$ vi $w/ After this when I hit the tab key, a mysterious…
user13107
  • 3,239
  • 4
  • 34
  • 54
6
votes
4 answers

custom directory completion appends whitespace

I have the following directory structure: /home/tichy/xxx/yyy/aaa /home/tichy/xxx/yyy/aab /home/tichy/xxx/yyy/aac I would like to enter cdw y and get cdw yyy/ as a result, so I could add cdw yyy/a and get cdw yyy/aa The…
tichy
  • 501
  • 4
  • 10
6
votes
3 answers

How to complete rustup/cargo commands?

I have rustup+rust+cargo installed using the official installation script. How do I enable shell completions, to be able to type cargo in the terminal and see the possible commands such as cargo check?
AnonymousDuck
  • 171
  • 1
  • 8