How can I reorder panes in Windows Terminal? - windows-terminal

I had my terminal set up with two panes. Like this:
[A|B]
I accidentally Ctrl+C'd a process running in the pane to the left, which results in the pane getting closed. When I split again, my new pane comes to the right. So that my setup becomes:
[B|A]
Is there anyway to restore the setup I had initially without cancelling the process running in B?

When you asked, this wasn't possible.
With Windows Terminal 1.12 however, this is possible with the swapPane actions. For more details, see: https://learn.microsoft.com/en-us/windows/terminal/panes#swapping-panes-preview
The syntax for these actions is:
{ "command": { "action": "swapPane", "direction": "down" } },
{ "command": { "action": "swapPane", "direction": "left" } },
{ "command": { "action": "swapPane", "direction": "right" } },
{ "command": { "action": "swapPane", "direction": "up" } },
{ "command": { "action": "swapPane", "direction": "previous" } },
{ "command": { "action": "swapPane", "direction": "previousInOrder" } },
{ "command": { "action": "swapPane", "direction": "nextInOrder" } }
But they should also be bound by default in the Command Palette, under the names "Swap Pane..."

Related

How to ensure a Step Function executes Parameterized Query properly in AWS?

I'm currently trying to execute an Athena Query during a State Machine. The query itself needs a date variable to use in several WHERE statements so I'm using a Lambda to generate it.
When I run EXECUTE prepared-statement USING 'date', 'date', 'date'; directly in Athena, I get the results I expect so I know the query is formed correctly, but when I try to do it in the state machine, it gives me the following error:
SYNTAX_ERROR: line 19:37: Unexpected parameters (integer) for function date. Expected: date(varchar(x)) , date(timestamp) , date(timestamp with time zone)
So my best guess is that I'm somehow not passing the execution parameters correctly.
The Lambda that calculates the date returns it in a string with the format %Y-%m-%d, and in the State Machine I make sure to pass it to the output of every State that needs it. Then I get a named query to create a prepare statement from within the state machine. I then use that prepared statement to run an EXECUTE query that requires the date multiple times, so I use an intrinsic function to turn it into an array:
{
"StartAt": "calculate_date",
"States": {
"calculate_date": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"Parameters": {
"Payload.$": "$",
"FunctionName": "arn:aws:lambda:::function:calculate_date:$LATEST"
},
"Retry": [
{
"ErrorEquals": [
"Lambda.ServiceException",
"Lambda.AWSLambdaException",
"Lambda.SdkClientException",
"Lambda.TooManyRequestsException"
],
"IntervalSeconds": 2,
"MaxAttempts": 6,
"BackoffRate": 2
}
],
"Next": "get_query",
"ResultSelector": {
"ExecDate.$": "$.Payload.body.exec_date"
}
},
"get_query": {
"Type": "Task",
"Next": "prepare_query",
"Parameters": {
"NamedQueryId": "abc123"
},
"Resource": "arn:aws:states:::aws-sdk:athena:getNamedQuery",
"ResultPath": "$.Payload"
},
"prepare_query": {
"Type": "Task",
"Next": "execute_query",
"Parameters": {
"QueryStatement.$": "$.Payload.NamedQuery.QueryString",
"StatementName": "PreparedStatementName",
"WorkGroup": "athena-workgroup"
},
"Resource": "arn:aws:states:::aws-sdk:athena:createPreparedStatement",
"ResultPath": "$.Payload"
},
"execute_query": {
"Type": "Task",
"Resource": "arn:aws:states:::athena:startQueryExecution",
"Parameters": {
"ExecutionParameters.$": "States.Array($.ExecDate, $.ExecDate, $.ExecDate)",
"QueryExecutionContext": {
"Catalog": "catalog_name",
"Database": "database_name"
},
"QueryString": "EXECUTE PreparedStatementName",
"WorkGroup": "athena-workgroup",
"ResultConfiguration": {
"OutputLocation": "s3://bucket"
}
},
"End": true
}
}
}
The execution of the State Machine returns successfully, but the query doesn't export the results to the bucket, and when I click on the "Athena query execution" link in the list of events, it takes me to the Athena editor page where I see the error listed above
https://i.stack.imgur.com/pxxOm.png
Am I generating the ExecutionParameters wrong? Does the createPreparedStatement resource need a different syntax for the query parameters? I'm truly at a lost here, so any help is greatly appreciated
I just solved my problem. And I'm posting this answer in case anyone comes across the same issue.
Apparently, the ExecutionParameters paremeter in an Athena StartQueryExecution state does not respect the variable type of a JSONPath variable, so you need to manually add the single quotes when forming your array. I solved this by adding a secondary output from the lambda, with the date wrapped in single quotes so that when I make the array using instrinsic functions and pass it to the query execution, it forms the query string correctly.
Transform the output from the lambda like this:
"ExecDateQuery.$": "States.Format('\\'{}\\'', $.Payload.body.exec_date)"
And use ExecDateQuery in the array intrinsic function, instead of ExecDate.
The final State Machine would look like this:
{
"StartAt": "calculate_date",
"States": {
"calculate_date": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"Parameters": {
"Payload.$": "$",
"FunctionName": "arn:aws:lambda:::function:calculate_date:$LATEST"
},
"Retry": [
{
"ErrorEquals": [
"Lambda.ServiceException",
"Lambda.AWSLambdaException",
"Lambda.SdkClientException",
"Lambda.TooManyRequestsException"
],
"IntervalSeconds": 2,
"MaxAttempts": 6,
"BackoffRate": 2
}
],
"Next": "get_query",
"ResultSelector": {
"ExecDate.$": "$.Payload.body.exec_date",
"ExecDateQuery.$": "States.Format('\\'{}\\'', $.Payload.body.exec_date)"
}
},
"get_query": {
"Type": "Task",
"Next": "prepare_query",
"Parameters": {
"NamedQueryId": "abc123"
},
"Resource": "arn:aws:states:::aws-sdk:athena:getNamedQuery",
"ResultPath": "$.Payload"
},
"prepare_query": {
"Type": "Task",
"Next": "execute_query",
"Parameters": {
"QueryStatement.$": "$.Payload.NamedQuery.QueryString",
"StatementName": "PreparedStatementName",
"WorkGroup": "athena-workgroup"
},
"Resource": "arn:aws:states:::aws-sdk:athena:createPreparedStatement",
"ResultPath": "$.Payload"
},
"execute_query": {
"Type": "Task",
"Resource": "arn:aws:states:::athena:startQueryExecution",
"Parameters": {
"ExecutionParameters.$": "States.Array($.ExecDateQuery, $.ExecDateQuery, $.ExecDateQuery)",
"QueryExecutionContext": {
"Catalog": "catalog_name",
"Database": "database_name"
},
"QueryString": "EXECUTE PreparedStatementName",
"WorkGroup": "athena-workgroup",
"ResultConfiguration": {
"OutputLocation": "s3://bucket"
}
},
"End": true
}
}
}

Step Functions ignoring Parameters, executing it with default input

I don't know if this is a bug of my own or Amazon's as I'm unable to properly understand what's going on.
I have the following Step Function (It's currently a work in progress), which takes care of validating an input and then sending it to an SQS lambda (CreateInAuth0 Step).
My problem is that apparently the SQS function is executing with the default parameters, fails, retries and then uses the ones specified in the Step Function. (Or at least that's what I'm gathering from the logs).
I want to know why it is ignoring the Parameters in the first go. Here's all the information I can gather.
There seems to be a difference between TaskStateEntered and TaskScheduled (which I believe it's ok).
{
"Comment": "Add the students to the platform and optionally adds them to their respective grades",
"StartAt": "AddStudents",
"States": {
"AddStudents": {
"Comment": "Validates that the students are OK",
"Type": "Task",
"Resource": "#AddStudents",
"Next": "Parallel"
},
"Parallel": {
"Type": "Parallel",
"Next": "FinishExecution",
"Branches": [
{
"StartAt": "CreateInAuth0",
"States": {
"CreateInAuth0": {
"Type": "Task",
"Resource": "arn:aws:states:::sqs:sendMessage.waitForTaskToken",
"Parameters": {
"QueueUrl": "#SQS_StudentsRegistrationSQSFifo",
"MessageBody": {
"execId.$": "$.result.execId",
"tenantType.$": "$.result.tenantType",
"tenantId.$": "$.result.tenantId",
"studentsToCreate.$": "$.result.newStudents.success",
"TaskToken.$": "$$.Task.Token",
"studentsSucceeded": []
}
},
"End": true
}
}
}
]
},
"FinishExecution": {
"Comment": "This signals the ending in DynamoDB that the transaction finished",
"Type": "Task",
"End": true,
"Resource": "arn:aws:states:::dynamodb:putItem",
"ResultPath": "$.dynamoDB",
"Parameters": {
"TableName": "#SchonDB",
"Item": {
"pk": {
"S.$": "$.arguments.tenantId:exec:$.id"
},
"sk": {
"S": "result"
},
"status": {
"S": "FINISHED"
},
"type": {
"S": "#EXEC_TYPE"
}
}
},
"Retry": [
{
"ErrorEquals": [
" States.Timeout"
],
"IntervalSeconds": 1,
"MaxAttempts": 5,
"BackoffRate": 2.0
}
],
"Catch": [
{
"ErrorEquals": [
"States.ALL"
],
"Next": "FinishExecutionIfFinishErrored"
}
]
},
"FinishExecutionIfFinishErrored": {
"Type": "Pass",
"End": true
}
}
}
Here's the visual:
Here's the execution event history:
Note: I have a try/catch statement inside the SQS function that wraps the entire SQS' execution.

Rebinding next/previous tab in Firefox without a plugin

I use a tool called Autokey on Linux so that I can bind next/previous tab to the hotkeys that I want across all applications. For the most part, the built in OSX key mapper does the job when I need to use a mac. The problem is that it can only trigger actions that appear as a menu item in an application and Firefox doesn't actually have a 'Next tab' or 'Previous tab' menu item like Chrome does.
I'd rather not install a Firefox plugin just to keybind certain functionality. They always end up messing me up on other operations systems or getting outdated. Is it possible to create an extension that contributes menu items to Firefox so I can just use the built in keyboard shortcut utility in OSX? Are there other ways of getting the keybinds I want?
I ended up solving this with Karabiner in a way that is more analogous to how Autokey works. Here is the json config that maps my preferred next/previous keybind to the thing Firefox (and iTerm) needs.
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
"basic.simultaneous_threshold_milliseconds": 50,
"basic.to_delayed_action_delay_milliseconds": 500,
"basic.to_if_alone_timeout_milliseconds": 250,
"basic.to_if_held_down_threshold_milliseconds": 500,
"mouse_motion_to_scroll.speed": 100
},
"rules": [
{
"manipulators": [
{
"type": "basic",
"description": "next tab in firefox",
"from": {
"key_code": "l",
"modifiers": {
"mandatory": ["left_control", "left_gui"]
}
},
"to": [
{
"key_code": "tab",
"modifiers": ["left_control"]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"org.mozilla.firefox",
"com.googlecode.iterm2"
]
}
]
},
{
"type": "basic",
"description": "prev tab in firefox",
"from": {
"key_code": "h",
"modifiers": {
"mandatory": ["left_control", "left_gui"]
}
},
"to": [
{
"key_code": "tab",
"modifiers": ["left_control", "left_shift"]
}
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"org.mozilla.firefox",
"com.googlecode.iterm2"
]
}
]
}
]
}
]
}
}
]
}
I use an Ergodox keyboard and the way I programmed it makes my left alt key appear as left_gui.

How to change brackets highlighting from underline? [duplicate]

This question already has answers here:
How to change style of matched brackets in Sublime Text 2 / 3?
(6 answers)
Closed 6 years ago.
For now open and close brackets { } highlights as underline _
I don't like it
But I can't find, is there way to change it to bolding or / and background change as in most of other editors?
Take a look at the BracketHighlighter plugin.
Edit
Try this for your Packages/User/bh_core.sublime-settings
{
// Define region highlight styles
"bracket_styles": {
// "default" and "unmatched" styles are special
// styles. If they are not defined here,
// they will be generated internally with
// internal defaults.
// "default" style defines attributes that
// will be used for any style that does not
// explicitly define that attribute. So if
// a style does not define a color, it will
// use the color from the "default" style.
"default": {
"icon": "dot",
// BH1's original default color for reference
// "color": "entity.name.class",
"color": "brackethighlighter.default",
"style": "underline"
},
// This particular style is used to highlight
// unmatched bracekt pairs. It is a special
// style.
"unmatched": {
"icon": "question",
// "color": "brackethighlighter.unmatched",
"style": "outline"
},
// User defined region styles
"curly": {
"icon": "curly_bracket",
// "color": "brackethighlighter.curly",
"style": "full"
},
"round": {
"icon": "round_bracket",
// "color": "brackethighlighter.round",
"style": "full"
},
"square": {
"icon": "square_bracket",
// "color": "brackethighlighter.square",
"style": "full"
},
"angle": {
"icon": "angle_bracket",
// "color": "brackethighlighter.angle",
"style": "full"
},
"tag": {
"icon": "tag",
// "color": "brackethighlighter.tag",
"style": "outline"
},
"single_quote": {
"icon": "single_quote",
// "color": "brackethighlighter.quote",
"style": "full"
},
"double_quote": {
"icon": "double_quote",
// "color": "brackethighlighter.quote",
"style": "full"
},
"regex": {
"icon": "regex",
// "color": "brackethighlighter.quote",
"style": "full"
}
}
}
Just go "Sublime Text -> Preferences -> Package Settings -> Bracket Highlighter -> Bracket Setting - User".
Then paste the following configuration and press "Save". That should fix it.
{
"bracket_styles": {
"default": {
"icon": "dot",
"color": "brackethighlighter.default",
"style": "none"
},
"unmatched": {
"icon": "question",
"style": "outline"
},
"curly": {
"icon": "curly_bracket"
},
"round": {
"icon": "round_bracket"
},
"square": {
"icon": "square_bracket"
},
"angle": {
"icon": "angle_bracket"
},
"tag": {
"icon": "tag"
},
"c_define": {
"icon": "hash"
},
"single_quote": {
"icon": "single_quote"
},
"double_quote": {
"icon": "double_quote"
},
"regex": {
"icon": "regex"
}
}
}
p.s.
I'm aware that this is an old question - this is for reference!
Paste this to your Theme_of_choise.tmTheme next to other stuff in settings. And no there are no bracketBackground key :(
<key>bracketsForeground</key>
<string>#FF0000</string>
<key>bracketsOptions</key>
<string>foreground</string>
<key>bracketContentsForeground</key>
<string>#FF0000</string>
<key>bracketContentsOptions</key>
<string>foreground</string>

I can't get this to work: In Sublime Text (3), I am trying to alternate a setting's value using the same shortcut/keymap and contexts

In Sublime Text 3, I am trying to alternate a setting's value using the same shortcut, but with differing contexts. Basically, I want to alternate the draw_white_space setting between its three possible values: none, selection, and all.
I change the setting easily enough with three separate shortcuts/keymaps. Here is that code (working):
{
"keys": ["ctrl+e", "ctrl+w"],
"command": "set_setting",
"args": {
"setting": "draw_white_space",
"value": "all",
}
},
{
"keys": ["ctrl+e", "ctrl+q"],
"command": "set_setting",
"args": {
"setting": "draw_white_space",
"value": "none",
}
},
{
"keys": ["ctrl+e", "ctrl+s"],
"command": "set_setting",
"args": {
"setting": "draw_white_space",
"value": "selection",
}
}
But, what I would really like is to be able to press ["ctrl+e", "ctrl+w"] and have it alternate through each possible value. Yes, it is a Visual Studio shortcut that I'm used to!
I created what looks to me like it should work, but it doesn't. At least not how I want it to. Here is that code (broken):
{
"keys": ["ctrl+e", "ctrl+w"],
"command": "set_setting",
"args": {
"setting": "draw_white_space",
"value": "none",
},
"context": [
{ "key": "setting.draw_white_space",
"operator": "equal", "operand": "all" }
]
},
{
"keys": ["ctrl+e", "ctrl+w"],
"command": "set_setting",
"args": {
"setting": "draw_white_space",
"value": "selection",
},
"context": [
{ "key": "setting.draw_white_space",
"operator": "equal", "operand": "none" }
]
},
{
"keys": ["ctrl+e", "ctrl+w"],
"command": "set_setting",
"args": {
"setting": "draw_white_space",
"value": "all",
},
"context": [
{ "key": "setting.draw_white_space",
"operator": "equal", "operand": "selection" }
]
}
I have tested out my contexts, so I know they work. For instance, I can manually set all in my settings file, then the shortcut that checks for all will work the first time only. It nor the others will work after that.
Another thing I noticed is that my settings file does not change the draw_white_space value when the shortcut does work (including the three separate shortcuts). I assumed that might be default behavior - the settings changes may be per session - and that would be fine. But, I removed the setting completely and it is still the same behavior.
I am changing the file opened via the Preferences | Key Bindings - User menu, which opened the <Sublime Text>\Data\Packages\User\Default (Windows).sublime-keymap file.
Any ideas? Am I doing something wrong or missing something?
Maybe not what you want, but you can get that behavior with a pretty simple plugin.
import sublime
import sublime_plugin
class CycleDrawWhiteSpaceCommand(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view
white_space_type = view.settings().get("draw_white_space")
if white_space_type == "all":
view.settings().set("draw_white_space", "none")
elif white_space_type == "none":
view.settings().set("draw_white_space", "selection")
else:
view.settings().set("draw_white_space", "all")
After you save the plugin, bind your key binding to cycle_draw_white_space

Resources