Score:0

Creating a file that will open another file in VS Code when it is double-clicked

ar flag

I want to write a command in ~/.bashrcthat will create a trigger file that will open a different target file in a different folder when I double-click on the trigger file. I want the target file to open in VS Code.

The files might appear in a directory structure like this:

parentDir/
  archiveDir/
  yesterdaysDateDir/
  todaysDateDir/
    fileIWantToOpen.js

  index/
    fileIWantToDoubleClick

I understand that I can create an executable .desktop file to do this. I have found the specifications for .desktop files, but I have got lost in all the possible details.

I think that what I want might look something like this...

[Desktop Entry]
Type=Application
Terminal=true
Name=fileIWantToDoubleClick
Icon=utilities-terminal
Exec="code '../todaysDate/fileIWantToOpen.js'"
Categories=Application;

... but I am out of my depth. Any help in understanding what to do would be appreciated.

Creating a simple symbolic link does not work for me: I want to click on a file in my index directory and have it open a specific file in a specific folder, rather than launch a clone with a different name from the index directory.

Score:2
uz flag

create bash file

#!/bin/bash
code '../todaysDate/fileIWantToOpen.js'

make it executable by running this command in the terminal chmod +x fileIWantToDoubleClick

double-click on it to open the file

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.