From 2ddd4bc55442a02c926f85df615fcf19fa2d0da0 Mon Sep 17 00:00:00 2001 From: Schwa Aresty Date: Mon, 3 Jun 2024 05:07:10 -0700 Subject: [PATCH] Add vscode terminal helper (#1395) It makes sense that the VSCode terminal should behave like a terminal. There's also a corresponding setting that needs to be set in VSCode. cc: @pokey --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Pokey Rule <755842+pokey@users.noreply.github.com> --- apps/vscode/README.md | 23 +++++++++++++++++++++++ apps/vscode/vscode_terminal.talon | 7 +++++++ 2 files changed, 30 insertions(+) create mode 100644 apps/vscode/vscode_terminal.talon diff --git a/apps/vscode/README.md b/apps/vscode/README.md index 72387de8d7..fb339e6334 100644 --- a/apps/vscode/README.md +++ b/apps/vscode/README.md @@ -5,3 +5,26 @@ It is recommended to install the [VSCode talon extension pack](https://marketpla ## Cursorless If you'd like to use Cursorless, follow the instructions in the [cursorless-talon repo](https://github.com/pokey/cursorless-talon). + +## Terminal + +In order to use terminal commands when the VSCode terminal is focused, you must add the following line to your [VSCode `settings.json`](https://code.visualstudio.com/docs/getstarted/settings#_settingsjson): + +``` +"window.title": "${activeEditorShort}${separator}${rootName}${separator}${profileName}${separator}focus:[${focusedView}]", +``` + +This setting will cause VSCode to include a special string in the window title whenever the terminal is focused. Talon will look for this string in the window title and activate the terminal commands in response. + +Note that if you have customizations in your window title that you'd like to keep, the important part is just to ensure that `focus:[${focusedView}]` appears somewhere within your custom window title. + +In order to enable additional terminal commands you will need to set some tags when the terminal tag is active. You can do this by creating a file in your talon settings that looks something like this: + +``` +tag: terminal +- +tag(): user.generic_unix_shell +tag(): user.git +tag(): user.kubectl +tag(): user.readline +``` diff --git a/apps/vscode/vscode_terminal.talon b/apps/vscode/vscode_terminal.talon new file mode 100644 index 0000000000..63caed5d43 --- /dev/null +++ b/apps/vscode/vscode_terminal.talon @@ -0,0 +1,7 @@ +app: vscode +# Looks for special string in window title. +# NOTE: This requires you to add a special setting to your VSCode settings.json +# See [our vscode docs](./README.md#terminal) +win.title: /focus:\[Terminal\]/ +- +tag(): terminal