How to make firefox command autcomplete SVG file paths when I press tab key
You can do this by modifying the bash-completions
definition for Firefox. If you need autocomplete support for a limited number of files, then something like this would work:
-
Open Terminal (if it's not already open)
-
Open the appropriate completions file for Firefox with
sudo
:sudo {editor of choice} /usr/share/bash-completion/completions/firefox
Note: Be sure to replace
{editor of choice}
with your editor of choice. -
Around line 42, you will see this:
_filedir "@(?([xs])htm?(l)|pdf)"
This is the line that controls what sort of file extensions are available as an autocomplete for Firefox. Here we can see support for
.htm
,.html
,.xhtm
,.xtml
,.xshtm
,.xshtml
, and.pdf
. You can add additional file extensions afterpdf
:_filedir "@(?([xs])htm?(l)|pdf|svg|jpg|jpeg|png|gif)"
Here I've added
.svg
,.jpg
,.jpeg
,.png
, and.gif
. Feel free to add/remove as needed. -
Save the file.
-
Reload your bash source:
source ~/.bashrc
Note: Alternatively, you can close the terminal and re-open it. If you have any other Terminal windows (or SSH connections) open, then the source will need to be reloaded in each before they can use this autocompletion.
Additionally ...
If you would like autocomplete to allow any file to work with Firefox regardless of the browser's ability to render the information, then you can remove everything after _filedir
to leave a blank:
_filedir
This will allow you to autocomplete nonsensical things like:
firefox ~/Documents/backup.sql.gz