How to Add “Open Folder in VS Code” to Nemo’s Right-Click Menu on Linux Mint
If you’re a developer working in Linux Mint, chances are you use Visual Studio Code (VS Code) as your go-to editor. It’s powerful, lightweight, and customizable. But wouldn’t it be even more convenient to open folders directly in VS Code from Nemo, Linux Mint’s default file manager?
In this guide, we’ll walk through how to customize the right-click menu in Nemo to include an option for “Open Folder in VS Code”. With just a few steps, you can streamline your workflow and save precious time.
Prerequisites
- Linux Mint (or any distro using Nemo as the file manager)
- VS Code installed (
code
command available from terminal) - Basic knowledge of terminal commands
Step-by-Step Guide
Step 1: Create a Custom Nemo Action File
Nemo allows you to define custom actions through .nemo_action
files. To add our “Open in VS Code” option, we need to create a new action file.
Open a terminal and create a new file in the following directory:
sudo nano ~/.local/share/nemo/actions/vscode-folder.nemo_action
This will open a text editor where you can define the custom action.
Step 2: Define the Action for VS Code
In the text editor, paste the following code:
[Nemo Action]
Name=Open Folder in VS Code
Comment=Open the selected folder in Visual Studio Code
Exec=code %P
Icon-Name=code
Selection=any
Extensions=dir;
- Name: This is the label that will appear in the context menu.
- Comment: This is a description that may appear as a tooltip.
- Exec: The command to run. Here,
code %P
will open the selected folder in VS Code. - Icon-Name: This sets the icon for the menu item. If you have the VS Code icon installed, it will show next to the option.
- Extensions: We specify
dir;
to ensure this option appears when right-clicking on folders.
Step 3: Save the File
After pasting the code, save the file by pressing CTRL+O
and then exit the editor with CTRL+X
.
Step 4: Restart Nemo
To apply the changes, we need to restart Nemo. Run the following command in your terminal:
nemo --quit
Then reopen Nemo by launching it from the application menu or running nemo
in the terminal.
Step 5: Test the New Menu Option
Now, navigate to any folder in Nemo, right-click on it, and you should see the “Open Folder in VS Code” option.
Bonus: Troubleshooting
If the “Open Folder in VS Code” option doesn’t appear:
- Ensure that the
code
command is available in your terminal. You can check this by runningcode
from the command line. If it doesn’t work, you might need to install the VS Code command-line tools. - Double-check that your
.nemo_action
file is correctly named and placed in~/.local/share/nemo/actions/
. - Restart your system if you still face issues after restarting Nemo.
Conclusion
With this simple tweak, you can now open any folder directly in VS Code from Nemo’s right-click menu, making your workflow smoother and faster. This method also works for other custom commands, so feel free to explore the possibilities!
Happy coding!