A very handy Rofi menu to open recent Visual Studio Code workspacess and files, written in Rust.
Main features:
- A custom-implemented Rofi mode (a.k.a. plugin) named
vscode-recent
, to open recent workspaces and files. - The
vscode-recent
command line tool to print paths of recent workspaces and files to stdout. Pair it with a selection tool like dmenu, fzf or similar. - Entries are taken from VSCode's File->Open Recent menu.
- Delete entries from recently opened (also affects VSCode).
- Support for remote and virtual workspaces, files and folders.
- Support for different flavors: Visual Studio Code, Visual Studio Code Insiders, Code - OSS and VSCodium.
This project was largely inspired by rofi-code. Many thanks to @Coffelius for writing it, and to @SabrinaJewson for providing Rust bindings to Rofi's C plugin interface.
If you are curious, I wrote a short wiki article explaining how this tool gets the recent items and opens them.
If you're an Arch Linux user, this package is available on the AUR.
You can easily install it with an AUR helper like yay
, paru
, pacaur
, etc.
yay -S rofi-vscode-mode
You can choose to build and install only the vscode-recent
tool (binary), only the plugin or both.
First clone this repository
git clone https://github.com/fuljo/rofi-vscode-mode
Then get a Rust toolchain as you prefer.
Then install the needed dependencies
# Ubuntu / Debian
apt-get install \
build-essential pkg-config libsqlite3-dev \
rofi-dev libpango1.0-dev # only needed for the rofi plugin
# Arch
pacman -S \
make pkg-config sqlite \
rofi # only needed for the rofi plugin
Then run make
according to your choice:
# Binary and plugin
make all
sudo make install
# Binary only
make bin
sudo make install.bin
# Plugin only
make plugin
sudo make install.plugin
This library introduces a new mode named vscode-recent
.
You can run it standalone with the command
rofi -show vscode-recent -modi vscode-recent
or add it to your default modi in ~/.config/rofi/config.rasi
, like so
configuration {
modi: "drun,run,window,vscode-recent";
show-icons: true;
drun-display-format: "{name}";
window-format: "{w} | {c} | {t}";
}
I highly reccommend assigning a keyboard shortcut for this; for example I use Mod + C to run rofi -show vscode-recent
(after adding it to my default modi).
When an item is selected, press:
- Enter to open it
- Shift+Del to permanently delete it from the list
If you prefer something other than Rofi to select your entry, we also provide the vscode-recent
command that simply writes out the paths line by line. You can then pair it with your favourite selection tool, like dmenu or fzf.
You can use the -c
option to set the preferred flavor and the -F
option to set the desired ouput format:
label
(default) will show the "tildified" path, which needs to be expanded. Only local entries are not shown.sh -c "code $(vscode-recent | dmenu)"
absolute-path
will show the full path. Only local entries are shown.code $(vscode-recent -F absolute-path | dmenu)
uri
will show the local or remote URI, read this for hints on how to open it. All entries are shown.
Various aspects of this plugin can be configured with environment variables.
If you are using keyboard shortcuts to launch Rofi, make sure that these variables are set in the shell that launches Rofi, e.g. by adding an export
statement to your ~/.bash_profile
.
Configuration of the theme and everything else is left to Rofi itself.
Multiple VSCode flavors exist for Linux, see the Arch Wiki for details.
By default this plugin will try to detect a flavor for which both a command in $PATH
and a configuration directory exist.
If you want to select it by hand, set ROFI_VSCODE_FLAVOR
with one of the following values (case insensitive):
ROFI_VSCODE_FLAVOR |
Flavor | Command | Configuration directory |
---|---|---|---|
code |
Visual Studio Code | code |
~/.config/Code/ |
code-insiders |
Visual Studio Code Insiders | code-insiders |
~/.config/Code - Insiders/ |
code-oss |
Code - OSS | code-oss |
~/.config/Code - OSS/ |
vscodium |
VSCodium | codium |
~/.config/VSCodium/ |
By default icons from Rofi's current icon theme are shown besides the entries. You have three choices:
- Set
ROFI_VSCODE_ICON_MODE=none
to disable icons - Set
ROFI_VSCODE_ICON_MODE=theme
to use the icons from Rofi's current icon theme - Set
ROFI_VSCODE_ICON_MODE=nerd
to use icons from a Nerd Font.
The font can be chosen by settingROFI_VSCODE_ICON_FONT=fontname
(defaults to monospace) and its color by settingROFI_VSCODE_ICON_COLOR
to an#rrggbb
or#rrggbbaa
value.
A different icon is shown for workspaces, files and folders.
If you like this little piece of software and would like to improve it, please fork the repo and create a pull request. Your contributions are greatly appreciated.
If you want to report a problem, please open an Issue. Make sure you include your Rofi version and any error messages that are printed by running the mode from a terminal as described before.
This software is released under the MIT license.