Merge upstream/main into fork

This commit is contained in:
Ty 2024-01-26 21:32:48 -07:00
commit 49ad411c6b
No known key found for this signature in database
GPG Key ID: 2813440C772555A4
17 changed files with 283 additions and 289 deletions

5
.github/pull_request_template.md vendored Normal file
View File

@ -0,0 +1,5 @@
<!-- 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

View File

@ -6,6 +6,25 @@ Atuin doesn't require anything super special to develop - standard Rust tooling
Before working on anything, we suggest taking a copy of your Atuin data directory (`~/.local/share/atuin` on most \*nix platforms). If anything goes wrong, you can always restore it!
While data directory backups are always a good idea, you can instruct Atuin to use custom path using the following environment variables:
```shell
export ATUIN_DB_PATH=/tmp/atuin_dev.db
export ATUIN_RECORD_STORE_PATH=/tmp/atuin_records.db
```
It is also recommended to update your `$PATH` so that the pre-exec scripts would use the locally built version:
```shell
export PATH="./target/release:$PATH"
```
These 3 variables can be added in a local `.envrc` file, read by [direnv](https://direnv.net/).
## PRs
It can speed up the review cycle if you consent to maintainers pushing to your branch. This will only be in the case of small fixes or adjustments, and not anything large. If you feel OK with this, please check the box on the template!
## What to work on?
Any issues labeled "bug" or "help wanted" would be fantastic, just drop a comment and feel free to ask for help!

333
Cargo.lock generated
View File

@ -57,9 +57,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
[[package]]
name = "anstream"
version = "0.6.5"
version = "0.6.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d664a92ecae85fd0a7392615844904654d1d5f5514837f471ddef4a057aba1b6"
checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5"
dependencies = [
"anstyle",
"anstyle-parse",
@ -135,7 +135,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.46",
"syn 2.0.48",
]
[[package]]
@ -172,7 +172,7 @@ dependencies = [
"atuin-common",
"atuin-server",
"atuin-server-postgres",
"base64 0.21.5",
"base64 0.21.7",
"clap",
"clap_complete",
"cli-clipboard",
@ -211,7 +211,7 @@ version = "17.2.1"
dependencies = [
"async-trait",
"atuin-common",
"base64 0.21.5",
"base64 0.21.7",
"clap",
"config",
"crypto_secretbox",
@ -278,7 +278,7 @@ dependencies = [
"atuin-server-database",
"axum",
"axum-server",
"base64 0.21.5",
"base64 0.21.7",
"config",
"eyre",
"fs-err",
@ -428,9 +428,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
[[package]]
name = "base64"
version = "0.21.5"
version = "0.21.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9"
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
[[package]]
name = "base64ct"
@ -452,9 +452,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.4.1"
version = "2.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf"
dependencies = [
"serde",
]
@ -583,9 +583,9 @@ dependencies = [
[[package]]
name = "clap"
version = "4.4.12"
version = "4.4.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcfab8ba68f3668e89f6ff60f5b205cea56aa7b769451a59f34b8682f51c056d"
checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c"
dependencies = [
"clap_builder",
"clap_derive",
@ -593,9 +593,9 @@ dependencies = [
[[package]]
name = "clap_builder"
version = "4.4.12"
version = "4.4.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb7fb5e4e979aec3be7791562fcba452f94ad85e954da024396433e0e25a79e9"
checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7"
dependencies = [
"anstream",
"anstyle",
@ -605,9 +605,9 @@ dependencies = [
[[package]]
name = "clap_complete"
version = "4.4.6"
version = "4.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97aeaa95557bd02f23fbb662f981670c3d20c5a26e69f7354b28f57092437fcd"
checksum = "df631ae429f6613fcd3a7c1adbdb65f637271e561b03680adaa6573015dfb106"
dependencies = [
"clap",
]
@ -621,7 +621,7 @@ dependencies = [
"heck",
"proc-macro2",
"quote",
"syn 2.0.46",
"syn 2.0.48",
]
[[package]]
@ -687,15 +687,15 @@ dependencies = [
[[package]]
name = "console"
version = "0.15.7"
version = "0.15.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8"
checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb"
dependencies = [
"encode_unicode",
"lazy_static",
"libc",
"unicode-width",
"windows-sys 0.45.0",
"windows-sys 0.52.0",
]
[[package]]
@ -746,33 +746,27 @@ checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5"
[[package]]
name = "crossbeam-epoch"
version = "0.9.17"
version = "0.9.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e3681d554572a651dda4186cd47240627c3d0114d45a95f6ad27f2f22e7548d"
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
dependencies = [
"autocfg",
"cfg-if",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-queue"
version = "0.3.10"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adc6598521bb5a83d491e8c1fe51db7296019d2ca3cb93cc6c2a20369a4d78a2"
checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35"
dependencies = [
"cfg-if",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.18"
version = "0.8.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3a430a770ebd84726f584a90ee7f020d28db52c6d02138900f22341f866d39c"
dependencies = [
"cfg-if",
]
checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345"
[[package]]
name = "crossterm"
@ -780,7 +774,7 @@ version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df"
dependencies = [
"bitflags 2.4.1",
"bitflags 2.4.2",
"crossterm_winapi",
"filedescriptor",
"libc",
@ -861,7 +855,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.46",
"syn 2.0.48",
]
[[package]]
@ -1015,9 +1009,9 @@ dependencies = [
[[package]]
name = "env_logger"
version = "0.10.1"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece"
checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580"
dependencies = [
"humantime",
"is-terminal",
@ -1216,7 +1210,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.46",
"syn 2.0.48",
]
[[package]]
@ -1282,9 +1276,9 @@ dependencies = [
[[package]]
name = "getrandom"
version = "0.2.11"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f"
checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5"
dependencies = [
"cfg-if",
"libc",
@ -1361,9 +1355,9 @@ dependencies = [
[[package]]
name = "hermit-abi"
version = "0.3.3"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"
checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f"
[[package]]
name = "hex"
@ -1644,9 +1638,9 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
[[package]]
name = "js-sys"
version = "0.3.66"
version = "0.3.67"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca"
checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1"
dependencies = [
"wasm-bindgen",
]
@ -1678,7 +1672,7 @@ version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8"
dependencies = [
"bitflags 2.4.1",
"bitflags 2.4.2",
"libc",
"redox_syscall",
]
@ -1696,9 +1690,9 @@ dependencies = [
[[package]]
name = "linux-raw-sys"
version = "0.4.12"
version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456"
checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
[[package]]
name = "lock_api"
@ -1736,7 +1730,7 @@ dependencies = [
"proc-macro2",
"quote",
"regex-syntax 0.6.29",
"syn 2.0.46",
"syn 2.0.48",
]
[[package]]
@ -1832,7 +1826,7 @@ version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d4fa7ce7c4862db464a37b0b31d89bca874562f034bd7993895572783d02950"
dependencies = [
"base64 0.21.5",
"base64 0.21.7",
"hyper 0.14.28",
"indexmap 1.9.3",
"ipnet",
@ -1852,7 +1846,7 @@ checksum = "38b4faf00617defe497754acde3024865bc143d44a86799b24e191ecff91354f"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.46",
"syn 2.0.48",
]
[[package]]
@ -1927,7 +1921,7 @@ version = "0.27.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053"
dependencies = [
"bitflags 2.4.1",
"bitflags 2.4.2",
"cfg-if",
"libc",
]
@ -2252,22 +2246,22 @@ dependencies = [
[[package]]
name = "pin-project"
version = "1.1.3"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422"
checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0"
dependencies = [
"pin-project-internal",
]
[[package]]
name = "pin-project-internal"
version = "1.1.3"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405"
checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.46",
"syn 2.0.48",
]
[[package]]
@ -2305,9 +2299,9 @@ dependencies = [
[[package]]
name = "pkg-config"
version = "0.3.28"
version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a"
checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb"
[[package]]
name = "platforms"
@ -2356,9 +2350,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.74"
version = "1.0.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db"
checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae"
dependencies = [
"unicode-ident",
]
@ -2424,7 +2418,7 @@ version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5659e52e4ba6e07b2dad9f1158f578ef84a73762625ddb51536019f34d180eb"
dependencies = [
"bitflags 2.4.1",
"bitflags 2.4.2",
"cassowary",
"crossterm",
"indoc",
@ -2468,13 +2462,13 @@ dependencies = [
[[package]]
name = "regex"
version = "1.10.2"
version = "1.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"
checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata 0.4.3",
"regex-automata 0.4.5",
"regex-syntax 0.8.2",
]
@ -2489,9 +2483,9 @@ dependencies = [
[[package]]
name = "regex-automata"
version = "0.4.3"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd"
dependencies = [
"aho-corasick",
"memchr",
@ -2516,7 +2510,7 @@ version = "0.11.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41"
dependencies = [
"base64 0.21.5",
"base64 0.21.7",
"bytes",
"encoding_rs",
"futures-core",
@ -2550,21 +2544,6 @@ dependencies = [
"winreg",
]
[[package]]
name = "ring"
version = "0.16.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc"
dependencies = [
"cc",
"libc",
"once_cell",
"spin 0.5.2",
"untrusted 0.7.1",
"web-sys",
"winapi",
]
[[package]]
name = "ring"
version = "0.17.7"
@ -2575,7 +2554,7 @@ dependencies = [
"getrandom",
"libc",
"spin 0.9.8",
"untrusted 0.9.0",
"untrusted",
"windows-sys 0.48.0",
]
@ -2667,7 +2646,7 @@ version = "0.38.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca"
dependencies = [
"bitflags 2.4.1",
"bitflags 2.4.2",
"errno",
"libc",
"linux-raw-sys",
@ -2681,7 +2660,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba"
dependencies = [
"log",
"ring 0.17.7",
"ring",
"rustls-webpki",
"sct",
]
@ -2704,7 +2683,7 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c"
dependencies = [
"base64 0.21.5",
"base64 0.21.7",
]
[[package]]
@ -2713,8 +2692,8 @@ version = "0.101.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765"
dependencies = [
"ring 0.17.7",
"untrusted 0.9.0",
"ring",
"untrusted",
]
[[package]]
@ -2748,9 +2727,9 @@ dependencies = [
[[package]]
name = "rusty_paseto"
version = "0.6.0"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6cdf6eecf99ba1cc36c0629fc69772bbd7fbec0d6a84a29076c25dc0f587be16"
checksum = "1aadb59ff4f705031fae18f6a0261dae6869f70cfd5d134eac497d3841cc3644"
dependencies = [
"base64 0.13.1",
"blake2 0.9.2",
@ -2758,7 +2737,7 @@ dependencies = [
"ed25519-dalek",
"hex",
"iso8601",
"ring 0.16.20",
"ring",
"thiserror",
"time",
"zeroize",
@ -2800,8 +2779,8 @@ version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414"
dependencies = [
"ring 0.17.7",
"untrusted 0.9.0",
"ring",
"untrusted",
]
[[package]]
@ -2835,29 +2814,29 @@ checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0"
[[package]]
name = "serde"
version = "1.0.194"
version = "1.0.195"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b114498256798c94a0689e1a15fec6005dee8ac1f41de56404b67afc2a4b773"
checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.194"
version = "1.0.195"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3385e45322e8f9931410f01b3031ec534c3947d0e94c18049af4d9f9907d4e0"
checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.46",
"syn 2.0.48",
]
[[package]]
name = "serde_json"
version = "1.0.110"
version = "1.0.111"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fbd975230bada99c8bb618e0c365c2eefa219158d5c6c29610fd09ff1833257"
checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4"
dependencies = [
"itoa",
"ryu",
@ -2993,9 +2972,9 @@ dependencies = [
[[package]]
name = "smallvec"
version = "1.11.2"
version = "1.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970"
checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7"
[[package]]
name = "socket2"
@ -3158,8 +3137,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e37195395df71fd068f6e2082247891bc11e3289624bbc776a0cdfa1ca7f1ea4"
dependencies = [
"atoi",
"base64 0.21.5",
"bitflags 2.4.1",
"base64 0.21.7",
"bitflags 2.4.2",
"byteorder",
"bytes",
"crc",
@ -3202,8 +3181,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6ac0ac3b7ccd10cc96c7ab29791a7dd236bd94021f31eec7ba3d46a74aa1c24"
dependencies = [
"atoi",
"base64 0.21.5",
"bitflags 2.4.1",
"base64 0.21.7",
"bitflags 2.4.2",
"byteorder",
"crc",
"dotenvy",
@ -3313,7 +3292,7 @@ dependencies = [
"proc-macro2",
"quote",
"rustversion",
"syn 2.0.46",
"syn 2.0.48",
]
[[package]]
@ -3335,9 +3314,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.46"
version = "2.0.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e"
checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f"
dependencies = [
"proc-macro2",
"quote",
@ -3386,9 +3365,9 @@ dependencies = [
[[package]]
name = "termcolor"
version = "1.4.0"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449"
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
dependencies = [
"winapi-util",
]
@ -3410,7 +3389,7 @@ checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.46",
"syn 2.0.48",
]
[[package]]
@ -3515,7 +3494,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.46",
"syn 2.0.48",
]
[[package]]
@ -3584,7 +3563,7 @@ version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140"
dependencies = [
"bitflags 2.4.1",
"bitflags 2.4.2",
"bytes",
"futures-core",
"futures-util",
@ -3629,7 +3608,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.46",
"syn 2.0.48",
]
[[package]]
@ -3703,22 +3682,22 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]
name = "typed-builder"
version = "0.18.0"
version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e47c0496149861b7c95198088cbf36645016b1a0734cf350c50e2a38e070f38a"
checksum = "444d8748011b93cb168770e8092458cb0f8854f931ff82fdf6ddfbd72a9c933e"
dependencies = [
"typed-builder-macro",
]
[[package]]
name = "typed-builder-macro"
version = "0.18.0"
version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "982ee4197351b5c9782847ef5ec1fdcaf50503fb19d68f9771adae314e72b492"
checksum = "563b3b88238ec95680aef36bdece66896eaa7ce3c0f1b4f39d38fb2435261352"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.46",
"syn 2.0.48",
]
[[package]]
@ -3729,9 +3708,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
[[package]]
name = "unicode-bidi"
version = "0.3.14"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416"
checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75"
[[package]]
name = "unicode-ident"
@ -3776,12 +3755,6 @@ dependencies = [
"subtle",
]
[[package]]
name = "untrusted"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
[[package]]
name = "untrusted"
version = "0.9.0"
@ -3813,9 +3786,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]]
name = "uuid"
version = "1.6.1"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560"
checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a"
dependencies = [
"atomic",
"getrandom",
@ -3857,9 +3830,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"
version = "0.2.89"
version = "0.2.90"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e"
checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406"
dependencies = [
"cfg-if",
"wasm-bindgen-macro",
@ -3867,24 +3840,24 @@ dependencies = [
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.89"
version = "0.2.90"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826"
checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd"
dependencies = [
"bumpalo",
"log",
"once_cell",
"proc-macro2",
"quote",
"syn 2.0.46",
"syn 2.0.48",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-futures"
version = "0.4.39"
version = "0.4.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12"
checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461"
dependencies = [
"cfg-if",
"js-sys",
@ -3894,9 +3867,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.89"
version = "0.2.90"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2"
checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@ -3904,22 +3877,22 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.89"
version = "0.2.90"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283"
checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.46",
"syn 2.0.48",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.89"
version = "0.2.90"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f"
checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b"
[[package]]
name = "wayland-client"
@ -3982,9 +3955,9 @@ dependencies = [
[[package]]
name = "web-sys"
version = "0.3.66"
version = "0.3.67"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f"
checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed"
dependencies = [
"js-sys",
"wasm-bindgen",
@ -4046,15 +4019,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.45.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
dependencies = [
"windows-targets 0.42.2",
]
[[package]]
name = "windows-sys"
version = "0.48.0"
@ -4073,21 +4037,6 @@ dependencies = [
"windows-targets 0.52.0",
]
[[package]]
name = "windows-targets"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
dependencies = [
"windows_aarch64_gnullvm 0.42.2",
"windows_aarch64_msvc 0.42.2",
"windows_i686_gnu 0.42.2",
"windows_i686_msvc 0.42.2",
"windows_x86_64_gnu 0.42.2",
"windows_x86_64_gnullvm 0.42.2",
"windows_x86_64_msvc 0.42.2",
]
[[package]]
name = "windows-targets"
version = "0.48.5"
@ -4118,12 +4067,6 @@ dependencies = [
"windows_x86_64_msvc 0.52.0",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.5"
@ -4136,12 +4079,6 @@ version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
[[package]]
name = "windows_aarch64_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.5"
@ -4154,12 +4091,6 @@ version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
[[package]]
name = "windows_i686_gnu"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
[[package]]
name = "windows_i686_gnu"
version = "0.48.5"
@ -4172,12 +4103,6 @@ version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
[[package]]
name = "windows_i686_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
[[package]]
name = "windows_i686_msvc"
version = "0.48.5"
@ -4190,12 +4115,6 @@ version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.5"
@ -4208,12 +4127,6 @@ version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.5"
@ -4226,12 +4139,6 @@ version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
[[package]]
name = "windows_x86_64_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.5"
@ -4332,7 +4239,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.46",
"syn 2.0.48",
]
[[package]]
@ -4352,5 +4259,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.46",
"syn 2.0.48",
]

View File

@ -8,6 +8,8 @@ members = [
"atuin-common",
]
resolver = "2"
[workspace.package]
name = "atuin"
version = "17.2.1"

View File

@ -15,6 +15,7 @@ repository = { workspace = true }
[features]
default = ["sync"]
sync = ["urlencoding", "reqwest", "sha2", "hex"]
check-update = []
[dependencies]
atuin-common = { path = "../atuin-common", version = "17.2.1" }

View File

@ -10,8 +10,8 @@ use reqwest::{
use atuin_common::{
api::{
AddHistoryRequest, CountResponse, DeleteHistoryRequest, ErrorResponse, IndexResponse,
LoginRequest, LoginResponse, RegisterResponse, StatusResponse, SyncHistoryResponse, ChangePasswordRequest,
AddHistoryRequest, CountResponse, DeleteHistoryRequest, ErrorResponse, LoginRequest,
LoginResponse, RegisterResponse, StatusResponse, SyncHistoryResponse, ChangePasswordRequest
},
record::RecordStatus,
};
@ -19,6 +19,7 @@ use atuin_common::{
api::{ATUIN_CARGO_VERSION, ATUIN_HEADER_VERSION, ATUIN_VERSION},
record::{EncryptedData, HostId, Record, RecordIdx},
};
use semver::Version;
use time::format_description::well_known::Rfc3339;
use time::OffsetDateTime;
@ -97,7 +98,10 @@ pub async fn login(address: &str, req: LoginRequest) -> Result<LoginResponse> {
Ok(session)
}
#[cfg(feature = "check-update")]
pub async fn latest_version() -> Result<Version> {
use atuin_common::api::IndexResponse;
let url = "https://api.atuin.sh";
let client = reqwest::Client::new();

View File

@ -402,6 +402,7 @@ impl Settings {
}
}
#[cfg(feature = "check-update")]
fn needs_update_check(&self) -> Result<bool> {
let last_check = Settings::last_version_check()?;
let diff = OffsetDateTime::now_utc() - last_check;
@ -410,6 +411,7 @@ impl Settings {
Ok(diff.whole_hours() >= 1)
}
#[cfg(feature = "check-update")]
async fn latest_version(&self) -> Result<Version> {
// Default to the current version, and if that doesn't parse, a version so high it's unlikely to ever
// suggest upgrading.
@ -440,6 +442,7 @@ impl Settings {
}
// Return Some(latest version) if an update is needed. Otherwise, none.
#[cfg(feature = "check-update")]
pub async fn needs_update(&self) -> Option<Version> {
if !self.update_check {
return None;
@ -463,6 +466,11 @@ impl Settings {
None
}
#[cfg(not(feature = "check-update"))]
pub async fn needs_update(&self) -> Option<Version> {
None
}
pub fn builder() -> Result<ConfigBuilder<DefaultState>> {
let data_dir = atuin_common::utils::data_dir();
let db_path = data_dir.join("history.db");
@ -478,7 +486,7 @@ impl Settings {
.set_default("session_path", session_path.to_str())?
.set_default("dialect", "us")?
.set_default("auto_sync", true)?
.set_default("update_check", true)?
.set_default("update_check", cfg!(feature = "check-update"))?
.set_default("sync_address", "https://api.atuin.sh")?
.set_default("sync_frequency", "10m")?
.set_default("search_mode", "fuzzy")?

View File

@ -1,6 +1,6 @@
[package]
name = "atuin-server-postgres"
edition = "2018"
edition = "2021"
description = "server postgres database library for atuin"
version = { workspace = true }

View File

@ -1,6 +1,6 @@
[package]
name = "atuin-server"
edition = "2018"
edition = "2021"
description = "server library for atuin"
rust-version = { workspace = true }

View File

@ -11,6 +11,7 @@ use axum::{
Json,
};
use http::StatusCode;
use metrics::counter;
use rand::rngs::OsRng;
use tracing::{debug, error, info, instrument};
use uuid::Uuid;
@ -142,6 +143,8 @@ pub async fn register<DB: Database>(
.await;
}
counter!("atuin_users_registered", 1);
match db.add_session(&new_session).await {
Ok(_) => Ok(Json(RegisterResponse { session: token })),
Err(e) => {
@ -166,6 +169,9 @@ pub async fn delete<DB: Database>(
return Err(ErrorResponse::reply("failed to delete user")
.with_status(StatusCode::INTERNAL_SERVER_ERROR));
};
counter!("atuin_users_deleted", 1);
Ok(Json(DeleteUserResponse {}))
}

View File

@ -33,11 +33,12 @@ buildflags = ["--release"]
atuin = { path = "/usr/bin/atuin" }
[features]
default = ["client", "sync", "server", "clipboard"]
default = ["client", "sync", "server", "clipboard", "check-update"]
client = ["atuin-client"]
sync = ["atuin-client/sync"]
server = ["atuin-server", "atuin-server-postgres", "tracing-subscriber"]
clipboard = ["cli-clipboard"]
check-update = ["atuin-client/check-update"]
[dependencies]
atuin-server-postgres = { path = "../atuin-server-postgres", version = "17.2.1", optional = true }

View File

@ -1,6 +1,6 @@
use std::{
fmt::{self, Display},
io::{self, Write},
io::{self, IsTerminal, Write},
time::Duration,
};
@ -150,50 +150,51 @@ pub fn print_list(
let flush_each_line = print0;
for h in iterator {
match write!(
w,
"{}{}",
parsed_fmt.with_args(&FmtHistory(h)),
entry_terminator
) {
Ok(()) => {}
// ignore broken pipe (issue #626)
Err(e) if e.kind() == io::ErrorKind::BrokenPipe => {
return;
}
Err(err) => {
eprintln!("ERROR: History output failed with the following error: {err}");
let fh = FmtHistory(h, CmdFormat::for_output(&w));
let args = parsed_fmt.with_args(&fh);
let write = write!(w, "{args}{entry_terminator}");
if let Err(err) = args.status() {
eprintln!("ERROR: history output failed with: {err}");
std::process::exit(1);
}
}
check_for_write_errors(write);
if flush_each_line {
match w.flush() {
Ok(()) => {}
// ignore broken pipe (issue #626)
Err(e) if e.kind() == io::ErrorKind::BrokenPipe => {}
Err(err) => {
eprintln!("ERROR: History output failed with the following error: {err}");
std::process::exit(1);
}
}
check_for_write_errors(w.flush());
}
}
if !flush_each_line {
match w.flush() {
Ok(()) => {}
// ignore broken pipe (issue #626)
Err(e) if e.kind() == io::ErrorKind::BrokenPipe => {}
Err(err) => {
check_for_write_errors(w.flush());
}
}
fn check_for_write_errors(write: Result<(), io::Error>) {
if let Err(err) = write {
// Ignore broken pipe (issue #626)
if err.kind() != io::ErrorKind::BrokenPipe {
eprintln!("ERROR: History output failed with the following error: {err}");
std::process::exit(1);
}
}
}
/// Wrapper around `History` so we can format output dynamically at runtime
struct FmtHistory<'a>(&'a History, CmdFormat);
enum CmdFormat {
Literal,
Escaped,
}
/// type wrapper around `History` so we can implement traits
struct FmtHistory<'a>(&'a History);
impl CmdFormat {
fn for_output<O: IsTerminal>(out: &O) -> Self {
if out.is_terminal() {
Self::Escaped
} else {
Self::Literal
}
}
}
static TIME_FMT: &[time::format_description::FormatItem<'static>] =
format_description!("[year]-[month]-[day] [hour repr:24]:[minute]:[second]");
@ -203,7 +204,10 @@ impl FormatKey for FmtHistory<'_> {
#[allow(clippy::cast_sign_loss)]
fn fmt(&self, key: &str, f: &mut fmt::Formatter<'_>) -> Result<(), FormatKeyError> {
match key {
"command" => f.write_str(&self.0.command.trim().escape_control())?,
"command" => match self.1 {
CmdFormat::Literal => f.write_str(self.0.command.trim()),
CmdFormat::Escaped => f.write_str(&self.0.command.trim().escape_control()),
}?,
"directory" => f.write_str(self.0.cwd.trim())?,
"exit" => f.write_str(&self.0.exit.to_string())?,
"duration" => {

View File

@ -16,6 +16,8 @@ pub struct HistoryList<'a> {
history: &'a [History],
block: Option<Block<'a>>,
inverted: bool,
/// Apply an alternative highlighting to the selected row
alternate_highlight: bool,
}
#[derive(Default)]
@ -65,6 +67,7 @@ impl<'a> StatefulWidget for HistoryList<'a> {
y: 0,
state,
inverted: self.inverted,
alternate_highlight: self.alternate_highlight,
};
for item in self.history.iter().skip(state.offset).take(end - start) {
@ -81,11 +84,12 @@ impl<'a> StatefulWidget for HistoryList<'a> {
}
impl<'a> HistoryList<'a> {
pub fn new(history: &'a [History], inverted: bool) -> Self {
pub fn new(history: &'a [History], inverted: bool, alternate_highlight: bool) -> Self {
Self {
history,
block: None,
inverted,
alternate_highlight,
}
}
@ -116,11 +120,14 @@ struct DrawState<'a> {
y: u16,
state: &'a ListState,
inverted: bool,
alternate_highlight: bool,
}
// longest line prefix I could come up with
#[allow(clippy::cast_possible_truncation)] // we know that this is <65536 length
pub const PREFIX_LENGTH: u16 = " > 123ms 59s ago".len() as u16;
static SPACES: &str = " ";
static _ASSERT: () = assert!(SPACES.len() == PREFIX_LENGTH as usize);
impl DrawState<'_> {
fn index(&mut self) {
@ -157,7 +164,10 @@ impl DrawState<'_> {
let time = format_duration(since.try_into().unwrap_or_default());
// pad the time a little bit before we write. this aligns things nicely
self.x = PREFIX_LENGTH - 4 - time.len() as u16;
// skip padding if for some reason it is already too long to align nicely
let padding =
usize::from(PREFIX_LENGTH).saturating_sub(usize::from(self.x) + 4 + time.len());
self.draw(&SPACES[..padding], Style::default());
self.draw(&time, style);
self.draw(" ago", style);
@ -165,12 +175,14 @@ impl DrawState<'_> {
fn command(&mut self, h: &History) {
let mut style = Style::default();
if self.y as usize + self.state.offset == self.state.selected {
if !self.alternate_highlight && (self.y as usize + self.state.offset == self.state.selected)
{
// if not applying alternative highlighting to the whole row, color the command
style = style.fg(Color::Red).add_modifier(Modifier::BOLD);
}
for section in h.command.escape_control().split_ascii_whitespace() {
self.x += 1;
self.draw(" ", style);
if self.x > self.list_area.width {
// Avoid attempting to draw a command section beyond the width
// of the list
@ -180,7 +192,7 @@ impl DrawState<'_> {
}
}
fn draw(&mut self, s: &str, style: Style) {
fn draw(&mut self, s: &str, mut style: Style) {
let cx = self.list_area.left() + self.x;
let cy = if self.inverted {
@ -189,6 +201,11 @@ impl DrawState<'_> {
self.list_area.bottom() - self.y - 1
};
if self.alternate_highlight && (self.y as usize + self.state.offset == self.state.selected)
{
style = style.add_modifier(Modifier::REVERSED);
}
let w = (self.list_area.width - self.x) as usize;
self.x += self.buf.set_stringn(cx, cy, s, w, style).0 - cx;
}

View File

@ -550,7 +550,7 @@ impl State {
match self.tab_index {
0 => {
let results_list = Self::build_results_list(style, results);
let results_list = Self::build_results_list(style, results, self.keymap_mode);
f.render_stateful_widget(results_list, results_list_chunk, &mut self.results_state);
}
@ -652,8 +652,13 @@ impl State {
stats
}
fn build_results_list(style: StyleState, results: &[History]) -> HistoryList {
let results_list = HistoryList::new(results, style.invert);
fn build_results_list(
style: StyleState,
results: &[History],
keymap_mode: KeymapMode,
) -> HistoryList<'_> {
let results_list =
HistoryList::new(results, style.invert, keymap_mode == KeymapMode::VimNormal);
if style.compact {
results_list

View File

@ -3,7 +3,7 @@ use std::collections::{HashMap, HashSet};
use atuin_common::utils::Escapable as _;
use clap::Parser;
use crossterm::style::{Color, ResetColor, SetAttribute, SetForegroundColor};
use eyre::{bail, Result};
use eyre::Result;
use interim::parse_date_string;
use atuin_client::{
@ -16,7 +16,7 @@ use time::{Duration, OffsetDateTime, Time};
#[derive(Parser, Debug)]
#[command(infer_subcommands = true)]
pub struct Cmd {
/// compute statistics for the specified period, leave blank for statistics since the beginning
/// Compute statistics for the specified period, leave blank for statistics since the beginning. See https://docs.atuin.sh/reference/stats/ for more details.
period: Vec<String>,
/// How many top commands to list
@ -24,7 +24,7 @@ pub struct Cmd {
count: usize,
}
fn compute_stats(settings: &Settings, history: &[History], count: usize) -> Result<()> {
fn compute_stats(settings: &Settings, history: &[History], count: usize) {
let mut commands = HashSet::<&str>::with_capacity(history.len());
let mut prefixes = HashMap::<&str, usize>::with_capacity(history.len());
for i in history {
@ -41,7 +41,8 @@ fn compute_stats(settings: &Settings, history: &[History], count: usize) -> Resu
top.sort_unstable_by_key(|x| std::cmp::Reverse(x.1));
top.truncate(count);
if top.is_empty() {
bail!("No commands found");
println!("No commands found");
return;
}
let max = top.iter().map(|x| x.1).max().unwrap();
@ -74,8 +75,6 @@ fn compute_stats(settings: &Settings, history: &[History], count: usize) -> Resu
}
println!("Total commands: {}", history.len());
println!("Unique commands: {unique}");
Ok(())
}
impl Cmd {
@ -114,7 +113,7 @@ impl Cmd {
let end = start + Duration::days(1);
db.range(start, end).await?
};
compute_stats(settings, &history, self.count)?;
compute_stats(settings, &history, self.count);
Ok(())
}
}

View File

@ -33,8 +33,8 @@ impl Cmd {
if std::env::var("ATUIN_NOBIND").is_err() {
const BIND_CTRL_R: &str = r"bindkey -M emacs '^r' _atuin_search_widget
bindkey -M vicmd '^r' _atuin_search_vicmd_widget
bindkey -M viins '^r' _atuin_search_viins_widget";
bindkey -M viins '^r' _atuin_search_viins_widget
bindkey -M vicmd '/' _atuin_search_widget";
const BIND_UP_ARROW: &str = r"bindkey -M emacs '^[[A' _atuin_up_search_widget
bindkey -M vicmd '^[[A' _atuin_up_search_vicmd_widget

View File

@ -71,28 +71,45 @@ __atuin_set_ret_value() {
return ${1:+"$1"}
}
# The expansion ${PS1@P} is available in bash >= 4.4.
# The shell function `__atuin_evaluate_prompt` evaluates prompt sequences in
# $PS1. We switch the implementation of the shell function
# `__atuin_evaluate_prompt` based on the Bash version because the expansion
# ${PS1@P} is only available in bash >= 4.4.
if ((BASH_VERSINFO[0] >= 5 || BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 4)); then
__atuin_use_prompt_expansion=true
__atuin_evaluate_prompt() {
__atuin_set_ret_value "${__bp_last_ret_value-}" "${__bp_last_argument_prev_command-}"
__atuin_prompt=${PS1@P}
# Note: Strip the control characters ^A (\001) and ^B (\002), which
# Bash internally uses to enclose the escape sequences. They are
# produced by '\[' and '\]', respectively, in $PS1 and used to tell
# Bash that the strings inbetween do not contribute to the prompt
# width. After the prompt width calculation, Bash strips those control
# characters before outputting it to the terminal. We here strip these
# characters following Bash's behavior.
__atuin_prompt=${__atuin_prompt//[$'\001\002']}
# Count the number of newlines contained in $__atuin_prompt
__atuin_prompt_offset=${__atuin_prompt//[!$'\n']}
__atuin_prompt_offset=${#__atuin_prompt_offset}
}
else
__atuin_use_prompt_expansion=false
__atuin_evaluate_prompt() {
__atuin_prompt='$ '
__atuin_prompt_offset=0
}
fi
__atuin_accept_line() {
local __atuin_command=$1
# Reprint the prompt, accounting for multiple lines
if [[ $__atuin_use_prompt_expansion == true ]]; then
local __atuin_prompt=${PS1@P}
local __atuin_prompt_offset
__atuin_prompt_offset=$(printf '%s' "$__atuin_prompt" | wc -l)
local __atuin_prompt __atuin_prompt_offset
__atuin_evaluate_prompt
if ((__atuin_prompt_offset > 0)); then
tput cuu "$__atuin_prompt_offset"
fi
printf '%s\n' "$__atuin_prompt$__atuin_command"
else
printf '%s\n' "\$ $__atuin_command"
fi
# Add it to the bash history
history -s "$__atuin_command"
@ -140,10 +157,8 @@ __atuin_accept_line() {
# Bash will redraw only the line with the prompt after we finish,
# so to work for a multiline prompt we need to print it ourselves,
# then go to the beginning of the last line.
if [[ $__atuin_use_prompt_expansion == true ]]; then
__atuin_set_ret_value "${__bp_last_ret_value-}" "${__bp_last_argument_prev_command-}"
printf '%s\r' "${PS1@P}"
fi
__atuin_evaluate_prompt
printf '%s\r' "$__atuin_prompt"
}
__atuin_history() {
@ -229,6 +244,7 @@ if [[ $__atuin_bind_ctrl_r == true ]]; then
# the vi_nmap keymap in ble.sh.
bind -m emacs -x '"\C-r": __atuin_history --keymap-mode=emacs'
bind -m vi-insert -x '"\C-r": __atuin_history --keymap-mode=vim-insert'
bind -m vi-command -x '"/": __atuin_history --keymap-mode=emacs'
fi
# shellcheck disable=SC2154