Hot answers tagged


To rebuild the cache of executable commands, use rehash or hash -rf. Make sure you haven't unset the hash_list_all option (it causes even fewer disk accesses but makes the cache update less often). If you don't want to have to type a command, you can tell zsh not to trust its cache when completing by putting the following line in your ~/.zshrc¹: zstyle ":...


Pressing Ctrl+R will open the reverse history search. Now start typing your command, this will give the first match. By pressing Ctrl+R again (and again) you can cycle through the history. mysq(Ctrl+R) Would give: mysqldump --add-drop-table -e -q -n -C -u Ctrl+R again: mysql -u ben.dauphinee -p


There aren't that many bash completion tutorials around, but this one is pretty good: Introduction to Bash Completion Part 1 is for general knowledge Part 2 covers creating scripts in /etc/bash_completion.d/


To expand on what Gilles said, I have the following in my .inputrc to bind the up/down arrow key to history-search-backward and history-search-forward: # Key bindings, up/down arrow searches through history "\e[A": history-search-backward "\e[B": history-search-forward "\eOA": history-search-backward "\eOB": history-search-forward Just type something (...


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


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 ...


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 ...


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.


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. ...


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 ...


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 ~/....


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 ...


There is a great thread about this on the Ubuntu forums. Ole J proposes the following alias completion definition function: function make-completion-wrapper () { local function_name="$2" local arg_count=$(($#-3)) local comp_function_name="$1" shift 2 local function=" function $function_name { ((COMP_CWORD+=$arg_count)) COMP_WORDS=( ...


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


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 ...


The easiest way of doing this is to include a shell script in /etc/bash_completion.d/. The basic structure of this file is a simple function that performs the completion and then invocation of complete which is a bash builtin. Rather than go into detail on how to use complete, I suggest you read An Introduction to Bash Completion. Part 1 covers the basics ...


Add the following to your .inputrc file, (exact location varies between systems): "\C-i": menu-complete This maps TAB to menu-complete, which auto-completes the first match. Then add (or uncomment) show-all-if-ambiguous, this shows the list of possible completions on the first TAB press. Alternatively, you can set menu-complete per session (without ...


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


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


Redirecting the standard error immediately to /dev/null is a bad idea as it will hide early error messages, and failures may be hard to diagnostic. I suggest something like the following start-app zsh script: #!/usr/bin/env zsh coproc "$@" 2>&1 quit=$(($(date +%s)+5)) nlines=0 while [[ $((nlines++)) -lt 10 ]] && read -p -t 5 line do [[ $(...


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 ...


Depending on the command: Someone may have written a function to generate possible completions of arguments, including options. You'll find functions for some commands in /etc/bash_completion.d/* (or a different location on some systems). These functions are registered with the complete built-in (e.g. complete -F _find find tells bash to call the _find ...


You can bind the completion command to any key sequence. Pick something that's easy to type but unlikely to appear in a normal command, like say capital A. Put bind "A":complete in ~/.bashrc, and new bash instances will use capital A as well as TAB to invoke completion.


I would start by looking at the library of bash completions already put together by the folks here: They also have a mailing list:


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.


With readline 6.3 and later you can add set colored-stats on to ~/.inputrc. See 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 ...


It's because the caret is often used to signify the ctrl key having been pressed, or that it's otherwise a control character. The key sequence that you actually typed was this: cp filename.xsl .ctrl+Vbackspace~Enter You were presumably trying to copy the file to your home directory (~). You can repeat this by typing ctrl+Vbackspace. You'll see ^? printed ...


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.


You can do this easily by setting rm's completion to an empty wordlist. complete -W "" rm Set it in /root/.bashrc if you only want it to apply to root.


Those are commands. If you start typing on the commandline and hit Tab, it won't expand the subdirectories and files of your location but available commands. Basically, tab completion is context sensitive. If you just start writing and hit Tab, it will complete commands found in your $PATH. If you have already written a command, cd for example, it will ...

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