DEV Community

özkan pakdil
özkan pakdil

Posted on • Originally published at ozkanpakdil.github.io on

Add `open with vscode` into context menu in linux mint cinnamon

one liner for bash

cat << EOF > ~/.local/share/nemo/actions/vscode.nemo_action
[Nemo Action]
Name=Open in VS Code
Comment=Open in VS Code
Exec=code "%F"
Icon-Name=visual-studio-code
Selection=Any
Extensions=dir;
EOF
Enter fullscreen mode Exit fullscreen mode

Add code below to ~/.local/share/nemo/actions/vscode.nemo_action

[Nemo Action]
Name=Open in VS Code
Comment=Open in VS Code
Exec=code "%F"
Icon-Name=visual-studio-code
Selection=Any
Extensions=dir;

Enter fullscreen mode Exit fullscreen mode

Then in files go to folder you want to open with VScode then right click and choose open in VS Code.

Top comments (4)

Collapse
 
smgh_smgh_6f559e984323f2d profile image
Smgh Smgh

Thank you soooooooo much

Collapse
 
zeuspod profile image
ZeusPod

thanks man

Collapse
 
carlos_alvarado_a141d2eb5 profile image
Carlos Alvarado

Perfect, thank you very much..

Collapse
 
adarsh_tech2904_b3b0e294a profile image
Adarsh Tech2904 • Edited

Open VS Code in Any File Manager Window Using a Keyboard Shortcut (No Terminal or Right-Click Needed)

If you'd like to open VS Code directly in the currently active file manager window without using the terminal or right-click context menu, here's a simple and elegant solution.

note --> before launching shortcut , first make your file manager window as an active window by clicking it .
then launch the shortcut

installation

✅ Steps:

1. Enable Full Path in File Manager Title Bar

To detect the current directory from the file manager window, you need to show the full path in the title bar:

Open any file manager window.
Go to Edit → Preferences → Display.
Enable "Show full path in the title bar".
Close file manager . reopen you will see changes .

Script to Open VS Code in the Active File Manager Window

The following script is designed for Nemo (the file manager used in Cinnamon desktops).
If you're using a different file manager (like Nautilus, Thunar, etc.), the script may need adjustments.

use chatgpt to change script , it is simple brute force logic script .
you can update it for more advance edge cases etc

paste below script in any file run.sh ,

make it executable ==> chmod +x run.sh
bind this file with a keyboard shortcut

install xdotool in your system

sudo apt update
sudo apt install xdotool

#!/bin/bash

#Get active window ID

win_id=$(xdotool getactivewindow)

#Get PID of that window

pid=$(xprop -id "$win_id" _NET_WM_PID | awk '{print $3}')

#Get process name

proc_name=$(ps -p "$pid" -o comm=)

if [[ "$proc_name" != "nemo" && "$proc_name" != "nemo-desktop" ]]; then
echo "❌ Not a Nemo window. Got: $proc_name"
notify-send "VSCode Launcher" "Not a file manager window."
exit 1
fi

#Get the window title (e.g., "Pictures — /home/user/Pictures" or "Home")

win_title=$(xprop -id "$win_id" WM_NAME | cut -d '"' -f 2)

#Determine folder path

if [[ "$win_title" == "Home" ]]; then
folder="$HOME"
else
folder=$(echo "$win_title" | grep -oE '/.*' | xargs)
fi

#Launch VSCode if the path exists

if [[ -d "$folder" ]]; then
echo "✅ Launching VSCode in: $folder"
code "$folder"
else
echo "❌ Could not determine full path from title: $win_title"
notify-send "VSCode Launcher" "Could not resolve full path from window title."
fi