Last active
January 19, 2022 20:06
-
-
Save tolunayozturk/e9af49862b0695d232f252c3f277a298 to your computer and use it in GitHub Desktop.
"Open in VSCode" extension for Nautilus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: latin-1 -*- | |
# Copy this python script under ~/.local/share/nautilus-python/extensions and restart nautilus. | |
# You may need to create nautilus-python and extensions folders if they do not exist. – | |
import os | |
import gi | |
gi.require_version('Nautilus', '3.0') | |
from gi.repository import Nautilus, GObject | |
class VSCodeExtension(GObject.GObject, Nautilus.MenuProvider): | |
def __init__(self): | |
pass | |
def menu_activate_cb(self, menu, file): | |
path = file.get_location().get_path() | |
os.system("code -n " + path) | |
def get_background_items(self, window, file): | |
item = Nautilus.MenuItem(name='VSCodeExtension', | |
label='Open in VSCode', | |
tip='Open this folder in Visual Studio Code', | |
icon='') | |
item.connect('activate', self.menu_activate_cb, file) | |
return item, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment