author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Thu, 19 Feb 2015 22:59:26 +0200 | |
changeset 725 | 840b60ed51c7 |
parent 646 | b3ada0aa23ed |
child 734 | da0dc50393b6 |
permissions | -rw-r--r-- |
646
b3ada0aa23ed
Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
1 |
# -*- mode: sh; sh-shell-file: bash -*- |
b3ada0aa23ed
Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
2 |
|
b3ada0aa23ed
Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
3 |
_firefox() |
b3ada0aa23ed
Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
4 |
{ |
b3ada0aa23ed
Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
5 |
local _opts="--sync --g-fatal-warnings -h -help -migration -ProfileManager \ |
b3ada0aa23ed
Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
6 |
-no-remote -new-instance -safe-mode -jsconsole -browser -new-window -new-tab -preferences -search \ |
b3ada0aa23ed
Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
7 |
-recording -recording-output -setDefaultBrowser" |
b3ada0aa23ed
Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
8 |
local cur prev |
b3ada0aa23ed
Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
9 |
cur=${COMP_WORDS[COMP_CWORD]} |
b3ada0aa23ed
Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
10 |
[[ $COMP_CWORD != 0 ]] && prev=${COMP_WORDS[COMP_CWORD-1]} |
b3ada0aa23ed
Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
11 |
case "$prev" in |
b3ada0aa23ed
Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
12 |
-P) |
b3ada0aa23ed
Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
13 |
local profile=~/.mozilla/firefox/profiles.ini |
b3ada0aa23ed
Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
14 |
if [[ ! -f $profile ]]; then |
b3ada0aa23ed
Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
15 |
return; |
b3ada0aa23ed
Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
16 |
fi |
b3ada0aa23ed
Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
17 |
local names=( $(sed -n '/^Name=/{s/^Name=//;p;}' $profile) ) |
b3ada0aa23ed
Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
18 |
COMPREPLY=( $(compgen -W '${names[@]}' -- "$cur") ) |
b3ada0aa23ed
Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
19 |
return ;; |
b3ada0aa23ed
Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
20 |
esac |
725 | 21 |
COMPREPLY=( $(compgen -W '$_opts' -- $cur) ) |
646
b3ada0aa23ed
Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
22 |
return 0 |
b3ada0aa23ed
Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
23 |
} && |
b3ada0aa23ed
Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
24 |
complete -F _firefox firefox iceweasel |