.bash_completion.d/firefox
author Oleksandr Gavenko <gavenkoa@gmail.com>
Sun, 25 Dec 2022 21:06:07 +0200
changeset 1012 5db0edb5ff00
parent 734 da0dc50393b6
permissions -rw-r--r--
OrangeRed is not recognized by mintty, used hex code instead.

# -*- 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'  -- $cur) )
  return 0
} &&
    complete -F _firefox firefox iceweasel