2

I have:

  • a bash script running in terminal that gives me a list of files from my local computer

  • phpstorm properly configured, so that I can open a file in phpstorm by typing "phpstorm /path/to/file" in terminal

Now I want the script to provide not only the list of filenames, but each filename should act as a link. Clicking on the link should have the same result as typing "phpstorm /path/to/file" in terminal.

I checked this answer Terminal - create hyperlinks, but couldn't modify it to my needs.

This doesn't work at all:

echo -e '\e]8;;phpstorm /path/to/file\aLinktext\e]8;;\a'

This does something, but opens the file in gedit:

echo -e '\e]8;;file:///path/to/file\aLinktext\e]8;;\a'

I looks like I "only" have to switch the preferred editor to phpstorm... But how would I do that?

Any ideas?

1
  • I was wondering the same. Commented Sep 8, 2022 at 17:31

1 Answer 1

0

You might want to associate the file type using XDG Mime applications.

The steps you'd take are similar to other file types you want associated with certain applications.

  1. create a mimetype and map it to the file extension, if necessary (e.g., in ~/.local/share/mime/packages/text-x-php.xml)
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
    <mime-type type="text/x-php">
        <comment>PHP source file</comment>
        <icon name="text-x-php"/>
        <glob-deleteall/>
        <glob pattern="*.php"/>
    </mime-type>
</mime-info>
$ update-mime-database ~/.local/share/mime
  1. map the mimetype to a default application (e.g., in ~/.config/mimeapps.list)
[Default Applications]
text/x-php=phpstorm.desktop

This assumes that the phpstorm.desktop file exists somewhere conventional, like for system-wide applications:

  • /usr/share/applications/
  • /usr/local/share/applications/

or local ones

  • ~/.local/share/applications/

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.