Building custom commands with "sendInput"
One of the most powerful actions available in Windows Terminal is the sendInput
command, which was written by a community contributor. This action allows us to send arbitrary keyboard input to our terminal. Let's take a look:
{ Â Â "command": { Â Â Â Â "action": "sendInput", Â Â Â Â "input": "cd /projects/\r" Â Â }, Â Â "keys": "ctrl+alt+p" }
After adding this action, pressing Ctrl + Alt + p will automatically navigate to the /projects/
directory. To accomplish this, the sendInput
command simulates typing on the keyboard; it sends the keystrokes of the characters in the cd /projects/
command to the shell. It then presses Enter, as represented by the carriage-return character \r
, to execute the command. We can automate any command that involves keyboard input!
The sendInput
action is ideal for...