watfaq / powersession Goto Github PK
View Code? Open in Web Editor NEWRecord a Session in PowerShell
License: MIT License
Record a Session in PowerShell
License: MIT License
๐ This is awesome, love your work. ๐
Is there a way to change the command it runs? For example, to run pwsh.exe
rather than powershell
?
Edit: FWIW, I tried this and it worked perfectly.
var record = new Command("rec")
{
new Argument<FileInfo>("file"),
new Argument<string>("command", "powershell.exe")
{
Arity = ArgumentArity.ExactlyOne
}
};
record.Handler = CommandHandler.Create((FileInfo file, string command) =>
{
var recordCmd = new RecordCommand(new RecordArgs
{
Filename = file.FullName,
Command = command
});
recordCmd.Execute();
});
Thank you for making this, it's really awesome!
I noticed that the output file lists all my env
variables, which is not ideal when sharing it.
According to the spec from asciicinema:
Official asciinema recorder captures only
SHELL
andTERM
by default. All implementations of asciicast-compatible terminal recorder should not capture any additional environment variables unless explicitly permitted by the user.
Do you think this could be fixed?
Thank you again!!
On latest commit (37da8b5). It actually also happens on the latest release by doing powersession rec test.cast -c pwsh
.
Hi I wrote a small powershell script to automate recordings.
Feel free to use it!
function Parse-KeyText ($Content) {
$Content = $Content.Replace("`r`n", "`n").Replace("`n", "{ENTER}")
[regex]$regex = '(?<modifiers>[+^%]+)?(?<content>{[^}]+}|[^+?^\^^%])'
$regex.Matches($Content) | % { $_.Value }
}
function Send-Keys ($KeyStrokes, $KeyPressSleep = 30, $LongSleep = 1500) {
$wshell = New-Object -ComObject wscript.shell;
foreach ($KeyPress in $KeyStrokes)
{
if ($KeyPress -eq '{SLEEP}')
{
Sleep -Milliseconds $LongSleep
}
else {
Sleep -Milliseconds $KeyPressSleep
$wshell.SendKeys($KeyPress)
}
}
}
#Documentation https://ss64.com/vb/sendkeys.html
$textToSend = @"
+^t{SLEEP}cd D:\Users\Peter\source\repos\FluentTerminal
powersession rec -c "pwsh -nologo" recording.txt
{SLEEP}Import-Module PowerType
{SLEEP}Enable-PowerType
git c{SLEEP}{DOWN}{SLEEP}{DOWN}{SLEEP} m{SLEEP}{DOWN}{SLEEP}
exit
{SLEEP}exit
"@
Write-Host "Installing powertype"
Install-Module PowerType
Write-Host "Simulating"
$KeyStrokes = Parse-KeyText -Content $textToSend
Send-Keys -KeyStrokes $KeyStrokes
Write-Host "Uninstalling PowerType"
Uninstall-Module PowerType
Firstly thanks for creating this! Works like a charm!
I see that PowerSession now supports cmd and pwsh through the --command parameter(#4), but this option is not shown in the help text. It would make its discovery easier.
Also, on a side note, when I do powersession play hello2.txt
and the file hello2.txt doesn't exist, PowerSession just dumps out a stacktrace. It'd be better if it just said 'File not found'.
Cheers!
I'm using the latest release (1.4.4), and it seems like doing powersession --version
shows up as 1.0.0
.
Hi thanks for a great program, are there any plans to publish on winget?
Up and down arrow key presses are useful for going through your command line history.
(Thank you so much for creating this BTW. It was really useful for me to learn how ConPTY works.)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.