Tools - egomobile/vscode-powertools GitHub Wiki
A set of useful and handy helpers.
Code Execution
Executes a line of (JavaScript) code.
Enter $help
to open the list of available functions and modules.
Constants
$cancel
The CancellationToken object, to check the current progress state.
$cancel.isCancellationRequested
$e
Stores the content of the active text editor, if available.
$alert( $e )
$progress
The Progress object, to control the current progress state ... s. withProgress().
$progress.report({ message: 'Hello, TM!' })
Functions
$alert(msg)
Shows a (warning) popup.
$alert("Hello, TM!")
$asc(str)
Handles a value as string and returns the ASCII (codes).
$asc("T")
$base64(val, enc?)
Converts a value to a Base64 string.
$base64("mkloubert:P@ssword123!")
$bcrypt(val, saltOrRounds?)
Handles a value as string and hashes with bcrypt.
$bcrypt("MyP@ssword123!", 10)
$bcryptcomp(val, hash)
Handles a value and a hash as strings and checks, with bcrypt, if they match.
$bcryptcomp("MyP@ssword123!", "$2a$10$JemKONAF8YtWJR88jIh52O7a2011ntsCJCzUwMC.hMIbQb1jylLs.")
$beautify()
Beautifies the code in the active editor and opens the result in a new one.
The following languages are supported:
- CSS
- HTML
- JavaScript
- JSON
- XML
$beautify
$buff(val, enc?)
Converts a value to a Buffer, if needed.
$buff('Hello, TM!', 'utf8')
$cb(val?)
Copies a value to clipboard or returns the current (text) value, if no argument is defined.
$cb("TM+MK")
$cmd(id, ...args)
Executes a Visual Studio Code command.
$cmd("editor.action.selectAll")
$cmyk(cOrHex, m?, y?, k?)
Converts CMYK color from or to hex.
$cmyk(167, 255, 4)
$code(val, lang?)
Handles a value as string to display it in a webview with syntax highlight.
$code("const TM = \'1979-09-05\';\\n\\nalert(TM);", "javascript")
$compile()
Compiles the code in the active editor and opens the result in a new one.
The following languages are supported:
- CoffeeScript
- LESS
- Pug
$compile
$csv(data)
Handles data as string in CSV format and displays them.
$csv( $GET('https://example.com/file.csv') )
$DELETE(url, body?, headers?)
Starts a HTTP DELETE request.
$DELETE("https://example.com/users/19861222")
$emojis(search?)
Returns a list of emojis, by using an optional filter.
$emojis("heart")
$excel()
Handles data as Excel workbook and displays its data.
$excel("https://example.com/myWorkbook.xlsx")
$exec()
Executes the code in the currently running editor.
$exec
$full(path)
Returns a full path.
$full("dir1/subDir1_1/myFile.txt")
$GET(url, headers?)
Starts a HTTP GET request.
$GET("https://example.com/users/19790905")
$guid(version?)
Generates a GUID.
$guid
$hash(algo, val, asBlob?)
Hashes a value.
$hash("sha1", "TM+MK")
$hsl(hOrHex, s?, l?)
Converts HSL color from or to hex.
$hsl(1, 2, 3)
$htmldec(val)
Handles a value as string, and decodes the HTML entities.
$htmldec("5979 > 23979")
$htmlenc(val)
Handles a value as string, and encodes the HTML entities.
$htmlenc("<tm>")
$img(dataOrUrl)
Handles a value as image (or image url) and displays it.
$img( "https://www.e-go-mobile.com/site/assets/files/1965/batch_ego_life_website_weiss-1600x550px.jpg" )
$insert(val)
Handles a value as string and inserts it into the selected text (or cursor) of the currently opened text editor.
$insert( $uuid )
$ip(version6?, timeout?)
Tries to detect the public IP address.
$ip(true)
$ip4(timeout?)
Tries to detect the public IP address (version 4).
$ip4
$ip6(timeout?)
Tries to detect the public IP address (version 6).
$ip6
$load(uri, headers?)
Loads data from an URI.
$load("https://www.e-go-mobile.com/site/assets/files/1965/batch_ego_life_website_weiss-1600x550px.jpg")
$ltrim(val)
Handles data as string and trims from leading whitespaces.
$ltrim(' TM + MK ')
$lower(val)
Handles data as string and converts to lower case characters.
$lower('tm + MK')
$map(...locs)
Handles geo locations and displays markers on a map.
$map("ik}tH{a|c@pg@gvO")
$map([50.782131, 6.047182], [50.775635, 6.132818])
$map({ lat: 50.782131, lng: 6.047182 }, { lat: 50.775635, lng: 6.132818 })
$map({ lat: 51.782131, lng: 7.047182 }, [51.775635, 7.132818], "ik}tH{a|c@pg@gvO")
$md(markdown)
Handles a value as Markdown string.
$md("# Header 1\\n\\nHello, TM!")
$md5(val, asBlob?)
Hashes a value with MD5.
$md5("TM+MK")
$now(timezone?)
Returns the current time with an optional timezone.
$now("Europe/Berlin")
$PATCH(url, body?, headers?)
Starts a HTTP PATCH request.
$PATCH("https://example.com/users/19790905")
$polyline(val)
Converts from and to polyline.
$polyline("_p~iF~ps|U_ulLnnqC_mqNvxq`@")
$POST(url, body?, headers?)
Starts a HTTP POST request.
$POST("https://example.com/users/19790905")
$PUT(url, body?, headers?)
Starts a HTTP PUT request.
$PUT("https://example.com/users/19790905")
$pwd(length?, allowedChars?)
Generates a password.
$pwd(64)
$r(id)
Extended require() function, which also allows to access the modules of that extension.
$r("moment").utc()
$read(file, enc?)
Reads data from a file. Relative paths will be mapped to the directory of the currently opened editor or the .vscode-powertools
sub folder inside the user's home directory.
$read("myFile.txt")
$rgb(rOrHex, g?, b?)
Converts RGB color from or to hex.
$rgb(5, 9, 79)
$res(val, mapper?)
Resolves a value.
$res( Promise.resolve("TM"), s => s.toLowerCase() )
$rtrim(val)
Handles data as string and trims from ending whitespaces.
$rtrim(' TM + MK ')
$sha1(val, asBlob?)
Hashes a value with SHA-1.
$sha1("TM+MK")
$sha256(val, asBlob?)
Hashes a value with SHA-256.
$sha256("TM+MK")
$sha384(val, asBlob?)
Hashes a value with SHA-384.
$sha384("TM+MK")
$sha512(val, asBlob?)
Hashes a value with SHA-512.
$sha512("TM+MK")
$str(val, enc?)
Returns a value or object as string that is NOT (null)
and NOT (undefined)
.
$str(5979 + 23979)
$tab(val)
Opens a value as text in a new editor tab.
$tab("TM+MK")
$trim(val)
Handles data as string and trims from leading and ending whitespaces.
$trim(' TM + MK ')
$uglify()
Uglifies the code in the active editor and opens the result in a new one.
The following languages are supported:
- CoffeeScript
- CSS
- HTML
- JavaScript
- JSON
- LESS
- XML
$uglify
$unwrap(val, maxLevel?, level?)
Unwraps a value from being a function.
$unwrap(() => 5979)
$upper(val)
Handles data as string and converts to upper case characters.
$upper('tm + MK')
$utc()
Returns the current time in UTC.
$utc
$uuid(version?)
Alias for $guid
.
$uuid
$write(file, data, enc?)
Writes data to a file. Relative paths will be mapped to the directory of the currently opened editor or the .vscode-powertools
sub folder inside the user's home directory.
$write("myFile.txt", "Data to write. Can be a string, stream or buffer")
$yaml(val)
Handles a value as YAML string and returns it as object.
$yaml( $load("https://raw.githubusercontent.com/swagger-api/swagger-samples/master/java/inflector-dropwizard-guice/src/main/swagger/swagger.yaml") )
Modules
Name | Description | Example |
---|---|---|
_ |
lodash | _.isString(5979) |
$fs |
fs-extra | $fs.existsSync("/path/to/something") |
$h |
helpers | $h.normalizeString("TM+MK") |
$m |
Moment.js | $m() |
$o |
opn | $o("https://e-go-mobile.com") |
$vs |
Visual Studio Code API | $vs.commands.getCommands |
Key bindings
If you would like to define key bindings for quick access, you can use the following command:
Name | Description |
---|---|
ego.power-tools.codeExecution |
Opens the input box for executing JavaScript code. |
Generate TypeScript Code
Generates TypeScript code from JSON/JavaScript, TOML, XML/XSL or YAML (this command is only available, if you have an active, opened JSON/JavaScript, TOML, XML/XSL or YAML editor).
Keep in mind: JavaScript code will be executed and NOT parsed as JSON documents!
Send To
Sends the file of the currently, active editor to a destination.
Currently supported are:
Key bindings
If you would like to define key bindings for quick access, you can use the following command:
Name | Description |
---|---|
ego.power-tools.sendTo |
Opens the list of sub commands for send the current file to a destination. |
TCP proxies
Manages TCP proxies.
Key bindings
If you would like to define key bindings for quick access, you can use the following command:
Name | Description |
---|---|
ego.power-tools.tcpProxies |
Opens the list of sub commands for handling TCP proxies. |