Bash completion for Firefox.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Tue, 22 Oct 2013 18:49:53 +0300
changeset 646 b3ada0aa23ed
parent 645 51f6d81be3da
child 647 f1bc699634fb
Bash completion for Firefox.
.bash_completion.d/firefox
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.bash_completion.d/firefox	Tue Oct 22 18:49:53 2013 +0300
@@ -0,0 +1,24 @@
+# -*- mode: sh; sh-shell-file: bash -*-
+
+_firefox()
+{
+   local _opts="--sync --g-fatal-warnings -h -help -migration -ProfileManager \
+     -no-remote -new-instance -safe-mode -jsconsole -browser -new-window -new-tab -preferences -search \
+     -recording -recording-output -setDefaultBrowser"
+   local cur prev
+   cur=${COMP_WORDS[COMP_CWORD]}
+   [[ $COMP_CWORD != 0 ]] && prev=${COMP_WORDS[COMP_CWORD-1]}
+   case "$prev" in
+     -P)
+       local profile=~/.mozilla/firefox/profiles.ini
+       if [[ ! -f $profile ]]; then
+         return;
+       fi
+       local names=( $(sed -n '/^Name=/{s/^Name=//;p;}' $profile) )
+       COMPREPLY=( $(compgen -W '${names[@]}' -- "$cur") )
+       return ;;
+   esac
+   COMPREPLY=( $(compgen -W '$_opts $_help_cmds $_java_cmds $_application_cmds'  -- $cur) )
+   return 0
+} &&
+complete -F _firefox firefox iceweasel