Code Monkey home page Code Monkey logo

get-this's Introduction

What does this extension do?

Get This! watches for changes to your active editor tab and will set an environment variable named THIS (in the integrated terminal) to the path of the active file.

Why?

Now whenever you switch editor tabs, you'll have access to the active file's path in the integrated terminal without having to...

  • right-click on the file in the sidebar and select "Open in Integrated Terminal"
  • right-click on the file in the sidebar and select "Copy Path" or "Copy Relative Path"
  • cd out of your current working directory to work with a different file path
  • open another terminal

Instead, you can simply use the environment variable: THIS

How?

Once installed, Get This! starts up automatically with VS Code.

To use it, simply open a new integrated terminal window and use THIS like any other environment variable, e.g.:

Mac OS, Linux

echo $THIS

Windows

echo %THIS%

How, specifically?

Specifically, Get This! sets the following configuration in your global settings.json file:

Mac OS

"terminal.integrated.env.osx": {
    "THIS": "<path to most recently active editor>"
}

Windows

"terminal.integrated.env.windows": {
    "THIS": "<path to most recently active editor>"
}

Linux

"terminal.integrated.env.linux": {
    "THIS": "<path to most recently active editor>"
}

This configuration is updated whenver you change your active editor to a tab with a valid file in it.

Don't worry, if you happen to have any other evnironment variables already set in terminal.integrated.env, Get This! will leave them alone (unless you happen to have one named THIS)

Tips and Tricks

  • THIS is case-sensitive, so remember to use all caps! $this won't work, but $THIS will
  • If THIS seems like it's stuck on a previous file path, close the integrated terminal and reopen it
    (looking for a better solution for this...)
  • THIS only exists in VS Code's integrated terminal, so you won't be able to access it from an external terminal, i.e. your OS's terminal
  • The value of THIS is updated as soon as an editor tab with a valid file path is selected, so if you're opening VS Code it will update to the path of any restored editor tab as well
  • The most recent value of THIS is stored in your global settings.json
  • Get This! only updates THIS if the file in the active editor has been saved - it doesn't work on new "Untitled" files

Requirements

Get This! has been developed and tested on...

Visual Studio Code
Version: 1.87.2 (Universal)
Commit: 863d2581ecda6849923a2118d93a088b0745d9d6
Date: 2024-03-08T15:21:31.043Z
Electron: 27.3.2
ElectronBuildId: 26836302
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Darwin arm64 23.3.0

but is designed to run on Mac OS, Windows and Linux and should work with most versions of VS Code

Extension Settings

None...yet?

Known Issues

None so far!

Release Notes

0.0.1

Initial development of Get This!

get-this's People

Contributors

jriggles avatar

Watchers

 avatar

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.