pawamoy / shell-history

Visualize your shell usage with Highcharts!
ISC License
110 stars 2 forks source link

Does this work with PowerShell? #27

Open kiedtl opened 5 years ago

kiedtl commented 5 years ago

Will this work with PowerShell on Linux/Windows Powershell?

pawamoy commented 5 years ago

Not at all! But provided Powershell has ways of executing code before and after each interactive command, and disposes of a history which can be queried, it shouldn't be too hard to add support for it!

The shell code is only around 200 lines of code :slightly_smiling_face:

I'm gonna see what Powershell has to offer (or if you already have some knowledge about it, don't hesitate to share here!)

pawamoy commented 5 years ago

Question on StackOverflow: https://stackoverflow.com/questions/55972059/powershell-execute-things-before-and-or-after-an-interactive-command

I don't know Powershell at all so if anyone could look into the suggestions made in the comments it would be great!

kiedtl commented 5 years ago

I'm not sure about the internals of shellhistory, but wouldn't it be possible to do with only an after function? Or would some features be broken?

pawamoy commented 5 years ago

It would not be broken, but the generated data could be inaccurate. If a command changes the working directory, or overrides itself or deletes itself (think of virtualenvs' deactivate function: it unsets itself at the end), then we could not compute its true type (file/function/alias etc).

We also need to get a timestamp before the command, to be able to compute its duration. That's actually the main reason for executing code before commands.

That said, maybe there are clever ways to do that in Powershell! Since it's a completely different shell, Bash/Zsh logic might not apply.