Recommend a workspace management gadget



The business lines in work are complex. Each business line corresponds to a project. There are often situations where multiple requirements are developed in parallel or problems are found in multiple projects. It is necessary to switch between different projects frequently.

When I come into contact with various new tools, I will try them myself. Sometimes half of the research may be interrupted by other things and lead to forgetting.

So I wrote a simple gadget to meet my needs:

  • You can record the workspace directory, add and delete
  • You can directly open the workspace through vs Code for editing

Introduction to gadgets

This gadget has been used for more than a year. In most scenarios, it meets my own needs and improves the development efficiency. The gadget is written in nodejs and uses inquire JS for interactive prompt, select by up and down keys, and press enter to open it with vs code. Use effect:

Recommend a workspace management gadget

Other commands (recent can be abbreviated as: R):

  • Recent add + dirname (relative address or absolute address)
  • recent del + dirname
  • Recent LS view all workspace data that has been added
  • Recent LS + STR filters the workspace data based on the input
  • Recent + STR matches according to the input and opens

Specific use

Add the code command to the environment variable

In vs code, use the shortcut key command / + Shift + P to open the command line panel and execute the shell command to install code.

Once the installation is complete, it can be passed through the command linecode .Open a file or folder in vs code.

Recommend a workspace management gadget

Link recent to global command

Because the function is relatively simple, it is not encapsulated into NPM package, and the code is placed in GitHub:tools

Execute after clone:

npm install && npm link

You can passrecent(or abbreviation)r)To manage the workspace, the code command will be called to open the workspace in vs code.


What does the installed code command do
#View code command address
which code
#View soft connection points
ls -a /usr/local/bin/code

Recommend a workspace management gadget

After finding the specific file, it is found that it is a shell script:

#!/usr/bin/env bash
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.

function realpath() { python -c "import os,sys; print(os.path.realpath(sys.argv[1]))" "$0"; }
CONTENTS="$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")"
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "[email protected]"
exit $?

Check it under MacOS:

$ELECTRONyes/Applications/Visual Studio

$CLIyes/Applications/Visual Studio

[email protected]Is the received folder or file address

Recommend a workspace management gadget

Open command

In MacOS, we can specify the application through open – A and pass the parameters:

#Open a file or folder using typora
open -a Typora 
#Open a file or folder using chrome
open -a open -a Google\ Chrome cat.png
open -a open -a Google\ Chrome .

By default, the open command opens using the file’s default application. If the file is in the form of a URL, the file opens as a URL:

#The directory is opened using finder by default
open .
#HTML opens in the default browser
open index.htmls

adopt-aParameters can specify the application to open files or directories. Other supported parameters can beopen -hsee.

Create a shortcut command for the open command

Through the open command, we can use the specified program to open the specified file or directory, but the open command is cumbersome, and we need to enter the complete program name.

If you want to pass directlytyporaOpen the markdown file and we can create a shortcut command for open.

Node. JS version:

#!/usr/bin/env node
// typora.js
const { spawn } = require('child_process')
const params = process.argv.slice(2)
spawn('open', ['-a', 'Typora', ...params]);

Create soft connection

  • Create soft connection directly

    #Add executable permissions
    chmod +x ./recent.js
    #Link to global ln - s source file absolute path local environment variable
    ln -s /User/xxx/typora.js /usr/local/bin/typora
  • Or put it in a separate directory in package Specified in JSON


    When the directory executes link, it will automatically add executable permissions and add soft connection to the local environment variable

    npm link

We can use it on the command linetyporaTo open the specified file / folder through typora. Similarly, we can create any shortcut command to open the software we want to use.

Recommend a workspace management gadget

Recommended Today

Delivery without leaving home – exclusive delivery of secret script (the second time)

Authors: Chen Nian, Congyan, Xin Yu Hello, I’m wang Xiaochui, who focuses on software application delivery! Our delivery iron triangle team (focus on delivery me, development brother tiezi, pre-sales boss Qiang brother) is here again. As an ISV enterprise providing big data analysis services, in the face of the still severe domestic epidemic situation and […]