66

Found it!! It seems that in Ubuntu the entries in ~/.ssh/known_hosts are hashed, so SSH completion cannot read them. This is a feature, not a bug. Even by adding HashKnownHosts no to ~/.ssh/config and /etc/ssh/ssh_config I was unable to prevent the host hashing. However, the hosts that I am interested in are also found in ~/.ssh/config. Here is a script ...


61

Readline library has bell-style variable: Controls what happens when Readline wants to ring the terminal bell. If set to ‘none’, Readline never rings the bell. If set to ‘visible’, Readline uses a visible bell if one is available. If set to ‘audible’ (the default), Readline attempts to ring the terminal’s bell. So you can put into your ~/.inputrc ...


51

This is actually a readline feature called menu-complete . You can bind it to tab (replacing the default complete) by running: bind TAB:menu-complete You probably want to add that to your ~/.bashrc. Alternatively, you could configure it for all readline completions (not just bash) in ~/.inputrc. You may also find bind -p (show current bindings, note that ...


50

I have implemented a zsh-autosuggestions plugin. It should integrate nicely with zsh-history-substring-search and zsh-syntax-highlighting which are features ported from fish.


38

It depends on which popup menu state you are in (see :help popupmenu-completion). I understand from your question that you're in state 2 (since you've pressed arrow keys to find a completion). However, the default behavior for Enter in state 2 is to insert the completion without newline; what you describe is normally the behavior of state 1 (which is when ...


32

This seems close to what you want: bind "TAB:menu-complete" bind "set show-all-if-ambiguous on"


31

Try complete-alias, which solves this problem exactly. After install it you can use one generic function to complete many aliases like this: complete -F _complete_alias <myalias1> complete -F _complete_alias <myalias2> complete -F _complete_alias <myalias3> You may want to source the complete_alias file in every bash instance through ....


30

First of all, hitting tab in bash is even better since it autocompletes all executables in your PATH irrespecitve of whether they're in the history. That said, there are various ways of getting a command from your history: Use its number. If you know that the command you want was 3 commands ago, you can just run !-3 That will re-execute the command you ...


28

I don't know about fixing — there are all kinds of things that could go cause delays. But I can offer a few tips to investigate. Just as a guess, maybe there's a directory somewhere in a search path ($PATH, or some place where bash looks for completion data) that's on a filesystem which is slow to respond. Usually it's remote filesystems that are slow, but ...


27

Typing Ctrli sends the same character as Tab would. This should work without rebinding any keys.


27

You could make use of the builtin compgen: compgen: compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word] Display possible completions depending on the options. Intended to be used from within a shell function generating possible completions. If ...


25

It does this using bash v4's completion features. The completion code for apt-get is provided by the bash-completion package and located at /usr/share/bash-completion/completions/apt-get. Applications that have completion and are not part of the base bash-completion package place their completion scripts in /etc/bash_completion.d. The completions are loaded ...


25

Just add complete -d cd in your ~/.bashrc (or other bash configuration file).


24

Make sure that you've turned on the fancy autocompletion. On many distributions, this means your ~/.bashrc needs to contain . /etc/bash_completion. You'll need to have passwordless authentication set up, i.e. with a key that's already loaded in ssh-agent. Establishing an SSH connection is slow, so you can considerably speed up completions by establishing a ...


24

Try: autoload predict-on predict-on See: info zsh --index-search=predict-on for details.


23

At the first time, zsh Completion System seems to be very complex and difficult to grasp. Let try an example. First thing you need to know, zsh completion system will load completion functions from $fpath. Make sure your completions directory appear in: print -rl -- $fpath (If you used oh-my-zsh, there's .oh-my-zsh/completions existed in $fpath, you can ...


22

The reason that installing command-not-found did not start providing suggestions for non-installed packages was that I had missed a small notification from dpkg as part of the install. One is supposed to run the command update-command-not-found immediately after running apt-get install command-not-found. In fact dpkg prompts for running this command.


22

Instead of keeping on commenting … complete -f -X '!*.@(zip|udp)' unzip should add completion for -f -X '!*.@(zip|udp)' | | | |||________| | | | || | | | | || +- filterpat: zip or udp | | | |+------------- @ : Matches one of the given patterns | | | +-------------- *. : Anything+<dot> | | +---------------- ! : Negate | ...


21

For commands use compgen -c: $ compgen -c bas basename base64 bashbug bash basename base64 bashbug This output you can simply pipe through grep.


21

With readline 6.3 and later you can add set colored-stats on to ~/.inputrc. See https://tiswww.case.edu/php/chet/readline/rluserman.html: colored-stats If set to `on', Readline displays possible completions using different colors to indicate their file type. The color definitions are taken from the value of the LS_COLORS environment variable. ...


21

Add this to your .zshrc and ..[TAB] will complete to ../ as per bash. zstyle ':completion:*' special-dirs true


21

I don't have an OSX system handy to check on but on all *nixes, ~foo is a shorthand for the home directory of user foo. For example, this command will move into my user's $HOME (cd ~ alone will move into your home directory): cd ~terdon So, ~ and Tab will expand to all possible user names. The list should be the same as the list of users in /etc/passwd. I ...


19

compgen -c # will list all the commands you could run. compgen -a # will list all the aliases you could run. compgen -b # will list all the built-ins you could run. compgen -k # will list all the keywords you could run. compgen -A function # will list all the functions you could run. compgen -A function -abck # will list all the above in one go.


19

If your *nix box is setup as an LDAP client you may have this problem, even logged in as a local user. Boring debug info: Debugging with set-x, I found the completion that was hanging at: > set -x > ls foo<tab> ... <--- lots of output removed ... + _quote_readline_by_ref foo quoted + '[' -z foo ']' + [[ foo == \'* ]] ...


18

Debian does not come with 'bash-completion' installed and enabled. To fix this, run (as root): apt-get install bash-completion Then, you have two options. You can either (1) enable it on a per-user basis for yourself, or (2) enable it globally. If you want to enable it for just your user, edit ~/.bashrc - add the following: if [ -f /etc/bash_completion ]...


16

put set disable-completion on string in ~/.inputrc and restart your shell. it will disable completion at all.


16

Pre-packaged You don't say what distro you're using but on my Fedora 19 system I have the following package installed, bash-completion which provides this feature through this completion rule file: /usr/share/bash-completion/completions/ssh Here's the package I have installed: $ rpm -aq |grep completion bash-completion-2.1-2.fc19.noarch If you look ...


16

Oooh, I found an explanation. To quote the relevant part: The zsh shell comes with (more than one) great feature(s), such as remote tabcompletion. If you for example want to copy a file over scp, simply hit tab at any part of the filename on the remote host. zsh is able to establish an ssh session on the background, and fetch the related information ...


15

Try: _codeComplete() { local cur=${COMP_WORDS[COMP_CWORD]} COMPREPLY=( $(compgen -W "$(ls /something/)" -- $cur) ) } complete -F _codeComplete hi You need to specify the -W option in compgen and also quote the command which produces the wordlist. More information on how to write completion functions on this blog: Writing your own Bash Completion ...


15

Add source /usr/share/git/completion/git-completion.bash to your ~/.bashrc. References Arch Linux Wiki


Only top voted, non community-wiki answers of a minimum length are eligible