To open vscode I use code .
in the directory I want to use. How can I assign a keyboard shortcut such that the command runs in the directory I am currently browsing? If it's not possible then how can I integrate vscode to my shell like in windows?

- 11
- 1
-
Currently browsing where? – muru May 23 '20 at 05:18
-
@muru whatever directory I want to – smallguyxoxo May 23 '20 at 05:48
-
1Browsing with what? – Jacob Vlijm May 23 '20 at 12:04
-
You should clarify where. A shortcut when you are on a specific path while using gnome-terminal? You probably need an alias – Pablo Bianchi May 26 '20 at 03:43
2 Answers
It seems that you want to run this command via terminal. If so, the solution can vary a lot depending on what terminal you're using, if gnome-terminal, terminator, konsole, etc. Check the 'Preferences' menu of the terminal your using and search for Shortcuts or Keybindings, again it can vary a lot..

- 131
You can achieve this using nautilus scripts. When you install nautilus scripts, a Scripts option will appear in your right-click menu. This menu contains all scripts stored under ~/.local/share/nautilus/scripts
, allowing you to run them. These scripts run in the directory you are currently browsing, so you can just use your command, code .
, as-is in your script.
This, however, still does not allow you to use a hotkey. To set that up, create a text file ~/.config/nautilus/scripts-accels
. You then can assign a hotkey, e.g. Ctrl+F12, to your script adding the following line:
F11 VSCode
VSCode is the name of the script. If you use a different name, adapt accordingly. Remember names are case sensitive. You can also use spaces in the file name of the script, and then use that name literally in scripts-accels
- no quotes or escape characters must be used.
You may need to log out and back in (or killall nautilus
) before the hotkey is taken up.

- 88,010