autocomplete : add info about IFS.
This commit is contained in:
parent
758651edac
commit
b5e04275a6
|
@ -2,7 +2,7 @@
|
|||
|
||||
Here is basic guide.
|
||||
|
||||
Lets have an example of script called admin.sh to which you would like to have autocomplete working.
|
||||
Let's have an example of script called admin.sh to which you would like to have autocomplete working.
|
||||
|
||||
```bash
|
||||
#!/usr/bin/bash
|
||||
|
@ -37,6 +37,7 @@ And here you have the autocomplete.sh script:
|
|||
#!/usr/bin/bash
|
||||
|
||||
_script() {
|
||||
local IFS=$'\n' # If we need to support spaces.
|
||||
_script_commands=$(/path/to/your/admin.sh shortlist)
|
||||
|
||||
local cur prev
|
||||
|
@ -46,7 +47,7 @@ _script() {
|
|||
return 0
|
||||
}
|
||||
|
||||
complete -o nospace -F _script /path/to/your/admin.sh
|
||||
complete -o nospace -o filenames -F _script /path/to/your/admin.sh
|
||||
```
|
||||
|
||||
Note that the last argument to complete is the name of the script you want to add autocompletion to. All you need to do is to add your autocomplete script to ~/.bashrc or /etc/bash_completion.d as:
|
||||
|
@ -157,3 +158,7 @@ _tb_containers()
|
|||
|
||||
complete -F _tb_containers tb tbk tb_rpmfusion
|
||||
```
|
||||
|
||||
# Spaces support.
|
||||
|
||||
Use `local IFS=$'\n'` and add an option `complete -o filenames`.
|
||||
|
|
Loading…
Reference in a new issue