Windows Terminal Paste Pre-Defined Text via Custom Key Bind - keyboard-shortcuts

I copy and paste different sets of pre-defined text often, so it would be nice to have a program-level key bind to set this. In the .json file key bindings section, I have tried things like:
{
"command": {
"command": "paste",
"insert": "<custom txt",
"keys": "ctrl+s"
}
}
or
{
"command": {
"command": "paste",
"commandline": "custom txt",
}
"keys": "ctrl+s"
}
.
There appears to be no action set for this in the available Windows Terminal key binding doc.

Send input: Send arbitrary text input to the shell.
Add the following item in the keybindings (or actions) array:
// Press Ctrl+S to send text (defined by the "input" field) to the shell.
// This command is not currently bound in the default settings.
{ "command": { "action": "sendInput", "input": "some custom text" }, "keys": "ctrl+s" }
ⓘ Important
As of Windows Terminal version 1.4, the keybindings array has been
renamed to actions inside the settings.json file. Support for the
keybindings array still exists for backward compatibility, however
the terminal will not automatically rename keybindings to actions
inside your settings.json file.

Related

How to prevent JupyterLab from overwriting my settings?

My JupyterLab version is 3.5.0. I want the shortcuts to be similar with vscode, and customize them at the following path (on Mac)
~/.jupyter/lab/user-settings/#jupyterlab/shortcuts-extension/shortcuts.jupyterlab-settings
but each time reopen JupyterLab, this file shortcuts.jupyterlab-settings will be overwritten, and the disabled shortcuts will be added back automatically.
For example, the disabled key
"command": "notebook:change-cell-to-markdown",
"keys": [
"M"
],
"selector": ".jp-Notebook:focus",
"disabled": true
},
will be replaced by
{
"args": {},
"command": "notebook:change-cell-to-markdown",
"keys": [
"M"
],
"selector": ".jp-Notebook:focus"
},
The following screenshot shows the differences: the LHS is my settings, and the RHS is the file shortcuts.jupyterlab-settings overwritten by JupyterLab.
How to prevent this behaviour?

Sublime Text 3 - apply shortcut only to specific file types

I am using Sublime Text 3, and I installed JSFormat to format my .js files and configured the key binding like this:
{ "keys": ["ctrl+shift+f"], "command": "js_format" }
Now, I also want to be able to format my .css and .html files, so I found this shortcut:
{ "keys": ["ctrl+shift+f"], "command": "reindent" , "args": { "single_line": false } }
I want to use js_format for my .js files and use reindent for my .css and .html files.
Is it possible to specify a file type per shortcut?
Update
This apparently no longer works in Sublime Text 4.
Update
I've since discovered that this is a duplicate of Sublime Text 3: how to bind a shortcut to a specific file extension?
Original Answer
Add a context:
{
"keys": ["ctrl+shift+f"],
"command": "js_format",
"context": [
{
"key": "selector",
"operator": "equal",
"operand": "source.js"
}
]
}
The important part is setting operand to source.js. You can replace js with whatever file extension you want. You can also specify additional sources with commas. For example, this would cause a command to apply to all .html and .css files:
{ "key": "selector", "operator": "equal", "operand": "source.html, source.css" }
See the unofficial documentation on key bindings.

How to show options in telegram bot?

I want to write a bot telegram.How to put possible option in my bot.I insert a picture of sample bot with this functionality.
For that, you have to talk to BotFather.
In the Telegram App, open the chat with BotFather.
Send him /setcommands. He will present you with a list of your bots.
Pick the bot for which you want to set the command menu.
Compose and send the command list. Using your image as an example, these 4 lines should do:
start - Description 1
menu - Description 2
help - Description 3
stop - Description 4
Note that command part of each line(left side of - signs) must have just lowercase characters, and no slashes. There should also be spaces around the - sign.
Once you complete this process, exit and kill the Telegram App. Re-open it, go to the chat with your target bot, type a / (or tab on the / button next to the text field), the command menu should come up.
New dynamic way to set commands
Telegram introduced a separate method setMyCommands which allows you to set commands via API directly from your code.
{
"commands": [
{
"command": "start",
"description": "Start using bot"
},
{
"command": "help",
"description": "Display help"
},
{
"command": "menu",
"description": "Display menu"
}
],
"language_code": "en"
}
Moreover, it allows you to customize commands per language code with language_code parameter
Without json.dumps([]) I get error response from Tlg: {'ok': False, 'error_code': 400, 'description': "Bad Request: can't parse commands JSON object"}
The code below works as expected.
{
"commands": json.dumps([
{
"command": "start",
"description": "Start using bot"
},
{
"command": "help",
"description": "Display help"
},
{
"command": "menu",
"description": "Display menu"
}
])
}
<?php
$comandos = [
["command" => "a", "description" => "aaa"],
["command" => "b", "description" => "bbb"],
["command" => "c", "description" => "ccc"],
];
defineMenuOptions($comandos);
function defineMenuOptions($comandos) {
$comandosEnc = "setMyCommands?commands=" . json_encode($comandos);
$retorno = file_get_contents(API_URL.$comandosEnc);
}
?>

Sublimetext custom key binding to Apple "cmd" button?

What is the keyword to specify the "command" button for mac?
I want to be able to press "command+t" to open a new tab, for instance.
What do I type into the keybindings file?
This doesn't work.
[
{ "keys": ["command+t"], "command": "new_tab" },
]
The proper key designation for the ⌘ key in OS X as well as the Windows key on other keyboards is super. So,
[ { "keys": ["super+t"], "command": "new_tab" }, ]
would be your key binding.
You can find the key binding reference here.

Sublime Text - Remove plugin's keymap shortcuts

In ST3, I want to keep the default key-map for super+alt+v, which is the paste history menu.
However, a plugin that I would like to use overrides those keys in it's default keymap. Can I remove the plugin's shortcut for super+alt+v or the keymap entirely?
This is what I want to keep (from the 'Default (OSX).sublime-keymap')
{ "keys": ["super+option+v"], "command": "paste_from_history" }
The is the perpetrator:
{ "keys": ["super+alt+v"], "command": "text_pastry_insert_text", "args": { "clipboard": true, "separator": "\n" } },
Turns out the Plugin's User settings will override the Plugin's Default.
So I copied { "keys": ["super+option+v"], "command": "paste_from_history" } from the original Default Sublime keymap into Text Pastry/User keymap and it's back. Thanks #Martin for talking it out with me.