forked from vertelab/odootools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash_completion.odoo
96 lines (80 loc) · 1.92 KB
/
bash_completion.odoo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# bash completion for Odoo projects
_odoo_projects()
{
COMPREPLY=( $( compgen -W '$( command ls /usr/share | grep odoo)' -- $cur ) )
}
_odoo_databases()
{
local dbs='$( command sudo su postgres -c "psql -At -c \"select datname from pg_database where datistemplate = false;\" postgres" )'
COMPREPLY=( $( compgen -W "$dbs" -- $cur ) )
}
_odoohosts(){
[ -f /etc/odoo/odoo.tools ] && . /etc/odoo/odoo.tools
COMPREPLY=( $( compgen -W "$ODOOHOSTS" -- $cur ) )
}
_cdp()
{
COMPREPLY=( $( compgen -W '$( command ls /usr/share | grep odoo)' -- $cur ) )
}
complete -F _cdp cdp
_drupal_sites()
{
COMPREPLY=( $( compgen -W '$( command ls /etc/drupal/$1/sites 2>/dev/null \
| sed -e 's/[.]load$//' -e 's/[.]conf$//' )' -- $cur ) )
}
_cdd()
{
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
_drupal_sites 7
}
complete -F _cdd cdd
_cdb()
{
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
_odoo_databases
}
complete -F _cdb cdb
complete -F _cdb sqldrop
complete -F _cdb sqldump
_check_prev_words()
{
for i in `seq 0 $(expr $COMP_CWORD - 1)`; do
if [[ $1 == ${COMP_WORDS[i]} ]]; then
return
fi
done
options=$options\ $1
}
__odoosync()
{
local cur
local prev
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ $prev == -p ]]; then
_odoo_projects
elif [[ $prev == -h ]]; then
_odoohosts
else
local options
_check_prev_words -p
_check_prev_words -h
COMPREPLY=( $( compgen -W "$options" -- $cur ) )
fi
}
complete -F __odoosync odoosync
__odoo_create_test_db()
{
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
if [[ $COMP_CWORD == 2 ]]; then
COMPREPLY=( $( compgen -W "$(ls|grep .gz$)" -- $cur ) )
fi
}
complete -F __odoo_create_test_db odoocreatetestdb