| Commit message (Collapse) | Author |
|
That helps remove duplicated code and rustc/cargo will now also show
dead code correctly.
|
|
Fixes #3350
PowerShell's Set-Location (cd) doesn't update the process-level working
directory, so the spawned search process sees a stale cwd and directory
filter mode matches against the wrong directory. Setting
`WorkingDirectory` on the `ProcessStartInfo` ensures the correct cwd is
passed through.
|
|
The current version generates the following error when PowerShell's
current directory is on a [non-FileSystem
drive](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_providers):
> A parameter cannot be found that matches parameter name 'Raw'.
Repro:
<img width="475" height="166" alt="image"
src="https://github.com/user-attachments/assets/72af2dd1-ff80-46e1-936d-808d0563796a"
/>
<!-- Thank you for making a PR! Bug fixes are always welcome, but if
you're adding a new feature or changing an existing one, we'd really
appreciate if you open an issue, post on the forum, or drop in on
Discord -->
## Checks
- [x] I am happy for maintainers to push small adjustments to this PR,
to speed up the review cycle
- [x] I have checked that there are no existing pull requests for the
same thing
|
|
This shows stderr output from `atuin search -i` in PowerShell:
The output looks like this:
<img width="628" height="149" alt="image"
src="https://github.com/user-attachments/assets/c0a4bc9a-5d57-415f-a5b4-9c497744c6e0"
/>
Currently reproducible with the following config:
```toml
[keymap.emacs]
"foo" = "bar"
"=" = "bar"
```
I started by using `Start-Process` in the first commit, but then rewrote
it entirely as using a `Process` object directly should be more stable
(`Start-Process` already [caused
issues](https://github.com/atuinsh/atuin/pull/2543#issuecomment-2647555114)
in the past).
This fixes the PowerShell part of #3134
## Checks
- [x] I am happy for maintainers to push small adjustments to this PR,
to speed up the review cycle
- [x] I have checked that there are no existing pull requests for the
same thing
|
|
`$LASTEXITCODE` is an [automatic
variable](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7.5#lastexitcode)
in PowerShell which holds the exit code of the last *native* program
which has run. It's a close equivalent to `$?` in bash (PowerShell also
has [its own `$?`
variable](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7.5#section-1),
but it's a boolean).
Atuin is a native program, and the `PSConsoleHostReadLine` function
calls `atuin history start`, which resets this variable to 0 (or to
something else if it fails).
This PR resets this variable to its previous value, as it is that one
which the user will expect.
Before:
<img width="453" height="225" alt="image"
src="https://github.com/user-attachments/assets/5fc781d3-dbba-4737-b2ec-7ba73739d006"
/>
After:
<img width="460" height="212" alt="image"
src="https://github.com/user-attachments/assets/a2db9bca-343c-48fc-ab45-167e0dd6f7f9"
/>
Default behavior (without a profile file or Atuin):
<img width="351" height="147" alt="image"
src="https://github.com/user-attachments/assets/47d6aa28-1ea9-4e55-9879-98359ad3fbcf"
/>
## Checks
- [x] I am happy for maintainers to push small adjustments to this PR,
to speed up the review cycle
- [x] I have checked that there are no existing pull requests for the
same thing
|
|
eg, the user uses tmux, runs zsh again as a nested session, etc
## Checks
- [ ] I am happy for maintainers to push small adjustments to this PR,
to speed up the review cycle
- [ ] I have checked that there are no existing pull requests for the
same thing
|
|
<!-- Thank you for making a PR! Bug fixes are always welcome, but if
you're adding a new feature or changing an existing one, we'd really
appreciate if you open an issue, post on the forum, or drop in on
Discord -->
## Checks
- [ ] I am happy for maintainers to push small adjustments to this PR,
to speed up the review cycle
- [ ] I have checked that there are no existing pull requests for the
same thing
|
|
This PR does a few things:
- Includes a fix by @sususu98 (added as co-author):
- Fix: #3032
- Issue: https://github.com/PowerShell/PSReadLine/issues/5047
- Adds a couple `catch` blocks for better error safety in
`PSConsoleHostReadLine`.
- Allows reloading the Atuin module on v7+ if it's already loaded, which
could be useful when updating Atuin.
- Refactors the code to clean it up.
I'll be AFK next week, so I preferred to submit this sooner than later.
Closes #3032
## Checks
- [x] I am happy for maintainers to push small adjustments to this PR,
to speed up the review cycle
- [x] I have checked that there are no existing pull requests for the
same thing
---------
Co-authored-by: sususu <suchangshan@foxmail.com>
|
|
This runs `atuin history end` in the background, since it could delay
the next prompt when syncing.
Sorry I didn't realize this command could be slow (I currently don't use
sync).
I went for the .NET [`Process`
class](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process),
which is not pretty, but the other solutions I thought about all had
their own issues (`Start-Process` needs a file to redirect the output so
you can't just ignore it, `Start-Job` creates job objects that will
linger, `&` does the same but doesn't work on PS 5.1, ...). I'm
surprised I couldn't find a nice way to do the equivalent of `command &
>/dev/null` in PowerShell. 😕
This replaces #3033
## Checks
- [x] I am happy for maintainers to push small adjustments to this PR,
to speed up the review cycle
- [x] I have checked that there are no existing pull requests for the
same thing
|
|
This adds PowerShell support 🎉
I built this script around @lzybkr's
[prototype](https://github.com/atuinsh/atuin/issues/84#issuecomment-1689168533),
so I added him as co-author (I hope that's ok). I wouldn't know where to
start without his contribution.
I'm not a PowerShell expert, so this was a nice opportunity to learn
some stuff. I think it's ok, but I would appreciate if someone more
knowledgeable in the matter could review this though.
It would be nice if other PowerShell users could test this with their
configs and report any issues. I wouldn't be surprised if there are some
remaining bugs or missing features.
Fixes #84
## Installation
If you'd like to test this, you can install the `atuin` from this PR by
running:
```powershell
cargo install --git https://github.com/ltrzesniewski/atuin.git --branch powershell-pr
```
Then, add the following to your PowerShell profile file (whose path is
in `$PROFILE`) and restart the shell:
```powershell
atuin init powershell | Out-String | Invoke-Expression
```
This requires `atuin` to be in the path and the
[PSReadLine](https://github.com/PowerShell/PSReadLine) module to be
installed, which is the case by default.
## Tests
I tested this on the following:
- PowerShell 7.4.6 / PSReadLine 2.3.5 / Windows (the latest one)
- PowerShell 7.5.1 / PSReadLine 2.3.6 / Windows (the latest one)
- PowerShell 5.1.22621.4391 / PSReadLine 2.0.0 / Windows (the one
shipped with Windows)
- PowerShell 7.4.6 / PSReadLine 2.3.5 / Ubuntu WSL (strangely, it didn't
behave exactly like the Windows version)
- PowerShell 7.5.1 / PSReadLine 2.3.6 / Ubuntu WSL
I also tested this with and without my custom [Oh My
Posh](https://ohmyposh.dev/) prompt. It works fine in both cases,
~except that since my OMP config contains `"newline": true`, my prompt
is multiline and shifts downwards by a single line on each `atuin search
-i` invocation. This can be adjusted with the
`$env:ATUIN_POWERSHELL_PROMPT_OFFSET` environment variable (e.g. I set
mine to `-1` to account for the additional prompt line).~ (this variable
is now auto-initialized).
## Checks
- [x] I am happy for maintainers to push small adjustments to this PR,
to speed up the review cycle
- [x] I have checked that there are no existing pull requests for the
same thing
---------
Co-authored-by: Jason Shirk <jasonsh@microsoft.com>
|