bash : archive_rename : add autocompletion.
This commit is contained in:
parent
40774fd82e
commit
523404ecb3
|
@ -178,4 +178,23 @@ _archive_list()
|
|||
_autocomplete "$(ls *_*.tar.* 2> /dev/null)"
|
||||
}
|
||||
|
||||
_archive_rename()
|
||||
{
|
||||
COMPREPLY=()
|
||||
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
local prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
local command="${COMP_WORDS[0]}"
|
||||
|
||||
if [[ "${prev}" = "${command}" ]]; then
|
||||
COMPREPLY=( $(compgen -W "$(ls -a)" -- ${cur}) )
|
||||
return 0
|
||||
else
|
||||
local name="${prev%_*}"
|
||||
COMPREPLY=( $(compgen -W "${name}" -- ${cur}) )
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
complete -o plusdirs -F _archive_list archive_check unarchive
|
||||
complete -F _archive_rename archive_rename
|
||||
|
|
|
@ -4,13 +4,12 @@
|
|||
_autocomplete()
|
||||
{
|
||||
local commands="$@"
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
command="${COMP_WORDS[0]}"
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
local prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
local command="${COMP_WORDS[0]}"
|
||||
|
||||
COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) )
|
||||
return 0
|
||||
|
@ -20,13 +19,12 @@ _autocomplete()
|
|||
_autocomplete_first()
|
||||
{
|
||||
local commands="$@"
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
command="${COMP_WORDS[0]}"
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
local prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
local command="${COMP_WORDS[0]}"
|
||||
|
||||
if [[ "${prev}" = "${command}" ]]; then
|
||||
COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) )
|
||||
|
@ -38,13 +36,12 @@ _autocomplete_first()
|
|||
_autocomplete_first_ls()
|
||||
{
|
||||
local commands="$@"
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
command="${COMP_WORDS[0]}"
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
local prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
local command="${COMP_WORDS[0]}"
|
||||
|
||||
if [[ "${prev}" = "${command}" ]]; then
|
||||
COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) )
|
||||
|
|
Reference in a new issue