.bash_completion.d/firefox
author Oleksandr Gavenko <gavenkoa@gmail.com>
Wed, 29 Mar 2023 23:42:06 +0300
changeset 1018 831e2c1bf980
parent 734 da0dc50393b6
permissions -rw-r--r--
Completed migration from ~/devel to ~/work.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
{
734
da0dc50393b6 Reindent sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 725
diff changeset
     5
  local _opts="--sync --g-fatal-warnings -h -help -migration -ProfileManager \
646
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"
734
da0dc50393b6 Reindent sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 725
diff changeset
     8
  local cur prev
da0dc50393b6 Reindent sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 725
diff changeset
     9
  cur=${COMP_WORDS[COMP_CWORD]}
da0dc50393b6 Reindent sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 725
diff changeset
    10
  [[ $COMP_CWORD != 0 ]] && prev=${COMP_WORDS[COMP_CWORD-1]}
da0dc50393b6 Reindent sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 725
diff changeset
    11
  case "$prev" in
da0dc50393b6 Reindent sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 725
diff changeset
    12
    -P)
da0dc50393b6 Reindent sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 725
diff changeset
    13
      local profile=~/.mozilla/firefox/profiles.ini
da0dc50393b6 Reindent sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 725
diff changeset
    14
      if [[ ! -f $profile ]]; then
da0dc50393b6 Reindent sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 725
diff changeset
    15
          return;
da0dc50393b6 Reindent sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 725
diff changeset
    16
      fi
da0dc50393b6 Reindent sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 725
diff changeset
    17
      local names=( $(sed -n '/^Name=/{s/^Name=//;p;}' $profile) )
da0dc50393b6 Reindent sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 725
diff changeset
    18
      COMPREPLY=( $(compgen -W '${names[@]}' -- "$cur") )
da0dc50393b6 Reindent sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 725
diff changeset
    19
      return ;;
da0dc50393b6 Reindent sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 725
diff changeset
    20
  esac
da0dc50393b6 Reindent sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 725
diff changeset
    21
  COMPREPLY=( $(compgen -W '$_opts'  -- $cur) )
da0dc50393b6 Reindent sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 725
diff changeset
    22
  return 0
646
b3ada0aa23ed Bash completion for Firefox.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    23
} &&
734
da0dc50393b6 Reindent sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 725
diff changeset
    24
    complete -F _firefox firefox iceweasel