bash-completion

Getting compgen to include slashes on directories when looking for files

梦想的初衷 提交于 2019-12-18 14:37:29
问题 I'd like to get the following behavior from my custom completion Given $ mkdir foo $ touch foo faz/bar faz/baz I'd like to get this $ foo -u <tab><tab> => foo faz/ $ foo -u fa<tab><tab> => foo -u faz/ $ foo -u faz/<tab><tab> => bar baz I assumed that compgen -f f would output foo faz/ , but it outputs foo faz which doesn't help me much. Do I need to post-process the output or is there some magic combination of options to compgen that work? 回答1: I ran into the same problem. Here's the

Slow load time of bash in cygwin

旧城冷巷雨未停 提交于 2019-12-18 10:55:11
问题 At the moment bash takes about 2 seconds to load. I have ran bash with -x flag and I am seeing the output and it seems as though PATH is being loaded many times in cygwin. The funny thing is I use the same file in linux environment, but it works fine, without the reload problem. Could the following cause the problem? if [ `uname -o` = "Cygwin" ]; then .... fi 回答1: As you've noted in your answer, the problem is Cygwin's bash-completion package. The quick and easy fix is to disable bash

A confusion about ${array[*]} versus ${array[@]} in the context of a Bash completion

你说的曾经没有我的故事 提交于 2019-12-17 06:24:51
问题 I'm taking a stab at writing a Bash completion for the first time, and I'm a bit confused about about the two ways of dereferencing Bash arrays ( ${array[@]} and ${array[*]} ). Here's the relevant chunk of code (it works, by the way, but I would like to understand it better): _switch() { local cur perls local ROOT=${PERLBREW_ROOT:-$HOME/perl5/perlbrew} COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} perls=($ROOT/perls/perl-*) # remove all but the final part of the name perls=(${perls[*]##*/})

Why are my Homebrew bash completion paths suddenly missing?

左心房为你撑大大i 提交于 2019-12-12 02:35:55
问题 Since my latest update of Homebrew, I'm suddenly getting the warnings below when attempting to set up path completion as I have always done, with commands (in my bash_profile ) such as source $(brew --repository)/etc/bash_completion.d/git-completion.bash The only thing I've done since this last worked is run brew update && echo; brew upgrade --all . How do I fix this error and restore access to my path completions. Why caused this to happen. -bash: /usr/local/Homebrew/etc/bash_completion.d

Makefile bash autocompletion issue with PHP generated targets

夙愿已清 提交于 2019-12-12 00:57:22
问题 In a large Makefile managed project, I recently added some PHP generated targets and bash completion stopped working: pressing [tab] does not trigger completion, but inserts a tab character. I isolated the issue to this minimal Makefile: # TARGETS = $(echo target1 target2) TARGETS = $(php -r 'echo "target1 target2";') # TARGETS = $(python -c 'print "target1 target2"') # TARGETS = $(ruby -e 'puts "target1 target2"') $(TARGETS): echo $@ If I use the bash-echo, python or ruby version of the

Different directory for bash_completion

◇◆丶佛笑我妖孽 提交于 2019-12-11 14:02:10
问题 To be able to enter dev my-[tab] anywhere on my system and receive auto completion like $ dev my-[tab] my-project my-awesome-project I created a file in /etc/bash_completion.d/ with the following content: _dev() { PROJECTS=$(ls /development) local cur=${COMP_WORDS[COMP_CWORD]} COMPREPLY=( $(compgen -W "${PROJECTS}" -- $cur) ) } complete -F _dev dev This works just fine, but I would also like to be able to auto-complete subfolders: [~] $ dev my-p[tab] [~] $ dev my-project/[tab][tab] src doc [~

How to give correct suggestions to tab complete when my words contains colons

对着背影说爱祢 提交于 2019-12-10 19:59:46
问题 I am writing a bash tab completion file for a utility that some times requires full URLs on the form: protocol://host:port . This contains two colons, which have proven to be problematic for tab completion. This is because the colons are treated as word breaks. I have read that I should not change COMP_WORDBREAKS directly, so I want to use the _get_comp_words_by_ref and __ltrim_colon_completions as suggested here: How to reset COMP_WORDBREAKS without effecting other completion script? This

nullglob disables pathname tab-completion

杀马特。学长 韩版系。学妹 提交于 2019-12-10 09:23:29
问题 I have found that shopt -s nullglob apparently disables tab-completion for files and directories, and shopt -u nullglob restores it. Why does tab-completion for directories apparently rely on nullglob being unset? I am using Bash 4.2.37(1)-release on Debian 7. 回答1: This is apparently a known issue with bash-completion and is listed as an objective to be fixed in the 3.0 version. But apparently it has been that way since at least 2012. See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug

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

有些话、适合烂在心里 提交于 2019-12-10 02:11:57
问题 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 /etc/git-flow-completion.bash GIT_PS1_SHOWUPSTREAM="verbose" GIT_PS1_SHOWDIRTYSTATE=true PS1='\[\033[32m\]\u@\h\[\033[00m\]:\[\033[34m\]\w\[\033[31m\]$(__git_ps1)\[\033[00m\]\$ ' When I log as root or normal_user git completion works. However if I use "sudo -s" or "sudo su" git completion is not working and I continually get "__git

Customize tab completion in shell

时光毁灭记忆、已成空白 提交于 2019-12-09 08:21:57
问题 This may be have a better name than "custom tab completion", but here's the scenario: Typically when I'm at the command line and I enter a command, followed with {TAB} twice, I get a list of all files and subdirectories in the current directory. For example: [user@host tmp]$ cat <TAB><TAB> chromatron2.exe Fedora-16-i686-Live-Desktop.iso isolate.py favicon.ico foo.exe James_Gosling_Interview.mp3 However, I noticed at least one program somehow filters this list: wine . Consider: [user@host tmp]