Bash completion. This functionality is called bash completion.
Bash completion This feature speeds up your workflow by reducing the amount of typing needed and helps avoid typos and misspellings that can lead to errors. Shell completion suggests command names, option names, and values for choice, file, and path parameter types. The latest version of macOS uses Zsh as its default shell, having switched from Bash with the Catalina release in Programmable completion functions for bash. What is bash completion? Bash completion is a functionality through which bash helps users type their commands faster While running the complete command on my gnome-terminal, it shows some commands. It is possible to add support for other shells too, and suggestions can be customized at multiple levels. Oct 9, 2019 · I recently worked on creating a bash completion script for registering directory aliases and navigating to them with autocomplete in Bash and I found the feature really interesting. Rather than go into detail on how to use complete, I suggest you read An Introduction to Bash Completion. Hidden commands Command-line completion Example of command-line completion in Bash. On Debian Linux, bash-completion is a set of shell functions that uses Bash’s programmable completion feature. bash-completion Introduction bash-completion is a collection of command line command completions for the Bash shell, collection of helper functions to assist in creating new completions, and set of facilities for loading completions automatically on demand, as well as installing them. Apr 26, 2025 · Bash completion is a useful functionality that allows you to auto-complete commands, filenames, and arguments within a bash shell. It allows you to auto-complete commands, options, and file names, saving time and reducing errors. What is Git Bash completion? Git Bash completion is a functionality that auto-completes Git commands and object names as you type them in the terminal. Programmable Completion Builtins (Bash Reference Manual)Specify how arguments to each name should be completed. Bash completion is a powerful tool that significantly enhances your command-line experience. This is nothing new, probably you already know about this. Discover the power of bash completion to enhance your command line efficiency. It's defined like this: -C command command is executed in a subshell environ GitHub is where people build software. bash >= v4) you should use the bash-completion@2 formula instead. Nov 1, 2025 · Provides bash completion scripts for Arch Linux, enhancing command-line efficiency and user experience. Options are only listed if at least a dash has been entered. How can I insert my own local completions without having to reinsert them every time you issue a new release? A. When typing in terminal/command console, user can press ‘Tab’ key to auto-complete command, options, file path & name. The basic file and directory name completion are available by default in bash command Sep 16, 2025 · Learn how to enable bash auto complete features on a CentOS / RHEL / Fedora / Scientific, Rocky and Alma Linux using the dnf/yum. It is a reasonably good example of what shell functions must do when used for Nov 3, 2024 · B ash is a command language interpreter compatible with sh. d/* (or a different location on some systems). Bash completion scripts seem overly complex to you. For clarity, I rewrote these instructions below in a more beginner-friendly manner. Jan 27, 2025 · Learn how to install and enable bash command autocomplete (auto completion) on Alpine Linux to increase productivity. The following function provides completions for the cd builtin. Part 1 covers the basics and Part 2 gets into how you would go Jul 6, 2024 · In fact, the git-completion. 8 A Programmable Completion Example ¶ The most common way to obtain additional completion functionality beyond the default actions complete and compgen provide is to use a shell function and bind it to a particular command using complete -F. bash_completion file. Mar 14, 2013 · I currently have a Bash completion file which completes a single parameter from a list of allowed commands for a script called pbt. Our guide reveals tips and tricks for seamless navigation. Mar 18, 2024 · Learn how to use the complete and compgen commands to set up Bash completion for any command in Linux. This functionality is called bash completion. What are they? And what is the use of complete command? $ complete complete -F _minimal complete -F _filedir_xspec Jan 19, 2024 · For bash, the best way to enable autocomplete is to install bash-completion. If you are using Homebrew’s bash as your shell (i. This saves time, increases efficiency, and enhances the user experience when working in a terminal environment. These commands install the completions and Sep 16, 2025 · I set up a new cloud server, but my auto-completion of bash shell commands are not working. This tool is for you if: You develop your own command line tools. The actual completion performed is application-specific. If you want to tweak this yourself, you will find plenty of examples in the Bash Completion package. Put them in ~/. e. Let's see how it works. Bash attempts completion by first checking for any programmable completions for the command word (see Programmable Completion), otherwise treating the text as a variable (if the Completely is a command line utility and a Ruby library that lets you generate bash completion scripts from simple YAML configuration. This page provides instructions on installing and enabling Bash auto-completion on Debian Linux versions 10, 11, and 12 to increase productivity by writing custom bash code. Command-line completion (also tab completion) is a common feature of command-line interpreters, in which the program automatically fills in partially typed commands. Note that if you are building bash command line scripts with bashly, then this functionality is One alternative is the comprehensive bash-completion package, which completes all CLI options for GNU-compatible tools (Figure 1) and valid package names for the RPM command; it even knows the modules in CVS. Oct 6, 2019 · Ever wondered how Bash completion works? In this first article on the topic, we’ll look at how it works under the hood. Discover how to install bash autocomplete effortlessly. On most systems you need to configure this manually. The article also provides a detailed tutorial on script creation, installation, and debugging, ideal for both novice and advanced users Dec 7, 2018 · Once mastered, bash completions scripts will greatly improve your terminal experience and make you more productive. The basic structure of this file is a simple function that performs the completion and then invocation of complete which is a bash builtin. Contribute to scop/bash-completion development by creating an account on GitHub. Your life feels empty without bash completions. I author/maintain package X and would like to maintain my own completion code for this package Jul 3, 2019 · Notes on Bash auto-completion on Linux July 3, 2019 Welcome to this new blog post! Introduction Setting up DIY bash completion Data provided to completion handlers Single <TAB> and double <TAB><TAB> Getting good old BASH completion back Magic of bash-completion package compgen built-in command Learning more Bash completion for applications cobra (Golang), click (Python) and clap (Rust compgen -A command <command_prefix> (u1686_grawity's comment about completion depending on the position of the cursor in the command line is still relevant, but the command above does work for the case of starting to type a command at the beginning of the line) Commands For Completion (Bash Reference Manual)8. Mar 22, 2018 · Learn how to create a Bash script that helps users type their commands more quickly and easily by presenting possible options when they press the Tab key. If there are no other subcommands, the default completion command will be hidden, but still functional. The following procedure enables tab completion for the Bash shell. real xtrapinfo xtrapreset xtrapchar xtrapout xtrapstatsbash$ xtrac [Tab]xtraceroute xtraceroute Apr 2, 2021 · Configure Bash Auto-Completion (Tab Completion) on Linux What to do when the auto-completion of bash shell commands are not working. This guide simplifies the process, enhancing your command line experience with speed and precision. See also the next question. These functions are registered with the complete built-in (e. Bash attempts completion by first checking for any programmable completions for the command word (see Programmable Completion), otherwise treating the text as a variable (if the Home / Manuals / Docker Engine / CLI / Completion Page options Bash Zsh fish Bash # Install using APT: sudo apt install bash-completion # Install using Homebrew (Bash version 4 or later): brew install bash-completion@2 # Homebrew install for older versions of Bash: brew install bash-completion # With pacman: sudo pacman -S bash Shell Completion Click provides tab completion support for Bash (version 4. This article tackles the technical details of implementing a bash completion script using pure bash. bash-completion is a collection of command-line command completions for the Bash shell, a collection of helper functions to assist in creating new completions, and a set of facilities for loading completions automatically on-demand, as well as installing them. For information on the AWS CLI version 2 auto-prompt feature instead, see Enabling and using command prompts in the AWS CLI. Configuring Completions in zsh To make Homebrew’s completions available in zsh programmable completion for the bash shell. bash-completion is a collection of command line command completions for the Bash shell, collection of helper functions to assist in creating new completions, and set of facilities for loading completions automatically on demand, as well as installing them. Follow a tutorial with examples of static and dynamic completion, and how to register the script for a custom executable. According to this page ("Turn on Bash Smart Completion") on Ubuntu Blog, it is as easy as editing your bash. Sep 18, 2017 · I want completion like in emacs that if there is only a sole completion to the command you are typing, than you don't need to type it all. Q. Here's how to set it up. 4. 04. complete -F _find find tells bash to call the _find function when you press Tab on a find Use a ~/. In bash, it's easy enough to set up customized completion of command arguments using the complete built-in. Apr 30, 2011 · Depending on the command: Someone may have written a function to generate possible completions of arguments, including options. Enabling Dec 2, 2013 · In Linux, while typing a command if you press TAB twice, it would list all available commands that starts with typed characters. In this tutorial we learn how to install bash-completion on Ubuntu 22. This guide delves into mastering Bash completions, showcasing how to enhance command-line efficiency by writing and customizing bash completion scripts. See how to define and invoke custom functions, use word lists, and filter options during tab completion. If you broke something done and the feature does no longer work Cobra can generate shell completions for multiple shells. For example: package ins is enough instead of typing the Dec 7, 2018 · We end with links to step-by-step tutorials. Example of command-line completion in PowerShell with Intellisense. It is an sh-compatible command language interpreter that executes commands read from the standard input or from a file . bash-completion is programmable completion for the bash shell Commands For Completion (Bash Reference Manual)8. g. It’s something which we expect these days to happen by … Mar 9, 2024 · By way of the Tab key, Bash Completion can autocomplete your thorniest Linux and Docker commands. 4 and up), Zsh, and Fish. From the Bash Completion FAQ: Q. You'll find functions for some commands in /etc/bash_completion. In this article, we focus on the process of creating a bash completion script 8. Autocomplete—found everywhere from text messaging apps to IDEs—can seem like a fairly modern innovation, but it’s been present in various forms of Unix since the early 80s, if not earlier. This feature is quite useful and available out-of-the-box for every user with home directory. Bash completion overview The complete command defines the completion candidates for a command. This guide will provide an in-depth look at enabling and using Git Bash completion on Windows. May 22, 2023 · The ‘Tab’ key bash auto-completion does not work for you? Here’s how to re-enable this feature in Ubuntu. 6 Letting Readline Type For You ¶ complete (TAB) ¶ Attempt to perform completion on the text before point. bash$ xtra [Tab]xtraceroute xtrapin xtrapproto xtraceroute. d/. Aug 17, 2025 · Find out how to take the first steps by building a simple Bash and zsh auto-complete script. Sep 16, 2025 · Learn how to install and enable bash-completion package on Ubuntu Linux to automatically complete file names, commands and more. When the user attempts word completion for a command or an argument to a command for which a completion specification (a compspec) has been defined using the complete builtin (see Programmable Completion Builtins), Readline invokes the programmable completion facilities. It can execute commands read from a file or keyboard. How do I enable autocomplete feature in CentOS 8 (CentOS Enterprise Linux 8)? How do I write simple bash completion code in CentOS 8? Introduction: Bash is a free and open source shell. Homebrew’s package index Oct 31, 2025 · Download bash-completion for free. Let’s dive into how you can set up and leverage for a more How do I add functionality to my command line scripts, so they too can offer auto completion for commands? (I have googled, but only get stuff about how to use it, and completion via history file) The easiest way of doing this is to include a shell script in /etc/bash_completion. It handles the autocomplete functionality while typing commands and pressing tabs. The main article about bash completion tweaking is: Faster workflow using bash completion scripts. The AWS Command Line Interface (AWS CLI) includes a bash-compatible command-completion feature that enables you to use the Tab key to complete a partially entered command. Bashly comes with a built-in bash completions generator, provided by the completely gem. bash script is originally based on code that came with bash-completion: It comes pre-installed on some Linux systems, such as Ubuntu. The currently supported shells are: Bash Zsh fish PowerShell Cobra will automatically provide your program with a fully functional completion command, similarly to how it provides the help command. Jul 31, 2018 · If you have the bash-completion package installed (or however it is named on your system), completions for a lot of commands are installed, and as Wrikken said, /etc/bash_completion contains a bash script which is then often executed at shell startup to configure this. More than 150 million people use GitHub to discover, fork, and contribute to over 420 million projects. Contribute to GArik/bash-completion development by creating an account on GitHub. bash-completion is a set of bash scripts that enables customized completion for specific commands. In this post I will familiarize you with the process of adding bash completion to your scripts. [1] If multiple completions are possible, then [Tab] lists them all. Dynamic completion is done through a bash function provided to complete -F: when you hit tab, bash will call a given function responsible to generate completion candidates, then print those candidates. It covers the basics, installation on various Linux distributions, and steps for enabling the feature. The -r option removes a completion specification for each name, or, if no name s are supplied, all completion Programmable completion functions for bash. If the -p option is supplied, or if no options or name s are supplied, print existing completion specifications in a way that allows them to be reused as input. bash-completion is a collection of command line command completions for the Bash shell, collection of helper functions to assist in creating new completions, and set of facilities for loading completions automatically on demand, as well as installing them. After you install the OpenShift CLI (oc), you can enable tab completion to automatically complete oc commands or suggest options when you press Tab. This is the working Bash completion file: _pbt_complete() { l When creating shell completion functionality in bash, it seems like the -C option would be powerful and common. bashrc file. Nowadays most completions are located in the directory given by command pkg-c onfig --variable=completionsdir bash-completion` and that directory is the recommendation given by Bash Completion FAQ linked above. Introduction Bash Completion: Are you spending too much time typing out lengthy Linux commands or struggling to remember Docker command options? Boost your terminal productivity with Bash Completion! This powerful tool helps automate your workflow by filling in partially typed commands and arguments with a simple tap of the tab key. Programmable completion functions for bash. See examples of bash completion code and how to test it with host command. For example, for a hypothetical command with a synopsis of foo --a | --b | --c you could Mar 1, 2018 · A tutorial for adding tab completion to your scripts using the Bash Programmable Completion functionality. If you install the bash-completion formula, this will automatically source the completions’ initialisation script (so you do not need to follow the instructions in the formula’s caveats). Jul 23, 2025 · The complete command is not a separate package rather it's a built-in command for the bash shell. bash_completion, which is parsed at the end of the main completion script. The programmable completion feature in Bash permits typing a partial command, then pressing the [Tab] key to auto-complete the command sequence.