Getting compgen to include slashes on directories when looking for files

I ran into the same problem. Here’s the workaround I’m using: Register the completion function with -o default, e.g., complete -o default -F _my_completion. When you want to complete a filename, just set COMPREPLY=() and let Readline take over (that’s what the -o default does). There’s a potential problem with this — you might be … Read more

bash and readline: tab completion in a user input loop?

After trying a custom completion script that I know works (I use it every day) and running into the same issue (when rigging it up similar to yours), I decided to snoop through the bash 4.1 source, and found this interesting block in bash-4.1/builtins/read.def:edit_line(): old_attempted_completion_function = rl_attempted_completion_function; rl_attempted_completion_function = (rl_completion_func_t *)NULL; if (itext) { old_startup_hook … Read more

Bash variable expansion on tab complete

Found the bug report, please register (if not already registered) and add yourself to the ‘people affected’ list, I just did: https://bugs.launchpad.net/ubuntu/+source/bash/+bug/778627 Workarounds Try enabling direxpand or cdable_vars: shopt -s direxpand # or shopt -s cdable_vars Apparently EscTab might be a workaround: I haven’t found a proper solution to this, but there’s a workaround. The … Read more

bash completion of makefile target

Add this in your ~/.bash_profile file or ~/.bashrc file complete -W “\`grep -oE ‘^[a-zA-Z0-9_.-]+:([^=]|$)’ ?akefile | sed ‘s/[^a-zA-Z0-9_.-]*$//’\`” make This searches for a target in your Makefile titled ‘Makefile’ or ‘makefile’ (note the capital ? wildcard in ?akefile) using grep, and pipes it over to the complete command in bash which is used to specify … Read more

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

[*] (This is an expansion of my comment on Kaleb Pederson’s answer — see that answer for a more general treatment of [@] vs [*].) When bash (or any similar shell) parses a command line, it splits it into a series of “words” (which I will call “shell-words” to avoid confusion later). Generally, shell-words are … Read more

Git tab completion not working in zsh on mac

TL;DR one-liner echo ‘autoload -Uz compinit && compinit’ >> ~/.zshrc && . ~/.zshrc this will enable completion in .zshrc and apply the setting to your current terminal session. Explanation: Actually, ZSH does know how to do git completion out of the box, but you need to turn on the completion feature itself (which from the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)