Git Product home page Git Product logo

Comments (6)

fuljo avatar fuljo commented on July 17, 2024 1

Then just do the dumb thing and create a script that does both:

#!/usr/bin/env bash

# get the selection
sel=$(vscode-recent | rofi -dmenu)

if [[ -n "$sel" ]]; then
        # open in vscode (after expanding the tilde)
        sh -c "code $sel"
        # copy to clipboard
        echo -n "$sel" | xclip -selection clipboard -in
fi

You save this in ~/.local/bin/my-rofi-vscode and give it execution privileges.

Then call it from rofi-bangs.

from rofi-vscode-mode.

darkpandarts avatar darkpandarts commented on July 17, 2024 1

Sorry, just saw this! this works perfectly thank you!!! I just added a cd to this line and it's perfect!!

echo -n "cd $sel" | xclip -selection clipboard -in

Many thanks!

from rofi-vscode-mode.

fuljo avatar fuljo commented on July 17, 2024

Hi there and thanks for the appreciation!

I've read your workflow and it's for sure a common case.
It's very easy to open an external terminal in your current VSCode Workspace:

  1. Open the command palette (Ctrl+Shift+P)
  2. Use the command "Open New External Terminal" (in my config it's also bound to Ctrl+Shift+C)

To control which terminal is opened, change the setting terminal.external.linuxExec.

However, this still spawns a new terminal. Let's see what you can do to cd into a recent workspace without leaving the terminal.
From the README you can see that this project also gives you a command line tool called vscode-recent that provides the same entries as the Rofi plugin.
You can use it in combination with Rofi, fzf or dmenu to select a directory and cd into it:

cd $(vscode-recent -F absolute-path | rofi -dmenu)

I'm sure you can also bind this command to a key combo in your shell if you put some time into it.
A lazier alternative, which is what I actually use, is to install fzf in your shell, use it to look through your history with Ctrl+R and bring up the command you're looking for.

Implementing a custom "copy" functionality into the Rofi plugin seems a little overkill to me, since you still need to paste the workspace path into the terminal.

I hope this is clear enough, as I've put it together after work 😆
If it's too cryptic, let me know.

from rofi-vscode-mode.

darkpandarts avatar darkpandarts commented on July 17, 2024

This seems like a potentially viable solution! However, I'm uncertain as to how to use with rofi-bangs which is what I'm currently using as the "meta" launcher

https://github.com/gotbletu/shownotes/blob/master/rofi-bangs.md

I'm a bit new to rofi and would be very grateful if you had some advice as to how I could integrate your suggestion with terminator and rofi-bangs

This is the entry in my current rofi-bangs script:

# vscode workspace selector
COMMANDS["{vsc"]="rofi -show vscode-recent -modi vscode-recent"
LABELS["{vsc"]=""

Thanks for your patience on this! :o)

from rofi-vscode-mode.

fuljo avatar fuljo commented on July 17, 2024

My suggestion was actually to set a keybinding inside your shell (I wrote terminal before, sorry) to launch that command. So you would manually open a new terminal panel in terminator, then press some key combination like Alt-C and the Rofi menu would come up. You select the entry you want and the cd /some/directory/you/selected command is invoked. No need to pass through rofi-bangs.

However, if you prefer to stick to rofi-bangs and the copy-paste workflow you described in the first post, you can do as follows. I'm assuming you're using X11, but this would be similar in Wayland.

  1. Install xclip
  2. Add the following command to your rofi-bangs configuration
    vscode-recent | rofi -dmenu | xclip -selection clipboard -in
    Basically, all that rofi -dmenu does is getting the entries from the vscode-recent command and showing them to you. Once you select an entry, it gets passed to the xclip command, which puts the entry in your clipboard. Now you can just paste it into terminator as you originally suggested.

from rofi-vscode-mode.

darkpandarts avatar darkpandarts commented on July 17, 2024

hmmm. This seems good but it does not work as expected with rofi-bangs

Executing the following does not open the vscode window but successfully copies the workspace url:

vscode-recent | rofi -dmenu | xclip -selection clipboard -in

The following opens the dir in vscode, but fails to copy the directory

rofi -show vscode-recent -modi vscode-recent | rofi -demnu | xclip -selection clipboard -in

Is there a way to get both at once?

from rofi-vscode-mode.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.