1

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?

2 Answers2

1

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..

TMS
  • 131
0

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.

vanadium
  • 88,010