| 1 | [wiki:howto <- Back to the HOWTO section] |
| 2 | |
| 3 | = How to use bash-completion = |
| 4 | |
| 5 | * Audience: All users |
| 6 | * Requires: - |
| 7 | |
| 8 | == Introduction == |
| 9 | |
| 10 | bash-completion is a set of bash scripts which enables customized completion for specific commands. |
| 11 | |
| 12 | This is not just for files and directories, but also e.g. for the commands of `port`. So you type `port <Tab>` and get a list of all possible commands. |
| 13 | |
| 14 | == Installation == |
| 15 | |
| 16 | === Step 1: '''Install bash-completion''' === |
| 17 | |
| 18 | {{{ |
| 19 | $ sudo port install bash-completion |
| 20 | }}} |
| 21 | |
| 22 | === Step 2: '''Enable bash-completion in your `.bash_profile` === |
| 23 | |
| 24 | You have to add bash-completion to your `.profile` or `.bash_profile`. |
| 25 | |
| 26 | First, locate the file you are using. If there is a `.bash_profile` edit this file, if there is only `.profile` you want to edit this. |
| 27 | |
| 28 | Open the file in any editor and add the following lines: |
| 29 | {{{ |
| 30 | # bash-completion |
| 31 | if [ -f /opt/local/etc/bash_completion ]; then |
| 32 | . /opt/local/etc/bash_completion |
| 33 | fi |
| 34 | }}} |
| 35 | Important: Reopen your Terminal afterwards. |
| 36 | |
| 37 | And you are done. From now on, you are able to use customized bash-completion. |
| 38 | |
| 39 | == Optional Parts == |
| 40 | |
| 41 | === '''Install +bash_completion variant automatically with all ports''' === |
| 42 | |
| 43 | Open the file `/opt/local/etc/macports/variants.conf` in any editor and add a new line: |
| 44 | {{{ |
| 45 | +bash_completion |
| 46 | }}} |
| 47 | |
| 48 | From now on, MacPorts will automatically select the bash_completion variant for all ports if available. |
| 49 | |
| 50 | [wiki:howto <- Back to the HOWTO section] |