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>
magical shell history
Atuin replaces your existing shell history with a SQLite database, and records additional context for your commands. Additionally, it provides optional and fully encrypted synchronisation of your history between machines, via an Atuin server.
exit code, duration, time and command shown
As well as the search UI, it can do things like this:
# search for all successful `make` commands, recorded after 3pm yesterday
atuin search --exit 0 --after "yesterday 3pm" make
You may use either the server I host, or host your own! Or just don't use sync at all. As all history sync is encrypted, I couldn't access your data even if I wanted to. And I really don't want to.
Features
- rebind
ctrl-randup(configurable) to a full screen history search UI - store shell history in a sqlite database
- back up and sync encrypted shell history
- the same history across terminals, across sessions, and across machines
- log exit code, cwd, hostname, session, command duration, etc
- calculate statistics such as "most used command"
- old history file is not replaced
- quick-jump to previous items with Alt-<num>
- switch filter modes via ctrl-r; search history just from the current session, directory, or globally
- enter to execute a command, tab to edit
Documentation
Supported Shells
- zsh
- bash
- fish
- nushell
- xonsh
Community
Forum
Atuin has a community forum, please ask here for help and support: https://forum.atuin.sh/
Discord
Atuin also has a community Discord, available here
Quickstart
This will sign you up for the Atuin Cloud sync server. Everything is end-to-end encrypted, so your secrets are safe!
Read more in the docs for an offline setup, self hosted server, and more.
curl --proto '=https' --tlsv1.2 -LsSf https://setup.atuin.sh | sh
atuin register -u <USERNAME> -e <EMAIL>
atuin import auto
atuin sync
Then restart your shell!
Note
For Bash users: The above sets up
bash-preexecfor necessary hooks, butbash-preexechas limitations. For details, please see the Bash section of the shell plugin documentation.
Security
If you find any security issues, we'd appreciate it if you could alert ellie@atuin.sh
Contributors
Made with contrib.rocks.
