diff --git a/.deepsource.toml b/.deepsource.toml index cf6e317..2895393 100644 --- a/.deepsource.toml +++ b/.deepsource.toml @@ -2,4 +2,9 @@ version = 1 [[analyzers]] name = "rust" -enabled = true + + [analyzers.meta] + msrv = "stable" + +[[analyzers]] +name = "shell" \ No newline at end of file diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md index a2a6a67..609eb60 100644 --- a/.github/CODE_OF_CONDUCT.md +++ b/.github/CODE_OF_CONDUCT.md @@ -17,23 +17,23 @@ diverse, inclusive, and healthy community. Examples of behavior that contributes to a positive environment for our community include: -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience -* Focusing on what is best not just for us as individuals, but for the +- Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: -* The use of sexualized language or imagery, and sexual attention or +- The use of sexualized language or imagery, and sexual attention or advances of any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email address, without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a +- Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities @@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban. ### 4. Permanent Ban **Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an +standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. **Consequence**: A permanent ban from any sort of public interaction within diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cb15ac9..95b7359 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,8 @@ env: CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }} CARGO_INCREMENTAL: 0 CARGO_TERM_COLOR: always +permissions: + contents: read jobs: ci: name: ${{ matrix.os }} @@ -16,33 +18,37 @@ jobs: matrix: os: [ubuntu-latest, windows-latest] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - - uses: actions-rs/toolchain@v1 if: ${{ matrix.os == 'windows-latest' }} with: - toolchain: stable - components: rustfmt, clippy + components: clippy profile: minimal - override: true - - uses: cachix/install-nix-action@v16 + toolchain: stable + - uses: actions-rs/toolchain@v1 + if: ${{ matrix.os == 'windows-latest' }} + with: + components: rustfmt + profile: minimal + toolchain: nightly + - uses: cachix/install-nix-action@v20 if: ${{ matrix.os != 'windows-latest' }} with: nix_path: nixpkgs=channel:nixos-unstable - - uses: cachix/cachix-action@v10 + - uses: cachix/cachix-action@v12 if: ${{ matrix.os != 'windows-latest' && env.CACHIX_AUTH_TOKEN != '' }} with: authToken: ${{ env.CACHIX_AUTH_TOKEN }} name: zoxide - - name: Setup cache - uses: Swatinem/rust-cache@v1 + uses: Swatinem/rust-cache@v2 with: - key: ${{ matrix.target }} - - - run: cargo xtask ci - if: ${{ matrix.os == 'windows-latest' }} - - run: nix-shell --cores 0 --pure --run 'rm -rf ~/.cargo/bin; cargo xtask ci' - if: ${{ matrix.os != 'windows-latest' }} + key: ${{ matrix.os }} + - name: Install just + uses: taiki-e/install-action@v2 + with: + tool: just + - name: Run lints + tests + run: just lint test diff --git a/.github/workflows/no-response.yml b/.github/workflows/no-response.yml index b73a46c..a23313f 100644 --- a/.github/workflows/no-response.yml +++ b/.github/workflows/no-response.yml @@ -17,6 +17,6 @@ jobs: daysUntilClose: 30 responseRequiredLabel: waiting-for-response closeComment: > - This issue has been automatically closed due to inactivity. If you - feel this is still relevant, please comment here or create a fresh - issue. + This issue has been automatically closed due to inactivity. If you feel + this is still relevant, please comment here or create a fresh issue. + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8d0accf..efa9466 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,11 +6,11 @@ on: workflow_dispatch: env: CARGO_INCREMENTAL: 0 +permissions: + contents: write jobs: release: name: ${{ matrix.target }} - permissions: - contents: write runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -26,29 +26,25 @@ jobs: - os: ubuntu-latest target: aarch64-unknown-linux-musl deb: true - - os: macos-11 target: x86_64-apple-darwin - os: macos-11 target: aarch64-apple-darwin - - os: windows-latest target: x86_64-pc-windows-msvc - os: windows-latest target: aarch64-pc-windows-msvc steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Get version id: get_version uses: SebRollen/toml-action@v1.0.2 with: file: Cargo.toml field: package.version - - name: Install Rust uses: actions-rs/toolchain@v1 with: @@ -56,62 +52,52 @@ jobs: profile: minimal override: true target: ${{ matrix.target }} - - name: Setup cache - uses: Swatinem/rust-cache@v1 + uses: Swatinem/rust-cache@v1.0.2 with: key: ${{ matrix.target }} - - name: Build binary uses: actions-rs/cargo@v1 with: command: build args: --release --locked --target=${{ matrix.target }} --color=always --verbose use-cross: ${{ runner.os == 'Linux' }} - - name: Install cargo-deb if: ${{ matrix.deb == true }} uses: actions-rs/install@v0.1 with: crate: cargo-deb - - name: Build deb if: ${{ matrix.deb == true }} uses: actions-rs/cargo@v1 with: command: deb args: --no-build --no-strip --output=. --target=${{ matrix.target }} - - name: Package (*nix) if: runner.os != 'Windows' - run: > - tar -cv - CHANGELOG.md LICENSE README.md - man/ - -C contrib/ completions/ -C ../ - -C target/${{ matrix.target }}/release/ zoxide - | gzip --best - > 'zoxide-${{ steps.get_version.outputs.value }}-${{ matrix.target }}.tar.gz' + run: | + tar -cv CHANGELOG.md LICENSE README.md man/ \ + -C contrib/ completions/ -C ../ \ + -C target/${{ matrix.target }}/release/ zoxide | + gzip --best > \ + zoxide-${{ steps.get_version.outputs.value }}-${{ matrix.target }}.tar.gz - name: Package (Windows) if: runner.os == 'Windows' - run: > - 7z a 'zoxide-${{ steps.get_version.outputs.value }}-${{ matrix.target }}.zip' - CHANGELOG.md LICENSE README.md - ./man/ - ./contrib/completions/ - ./target/${{ matrix.target }}/release/zoxide.exe - + run: | + 7z a zoxide-${{ steps.get_version.outputs.value }}-${{ matrix.target }}.zip ` + CHANGELOG.md LICENSE README.md ./man/ ./contrib/completions/ ` + ./target/${{ matrix.target }}/release/zoxide.exe - name: Upload artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: ${{ matrix.target }} path: | *.deb *.tar.gz *.zip - - name: Create release - if: ${{ github.ref == 'refs/heads/main' && startsWith(github.event.head_commit.message, 'chore(release)') }} + if: | + ${{ github.ref == 'refs/heads/main' && startsWith(github.event.head_commit.message, 'chore(release)') }} uses: softprops/action-gh-release@v1 with: draft: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 46be75f..83e8681 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,11 +7,21 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## Unreleased +## [0.9.1] - 2023-05-07 ### Added -- Fish/Zsh: Aliases on `__zoxide_z` will now use completions. +- Fish/Zsh: aliases on `__zoxide_z` will now use completions. +- Nushell: add support for v0.78.0. +- Fish: plugin now works on older versions. +- PowerShell: warn when PowerShell version is too old for `z -` and `z +`. +- PowerShell: support for PWD hooks on all versions. + +### Fixed + +- Fish: not providing `cd` completions when there is a space in the path. +- Bash/Fish/Zsh: providing `z` completions when the last argument starts with `z!`. +- Bash/Fish/Zsh: attempting to `cd` when the last argument is `z!`. ## [0.9.0] - 2023-01-08 @@ -28,7 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Nushell: upgrade minimum supported version to v0.73.0. - Zsh: fix extra space in interactive completions when no match is found. - Fzf: various improvements, upgrade minimum supported version to v0.33.0. -- Nushell: Accidental redefinition of hooks when initialized twice. +- Nushell: accidental redefinition of hooks when initialized twice. ### Removed @@ -132,7 +142,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- PowerShell: Hook not initializing correctly. +- PowerShell: hook not initializing correctly. ## [0.7.6] - 2021-10-13 @@ -430,6 +440,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - GitHub Actions pipeline to build and upload releases. - Support for zsh. +[0.9.1]: https://github.com/ajeetdsouza/zoxide/compare/v0.9.0...v0.9.1 [0.9.0]: https://github.com/ajeetdsouza/zoxide/compare/v0.8.3...v0.9.0 [0.8.3]: https://github.com/ajeetdsouza/zoxide/compare/v0.8.2...v0.8.3 [0.8.2]: https://github.com/ajeetdsouza/zoxide/compare/v0.8.1...v0.8.2 diff --git a/Cargo.lock b/Cargo.lock index eecacd9..1ff239f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,15 +8,6 @@ version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" -[[package]] -name = "aho-corasick" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" -dependencies = [ - "memchr", -] - [[package]] name = "aliasable" version = "0.1.3" @@ -24,31 +15,82 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" [[package]] -name = "anyhow" -version = "1.0.68" +name = "anstream" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is-terminal", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" + +[[package]] +name = "anstyle-parse" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "anstyle-wincon" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +dependencies = [ + "anstyle", + "windows-sys 0.48.0", +] + +[[package]] +name = "anyhow" +version = "1.0.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" [[package]] name = "askama" -version = "0.11.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb98f10f371286b177db5eeb9a6e5396609555686a35e1d4f7b9a9c6d8af0139" +checksum = "47cbc3cf73fa8d9833727bbee4835ba5c421a0d65b72daf9a7b5d0e0f9cfb57e" dependencies = [ "askama_derive", "askama_escape", - "askama_shared", ] [[package]] name = "askama_derive" -version = "0.11.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87bf87e6e8b47264efa9bde63d6225c6276a52e05e91bf37eaa8afd0032d6b71" +checksum = "c22fbe0413545c098358e56966ff22cdd039e10215ae213cfbd65032b119fc94" dependencies = [ - "askama_shared", + "mime", + "mime_guess", + "nom", "proc-macro2", - "syn", + "quote", + "syn 2.0.15", ] [[package]] @@ -57,27 +99,13 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341" -[[package]] -name = "askama_shared" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf722b94118a07fcbc6640190f247334027685d4e218b794dbfe17c32bf38ed0" -dependencies = [ - "askama_escape", - "mime", - "mime_guess", - "nom", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "assert_cmd" -version = "2.0.7" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa3d466004a8b4cb1bc34044240a2fd29d17607e2e3bd613eb44fd48e8100da3" +checksum = "86d6b683edf8d1119fe420a94f8a7e389239666aa72e65495d91c00462510151" dependencies = [ + "anstyle", "bstr", "doc-comment", "predicates", @@ -103,9 +131,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bstr" -version = "1.1.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45ea9b00a7b3f2988e9a65ad3917e62123c38dba709b666506207be96d1790b" +checksum = "c3d4260bcc2e8fc9df1eac4919a720effeb63a3f0952f5bf4944adfa18897f09" dependencies = [ "memchr", "once_cell", @@ -115,9 +143,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" [[package]] name = "cfg-if" @@ -127,33 +155,42 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.0.32" +version = "4.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7db700bc935f9e43e88d00b0850dae18a63773cfbec6d8e070fccf7fef89a39" +checksum = "34d21f9bf1b425d2968943631ec91202fe5e837264063503708b83013f8fc938" dependencies = [ - "bitflags", + "clap_builder", "clap_derive", - "clap_lex", - "is-terminal", "once_cell", +] + +[[package]] +name = "clap_builder" +version = "4.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "914c8c79fb560f238ef6429439a30023c862f7a28e688c58f7203f12b29970bd" +dependencies = [ + "anstream", + "anstyle", + "bitflags", + "clap_lex", "strsim", - "termcolor", ] [[package]] name = "clap_complete" -version = "4.0.7" +version = "4.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10861370d2ba66b0f5989f83ebf35db6421713fd92351790e7fdd6c36774c56b" +checksum = "1a19591b2ab0e3c04b588a0e04ddde7b9eaa423646d1b4a8092879216bf47473" dependencies = [ "clap", ] [[package]] name = "clap_complete_fig" -version = "4.0.2" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46b30e010e669cd021e5004f3be26cff6b7c08d2a8a0d65b48d43a8cc0efd6c3" +checksum = "f3af28956330989baa428ed4d3471b853715d445c62de21b67292e22cf8a41fa" dependencies = [ "clap", "clap_complete", @@ -161,26 +198,49 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.0.21" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014" +checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4" dependencies = [ "heck", - "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "clap_lex" -version = "0.3.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" +checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" + +[[package]] +name = "color-print" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2a5e6504ed8648554968650feecea00557a3476bc040d0ffc33080e66b646d0" dependencies = [ - "os_str_bytes", + "color-print-proc-macro", ] +[[package]] +name = "color-print-proc-macro" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d51beaa537d73d2d1ff34ee70bc095f170420ab2ec5d687ecd3ec2b0d092514b" +dependencies = [ + "nom", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "difflib" version = "0.4.0" @@ -189,22 +249,23 @@ checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" [[package]] name = "dirs" -version = "4.0.0" +version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" dependencies = [ "dirs-sys", ] [[package]] name = "dirs-sys" -version = "0.3.7" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" dependencies = [ "libc", + "option-ext", "redox_users", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -215,25 +276,25 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] name = "dunce" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bd4b30a6560bbd9b4620f4de34c3f14f60848e58a9b7216801afcb4c7b31c3c" +checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" [[package]] name = "either" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "errno" -version = "0.2.8" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -248,24 +309,18 @@ dependencies = [ [[package]] name = "fastrand" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" dependencies = [ "instant", ] -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if", "libc", @@ -278,50 +333,17 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" -[[package]] -name = "globset" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" -dependencies = [ - "aho-corasick", - "bstr", - "fnv", - "log", - "regex", -] - [[package]] name = "heck" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.2.6" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] - -[[package]] -name = "ignore" -version = "0.4.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a05705bc64e0b66a806c3740bd6578ea66051b157ec42dc219c785cbf185aef3" -dependencies = [ - "globset", - "lazy_static", - "log", - "memchr", - "regex", - "same-file", - "thread_local", - "walkdir", - "winapi-util", -] +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" [[package]] name = "instant" @@ -334,24 +356,25 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.3" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" dependencies = [ + "hermit-abi", "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "is-terminal" -version = "0.4.2" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ "hermit-abi", "io-lifetimes", "rustix", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -363,32 +386,17 @@ dependencies = [ "either", ] -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - [[package]] name = "libc" -version = "0.2.139" +version = "0.2.143" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "edc207893e85c5d6be840e969b496b53d94cec8be2d501b214f50daa97fa8024" [[package]] name = "linux-raw-sys" -version = "0.1.4" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" - -[[package]] -name = "log" -version = "0.4.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f" [[package]] name = "memchr" @@ -398,9 +406,9 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "mime" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "mime_guess" @@ -420,9 +428,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "nix" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46a58d1d356c6597d08cde02c2f09d785b09e28711837b1ed667dc652c08a694" +checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" dependencies = [ "bitflags", "cfg-if", @@ -432,9 +440,9 @@ dependencies = [ [[package]] name = "nom" -version = "7.1.2" +version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5507769c4919c998e69e49c839d9dc6e693ede4cc4290d6ad8b41d4f09c548c" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" dependencies = [ "memchr", "minimal-lexical", @@ -442,21 +450,21 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] -name = "os_str_bytes" -version = "6.4.1" +name = "option-ext" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "ouroboros" -version = "0.15.5" +version = "0.15.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbb50b356159620db6ac971c6d5c9ab788c9cc38a6f49619fca2a27acb062ca" +checksum = "e1358bd1558bd2a083fed428ffeda486fbfb323e698cdda7794259d592ca72db" dependencies = [ "aliasable", "ouroboros_macro", @@ -464,23 +472,30 @@ dependencies = [ [[package]] name = "ouroboros_macro" -version = "0.15.5" +version = "0.15.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a0d9d1a6191c4f391f87219d1ea42b23f09ee84d64763cd05ee6ea88d9f384d" +checksum = "5f7d21ccd03305a674437ee1248f3ab5d4b1db095cf1caf49f1713ddf61956b7" dependencies = [ "Inflector", "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] -name = "predicates" -version = "2.1.5" +name = "ppv-lite86" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59230a63c37f3e18569bdb90e4a89cbf5bf8b06fea0b84e65ea10cc4df47addd" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "predicates" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09963355b9f467184c04017ced4a2ba2d75cbcb4e7462690d388233253d4b1a9" dependencies = [ + "anstyle", "difflib", "itertools", "predicates-core", @@ -488,15 +503,15 @@ dependencies = [ [[package]] name = "predicates-core" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72f883590242d3c6fc5bf50299011695fa6590c2c70eac95ee1bdb9a733ad1a2" +checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" [[package]] name = "predicates-tree" -version = "1.0.7" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54ff541861505aabf6ea722d2131ee980b8276e10a1297b94e896dd8b621850d" +checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" dependencies = [ "predicates-core", "termtree", @@ -511,7 +526,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -528,22 +543,52 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.49" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.23" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + [[package]] name = "redox_syscall" version = "0.2.16" @@ -553,6 +598,15 @@ dependencies = [ "bitflags", ] +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags", +] + [[package]] name = "redox_users" version = "0.4.3" @@ -560,47 +614,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ "getrandom", - "redox_syscall", + "redox_syscall 0.2.16", "thiserror", ] -[[package]] -name = "regex" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - [[package]] name = "regex-automata" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -[[package]] -name = "regex-syntax" -version = "0.6.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" - -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - [[package]] name = "rstest" -version = "0.16.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b07f2d176c472198ec1e6551dc7da28f1c089652f66a7b722676c2238ebc0edf" +checksum = "de1bb486a691878cd320c2f0d319ba91eeaa2e894066d8b5f8f117c000e9d962" dependencies = [ "rstest_macros", "rustc_version", @@ -608,27 +636,28 @@ dependencies = [ [[package]] name = "rstest_macros" -version = "0.16.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7229b505ae0706e64f37ffc54a9c163e11022a6636d58fe1f3f52018257ff9f7" +checksum = "290ca1a1c8ca7edb7c3283bd44dc35dd54fdec6253a3912e201ba1072018fca8" dependencies = [ "cfg-if", "proc-macro2", "quote", "rustc_version", - "syn", + "syn 1.0.109", "unicode-ident", ] [[package]] name = "rstest_reuse" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9b5aed35457441e7e0db509695ba3932d4c47e046777141c167efe584d0ec17" +checksum = "45f80dcc84beab3a327bbe161f77db25f336a1452428176787c8c79ac79d7073" dependencies = [ "quote", + "rand", "rustc_version", - "syn", + "syn 1.0.109", ] [[package]] @@ -642,59 +671,44 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.6" +version = "0.37.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4feacf7db682c6c329c4ede12649cd36ecab0f3be5b7d74e6a20304725db4549" +checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" dependencies = [ "bitflags", "errno", "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys", -] - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", + "windows-sys 0.48.0", ] [[package]] name = "semver" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.152" +version = "1.0.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +checksum = "71b2f6e1ab5c2b98c05f0f35b236b22e8df7ead6ffbf51d7808da7f8817e7ab6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.152" +version = "1.0.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +checksum = "a2a0814352fd64b58489904a44ea8d90cb1a91dcb6b4f5ebabc32c8318e93cb6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] -[[package]] -name = "shell-words" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" - [[package]] name = "static_assertions" version = "1.1.0" @@ -709,9 +723,20 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.107" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" dependencies = [ "proc-macro2", "quote", @@ -720,60 +745,41 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.3.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" dependencies = [ "cfg-if", "fastrand", - "libc", - "redox_syscall", - "remove_dir_all", - "winapi", -] - -[[package]] -name = "termcolor" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" -dependencies = [ - "winapi-util", + "redox_syscall 0.3.5", + "rustix", + "windows-sys 0.45.0", ] [[package]] name = "termtree" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95059e91184749cb66be6dc994f67f182b6d897cb3df74a5bf66b5e709295fd8" +checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn", -] - -[[package]] -name = "thread_local" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" -dependencies = [ - "once_cell", + "syn 2.0.15", ] [[package]] @@ -787,9 +793,15 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" + +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "version_check" @@ -806,17 +818,6 @@ dependencies = [ "libc", ] -[[package]] -name = "walkdir" -version = "2.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" -dependencies = [ - "same-file", - "winapi", - "winapi-util", -] - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -825,9 +826,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "which" -version = "4.3.0" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b" +checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" dependencies = [ "either", "libc", @@ -835,106 +836,140 @@ dependencies = [ ] [[package]] -name = "winapi" -version = "0.3.9" +name = "windows-sys" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", + "windows-targets 0.42.2", ] -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows-sys" -version = "0.42.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows-targets 0.48.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.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_msvc" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] -name = "xtask" -version = "0.1.0" -dependencies = [ - "anyhow", - "clap", - "ignore", - "shell-words", -] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "zoxide" -version = "0.9.0" +version = "0.9.1" dependencies = [ "anyhow", "askama", @@ -943,6 +978,7 @@ dependencies = [ "clap", "clap_complete", "clap_complete_fig", + "color-print", "dirs", "dunce", "fastrand", diff --git a/Cargo.toml b/Cargo.toml index 814f455..c16a100 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,67 +10,44 @@ name = "zoxide" readme = "README.md" repository = "https://github.com/ajeetdsouza/zoxide" rust-version = "1.65" -version = "0.9.0" +version = "0.9.1" [badges] maintenance = { status = "actively-developed" } -[workspace] -members = ["xtask/"] - -[workspace.dependencies] +[dependencies] anyhow = "1.0.32" -askama = { version = "0.11.0", default-features = false } -assert_cmd = "2.0.0" +askama = { version = "0.12.0", default-features = false } bincode = "1.3.1" clap = { version = "4.0.0", features = ["derive"] } -clap_complete = "4.0.0" -clap_complete_fig = "4.0.0" -dirs = "4.0.0" +color-print = "0.3.4" +dirs = "5.0.0" dunce = "1.0.1" fastrand = "1.7.0" glob = "0.3.0" -ignore = "0.4.18" +ouroboros = "0.15.5" +serde = { version = "1.0.116", features = ["derive"] } + +[target.'cfg(unix)'.dependencies] nix = { version = "0.26.1", default-features = false, features = [ "fs", "user", ] } -ouroboros = "0.15.5" -rstest = { version = "0.16.0", default-features = false } -rstest_reuse = "0.4.0" -serde = { version = "1.0.116", features = ["derive"] } -shell-words = "1.0.0" -tempfile = "3.1.0" -which = "4.2.5" - -[dependencies] -anyhow.workspace = true -askama.workspace = true -bincode.workspace = true -clap.workspace = true -dirs.workspace = true -dunce.workspace = true -fastrand.workspace = true -glob.workspace = true -ouroboros.workspace = true -serde.workspace = true - -[target.'cfg(unix)'.dependencies] -nix.workspace = true [target.'cfg(windows)'.dependencies] -which.workspace = true +which = "4.2.5" [build-dependencies] -clap.workspace = true -clap_complete.workspace = true -clap_complete_fig.workspace = true +clap = { version = "4.0.0", features = ["derive"] } +clap_complete = "4.0.0" +clap_complete_fig = "4.0.0" +color-print = "0.3.4" [dev-dependencies] -assert_cmd.workspace = true -rstest.workspace = true -rstest_reuse.workspace = true -tempfile.workspace = true +assert_cmd = "2.0.0" +rstest = { version = "0.17.0", default-features = false } +rstest_reuse = "0.5.0" +tempfile = "3.1.0" [features] default = [] diff --git a/README.md b/README.md index 671b3ca..16e1fbd 100644 --- a/README.md +++ b/README.md @@ -71,10 +71,10 @@ zoxide can be installed in 4 easy steps: > > | Distribution | Repository | Instructions | > | ------------------- | ----------------------- | ----------------------------------------------------------------------------------------------------- | - > | ***Any*** | **[crates.io]** | `cargo install zoxide --locked` | - > | *Any* | [asdf] | `asdf plugin add zoxide https://github.com/nyrst/asdf-zoxide.git`
`asdf install zoxide latest` | - > | *Any* | [conda-forge] | `conda install -c conda-forge zoxide` | - > | *Any* | [Linuxbrew] | `brew install zoxide` | + > | **_Any_** | **[crates.io]** | `cargo install zoxide --locked` | + > | _Any_ | [asdf] | `asdf plugin add zoxide https://github.com/nyrst/asdf-zoxide.git`
`asdf install zoxide latest` | + > | _Any_ | [conda-forge] | `conda install -c conda-forge zoxide` | + > | _Any_ | [Linuxbrew] | `brew install zoxide` | > | Alpine Linux 3.13+ | [Alpine Linux Packages] | `apk add zoxide` | > | Arch Linux | [Arch Linux Community] | `pacman -S zoxide` | > | CentOS 7+ | [Copr] | `dnf copr enable atim/zoxide`
`dnf install zoxide` | @@ -131,6 +131,12 @@ zoxide can be installed in 4 easy steps: > | [Chocolatey] | `choco install zoxide` | > | [conda-forge] | `conda install -c conda-forge zoxide` | > | [Scoop] | `scoop install zoxide` | + > + > If you're using Cygwin, Git Bash, or MSYS2, use the install script instead: + > + > ```sh + > curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash + > ``` @@ -141,7 +147,7 @@ zoxide can be installed in 4 easy steps: > > | Distribution | Repository | Instructions | > | ------------- | --------------- | ------------------------------- | - > | ***Any*** | **[crates.io]** | `cargo install zoxide --locked` | + > | **_Any_** | **[crates.io]** | `cargo install zoxide --locked` | > | DragonFly BSD | [DPorts] | `pkg install zoxide` | > | FreeBSD | [FreshPorts] | `pkg install zoxide` | > | NetBSD | [pkgsrc] | `pkgin install zoxide` | @@ -196,9 +202,6 @@ zoxide can be installed in 4 easy steps: > ```fish > zoxide init fish | source > ``` - > - > **Note** - > zoxide only supports fish v3.4.0 and above. @@ -229,23 +232,9 @@ zoxide can be installed in 4 easy steps: > Add this to your configuration (find it by running `echo $profile` in > PowerShell): > - > - For zoxide v0.8.0+: - > - > ```powershell - > Invoke-Expression (& { - > $hook = if ($PSVersionTable.PSVersion.Major -lt 6) { 'prompt' } else { 'pwd' } - > (zoxide init --hook $hook powershell | Out-String) - > }) - > ``` - > - > - For older versions of zoxide: - > - > ```powershell - > Invoke-Expression (& { - > $hook = if ($PSVersionTable.PSVersion.Major -lt 6) { 'prompt' } else { 'pwd' } - > (zoxide init --hook $hook powershell) -join "`n" - > }) - > ``` + > ```powershell + > Invoke-Expression (& { (zoxide init powershell | Out-String) }) + > ``` @@ -269,7 +258,7 @@ zoxide can be installed in 4 easy steps: > eval "$(zoxide init zsh)" > ``` > - > For completions to work, the above line must be added *after* `compinit` is + > For completions to work, the above line must be added _after_ `compinit` is > called. You may have to rebuild your completions cache by running > `rm ~/.zcompdump*; compinit`. @@ -423,17 +412,21 @@ Environment variables[^2] can be used for configuration. They must be set before | [nnn] | File manager | [nnn-autojump] | | [ranger] | File manager | [ranger-zoxide] | | [telescope.nvim] | Fuzzy finder for Neovim | [telescope-zoxide] | -| [tmux-session-wizard] | Jump to a directory inside a Tmux session | Natively supported | +| [t] | `tmux` session manager | Natively supported | +| [tmux-session-wizard] | `tmux` session manager | Natively supported | | [vim] / [neovim] | Text editor | [zoxide.vim] | | [xplr] | File manager | [zoxide.xplr] | | [xxh] | Transports shell configuration over SSH | [xxh-plugin-prerun-zoxide] | | [zabb] | Finds the shortest possible query for a path | Natively supported | | [zsh-autocomplete] | Realtime completions for zsh | Natively supported | -[^1]: Debian / Ubuntu derivatives update their packages very slowly. If you're -using one of these distributions, consider using the install script instead. -[^2]: If you're not sure how to set an environment variable on your shell, check -out the [wiki][wiki-env]. +[^1]: + Debian / Ubuntu derivatives update their packages very slowly. If you're + using one of these distributions, consider using the install script instead. + +[^2]: + If you're not sure how to set an environment variable on your shell, check + out the [wiki][wiki-env]. [algorithm-aging]: https://github.com/ajeetdsouza/zoxide/wiki/Algorithm#aging [algorithm-matching]: https://github.com/ajeetdsouza/zoxide/wiki/Algorithm#matching @@ -481,6 +474,7 @@ out the [wiki][wiki-env]. [releases]: https://github.com/ajeetdsouza/zoxide/releases [scoop]: https://github.com/ScoopInstaller/Main/tree/master/bucket/zoxide.json [slackbuilds-howto]: https://slackbuilds.org/howto/ +[t]: https://github.com/joshmedeski/t-smart-tmux-session-manager [telescope-zoxide]: https://github.com/jvgrootveld/telescope-zoxide [telescope.nvim]: https://github.com/nvim-telescope/telescope.nvim [termux]: https://github.com/termux/termux-packages/tree/master/packages/zoxide diff --git a/contrib/completions/_zoxide b/contrib/completions/_zoxide index 9a0df2a..abbec76 100644 --- a/contrib/completions/_zoxide +++ b/contrib/completions/_zoxide @@ -15,10 +15,10 @@ _zoxide() { local context curcontext="$curcontext" state line _arguments "${_arguments_options[@]}" \ -'-h[Print help information]' \ -'--help[Print help information]' \ -'-V[Print version information]' \ -'--version[Print version information]' \ +'-h[Print help]' \ +'--help[Print help]' \ +'-V[Print version]' \ +'--version[Print version]' \ ":: :_zoxide_commands" \ "*::: :->zoxide" \ && ret=0 @@ -30,19 +30,19 @@ _zoxide() { case $line[1] in (add) _arguments "${_arguments_options[@]}" \ -'-h[Print help information]' \ -'--help[Print help information]' \ -'-V[Print version information]' \ -'--version[Print version information]' \ +'-h[Print help]' \ +'--help[Print help]' \ +'-V[Print version]' \ +'--version[Print version]' \ '*::paths:_files -/' \ && ret=0 ;; (edit) _arguments "${_arguments_options[@]}" \ -'-h[Print help information]' \ -'--help[Print help information]' \ -'-V[Print version information]' \ -'--version[Print version information]' \ +'-h[Print help]' \ +'--help[Print help]' \ +'-V[Print version]' \ +'--version[Print version]' \ ":: :_zoxide__edit_commands" \ "*::: :->edit" \ && ret=0 @@ -55,37 +55,37 @@ _arguments "${_arguments_options[@]}" \ case $line[1] in (decrement) _arguments "${_arguments_options[@]}" \ -'-h[Print help information]' \ -'--help[Print help information]' \ -'-V[Print version information]' \ -'--version[Print version information]' \ +'-h[Print help]' \ +'--help[Print help]' \ +'-V[Print version]' \ +'--version[Print version]' \ ':path:' \ && ret=0 ;; (delete) _arguments "${_arguments_options[@]}" \ -'-h[Print help information]' \ -'--help[Print help information]' \ -'-V[Print version information]' \ -'--version[Print version information]' \ +'-h[Print help]' \ +'--help[Print help]' \ +'-V[Print version]' \ +'--version[Print version]' \ ':path:' \ && ret=0 ;; (increment) _arguments "${_arguments_options[@]}" \ -'-h[Print help information]' \ -'--help[Print help information]' \ -'-V[Print version information]' \ -'--version[Print version information]' \ +'-h[Print help]' \ +'--help[Print help]' \ +'-V[Print version]' \ +'--version[Print version]' \ ':path:' \ && ret=0 ;; (reload) _arguments "${_arguments_options[@]}" \ -'-h[Print help information]' \ -'--help[Print help information]' \ -'-V[Print version information]' \ -'--version[Print version information]' \ +'-h[Print help]' \ +'--help[Print help]' \ +'-V[Print version]' \ +'--version[Print version]' \ && ret=0 ;; esac @@ -96,22 +96,22 @@ esac _arguments "${_arguments_options[@]}" \ '--from=[Application to import from]:FROM:(autojump z)' \ '--merge[Merge into existing database]' \ -'-h[Print help information]' \ -'--help[Print help information]' \ -'-V[Print version information]' \ -'--version[Print version information]' \ +'-h[Print help]' \ +'--help[Print help]' \ +'-V[Print version]' \ +'--version[Print version]' \ ':path:_files' \ && ret=0 ;; (init) _arguments "${_arguments_options[@]}" \ -'--cmd=[Changes the prefix of the `z` and `zi` commands]:CMD: ' \ +'--cmd=[Changes the prefix of the \`z\` and \`zi\` commands]:CMD: ' \ '--hook=[Changes how often zoxide increments a directory'\''s score]:HOOK:(none prompt pwd)' \ -'--no-cmd[Prevents zoxide from defining the `z` and `zi` commands]' \ -'-h[Print help information]' \ -'--help[Print help information]' \ -'-V[Print version information]' \ -'--version[Print version information]' \ +'--no-cmd[Prevents zoxide from defining the \`z\` and \`zi\` commands]' \ +'-h[Print help]' \ +'--help[Print help]' \ +'-V[Print version]' \ +'--version[Print version]' \ ':shell:(bash elvish fish nushell posix powershell xonsh zsh)' \ && ret=0 ;; @@ -125,19 +125,19 @@ _arguments "${_arguments_options[@]}" \ '(-i --interactive)--list[List all matching directories]' \ '-s[Print score with results]' \ '--score[Print score with results]' \ -'-h[Print help information]' \ -'--help[Print help information]' \ -'-V[Print version information]' \ -'--version[Print version information]' \ +'-h[Print help]' \ +'--help[Print help]' \ +'-V[Print version]' \ +'--version[Print version]' \ '*::keywords:' \ && ret=0 ;; (remove) _arguments "${_arguments_options[@]}" \ -'-h[Print help information]' \ -'--help[Print help information]' \ -'-V[Print version information]' \ -'--version[Print version information]' \ +'-h[Print help]' \ +'--help[Print help]' \ +'-V[Print version]' \ +'--version[Print version]' \ '*::paths:_files -/' \ && ret=0 ;; @@ -214,4 +214,8 @@ _zoxide__remove_commands() { _describe -t commands 'zoxide remove commands' commands "$@" } -_zoxide "$@" +if [ "$funcstack[1]" = "_zoxide" ]; then + _zoxide "$@" +else + compdef _zoxide zoxide +fi diff --git a/contrib/completions/_zoxide.ps1 b/contrib/completions/_zoxide.ps1 index 2978e19..994ebc0 100644 --- a/contrib/completions/_zoxide.ps1 +++ b/contrib/completions/_zoxide.ps1 @@ -21,10 +21,10 @@ Register-ArgumentCompleter -Native -CommandName 'zoxide' -ScriptBlock { $completions = @(switch ($command) { 'zoxide' { - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') - [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information') + [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') [CompletionResult]::new('add', 'add', [CompletionResultType]::ParameterValue, 'Add a new directory or increment its rank') [CompletionResult]::new('edit', 'edit', [CompletionResultType]::ParameterValue, 'Edit the database') [CompletionResult]::new('import', 'import', [CompletionResultType]::ParameterValue, 'Import entries from another application') @@ -34,17 +34,17 @@ Register-ArgumentCompleter -Native -CommandName 'zoxide' -ScriptBlock { break } 'zoxide;add' { - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') - [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information') + [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') break } 'zoxide;edit' { - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') - [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information') + [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') [CompletionResult]::new('decrement', 'decrement', [CompletionResultType]::ParameterValue, 'decrement') [CompletionResult]::new('delete', 'delete', [CompletionResultType]::ParameterValue, 'delete') [CompletionResult]::new('increment', 'increment', [CompletionResultType]::ParameterValue, 'increment') @@ -52,50 +52,50 @@ Register-ArgumentCompleter -Native -CommandName 'zoxide' -ScriptBlock { break } 'zoxide;edit;decrement' { - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') - [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information') + [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') break } 'zoxide;edit;delete' { - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') - [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information') + [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') break } 'zoxide;edit;increment' { - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') - [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information') + [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') break } 'zoxide;edit;reload' { - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') - [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information') + [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') break } 'zoxide;import' { [CompletionResult]::new('--from', 'from', [CompletionResultType]::ParameterName, 'Application to import from') [CompletionResult]::new('--merge', 'merge', [CompletionResultType]::ParameterName, 'Merge into existing database') - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') - [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information') + [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') break } 'zoxide;init' { [CompletionResult]::new('--cmd', 'cmd', [CompletionResultType]::ParameterName, 'Changes the prefix of the `z` and `zi` commands') [CompletionResult]::new('--hook', 'hook', [CompletionResultType]::ParameterName, 'Changes how often zoxide increments a directory''s score') [CompletionResult]::new('--no-cmd', 'no-cmd', [CompletionResultType]::ParameterName, 'Prevents zoxide from defining the `z` and `zi` commands') - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') - [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information') + [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') break } 'zoxide;query' { @@ -107,17 +107,17 @@ Register-ArgumentCompleter -Native -CommandName 'zoxide' -ScriptBlock { [CompletionResult]::new('--list', 'list', [CompletionResultType]::ParameterName, 'List all matching directories') [CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 'Print score with results') [CompletionResult]::new('--score', 'score', [CompletionResultType]::ParameterName, 'Print score with results') - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') - [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information') + [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') break } 'zoxide;remove' { - [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information') - [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information') - [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information') + [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version') + [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version') break } }) diff --git a/contrib/completions/zoxide.bash b/contrib/completions/zoxide.bash index 6583641..04ccbd0 100644 --- a/contrib/completions/zoxide.bash +++ b/contrib/completions/zoxide.bash @@ -1,5 +1,5 @@ _zoxide() { - local i cur prev opts cmds + local i cur prev opts cmd COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" diff --git a/contrib/completions/zoxide.elv b/contrib/completions/zoxide.elv index abc01d7..dc79e0d 100644 --- a/contrib/completions/zoxide.elv +++ b/contrib/completions/zoxide.elv @@ -18,10 +18,10 @@ set edit:completion:arg-completer[zoxide] = {|@words| } var completions = [ &'zoxide'= { - cand -h 'Print help information' - cand --help 'Print help information' - cand -V 'Print version information' - cand --version 'Print version information' + cand -h 'Print help' + cand --help 'Print help' + cand -V 'Print version' + cand --version 'Print version' cand add 'Add a new directory or increment its rank' cand edit 'Edit the database' cand import 'Import entries from another application' @@ -30,61 +30,61 @@ set edit:completion:arg-completer[zoxide] = {|@words| cand remove 'Remove a directory from the database' } &'zoxide;add'= { - cand -h 'Print help information' - cand --help 'Print help information' - cand -V 'Print version information' - cand --version 'Print version information' + cand -h 'Print help' + cand --help 'Print help' + cand -V 'Print version' + cand --version 'Print version' } &'zoxide;edit'= { - cand -h 'Print help information' - cand --help 'Print help information' - cand -V 'Print version information' - cand --version 'Print version information' + cand -h 'Print help' + cand --help 'Print help' + cand -V 'Print version' + cand --version 'Print version' cand decrement 'decrement' cand delete 'delete' cand increment 'increment' cand reload 'reload' } &'zoxide;edit;decrement'= { - cand -h 'Print help information' - cand --help 'Print help information' - cand -V 'Print version information' - cand --version 'Print version information' + cand -h 'Print help' + cand --help 'Print help' + cand -V 'Print version' + cand --version 'Print version' } &'zoxide;edit;delete'= { - cand -h 'Print help information' - cand --help 'Print help information' - cand -V 'Print version information' - cand --version 'Print version information' + cand -h 'Print help' + cand --help 'Print help' + cand -V 'Print version' + cand --version 'Print version' } &'zoxide;edit;increment'= { - cand -h 'Print help information' - cand --help 'Print help information' - cand -V 'Print version information' - cand --version 'Print version information' + cand -h 'Print help' + cand --help 'Print help' + cand -V 'Print version' + cand --version 'Print version' } &'zoxide;edit;reload'= { - cand -h 'Print help information' - cand --help 'Print help information' - cand -V 'Print version information' - cand --version 'Print version information' + cand -h 'Print help' + cand --help 'Print help' + cand -V 'Print version' + cand --version 'Print version' } &'zoxide;import'= { cand --from 'Application to import from' cand --merge 'Merge into existing database' - cand -h 'Print help information' - cand --help 'Print help information' - cand -V 'Print version information' - cand --version 'Print version information' + cand -h 'Print help' + cand --help 'Print help' + cand -V 'Print version' + cand --version 'Print version' } &'zoxide;init'= { cand --cmd 'Changes the prefix of the `z` and `zi` commands' cand --hook 'Changes how often zoxide increments a directory''s score' cand --no-cmd 'Prevents zoxide from defining the `z` and `zi` commands' - cand -h 'Print help information' - cand --help 'Print help information' - cand -V 'Print version information' - cand --version 'Print version information' + cand -h 'Print help' + cand --help 'Print help' + cand -V 'Print version' + cand --version 'Print version' } &'zoxide;query'= { cand --exclude 'Exclude the current directory' @@ -95,16 +95,16 @@ set edit:completion:arg-completer[zoxide] = {|@words| cand --list 'List all matching directories' cand -s 'Print score with results' cand --score 'Print score with results' - cand -h 'Print help information' - cand --help 'Print help information' - cand -V 'Print version information' - cand --version 'Print version information' + cand -h 'Print help' + cand --help 'Print help' + cand -V 'Print version' + cand --version 'Print version' } &'zoxide;remove'= { - cand -h 'Print help information' - cand --help 'Print help information' - cand -V 'Print version information' - cand --version 'Print version information' + cand -h 'Print help' + cand --help 'Print help' + cand -V 'Print version' + cand --version 'Print version' } ] $completions[$command] diff --git a/contrib/completions/zoxide.fish b/contrib/completions/zoxide.fish index 1dbe1c3..c6a5b20 100644 --- a/contrib/completions/zoxide.fish +++ b/contrib/completions/zoxide.fish @@ -1,42 +1,42 @@ -complete -c zoxide -n "__fish_use_subcommand" -s h -l help -d 'Print help information' -complete -c zoxide -n "__fish_use_subcommand" -s V -l version -d 'Print version information' +complete -c zoxide -n "__fish_use_subcommand" -s h -l help -d 'Print help' +complete -c zoxide -n "__fish_use_subcommand" -s V -l version -d 'Print version' complete -c zoxide -n "__fish_use_subcommand" -f -a "add" -d 'Add a new directory or increment its rank' complete -c zoxide -n "__fish_use_subcommand" -f -a "edit" -d 'Edit the database' complete -c zoxide -n "__fish_use_subcommand" -f -a "import" -d 'Import entries from another application' complete -c zoxide -n "__fish_use_subcommand" -f -a "init" -d 'Generate shell configuration' complete -c zoxide -n "__fish_use_subcommand" -f -a "query" -d 'Search for a directory in the database' complete -c zoxide -n "__fish_use_subcommand" -f -a "remove" -d 'Remove a directory from the database' -complete -c zoxide -n "__fish_seen_subcommand_from add" -s h -l help -d 'Print help information' -complete -c zoxide -n "__fish_seen_subcommand_from add" -s V -l version -d 'Print version information' -complete -c zoxide -n "__fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from decrement; and not __fish_seen_subcommand_from delete; and not __fish_seen_subcommand_from increment; and not __fish_seen_subcommand_from reload" -s h -l help -d 'Print help information' -complete -c zoxide -n "__fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from decrement; and not __fish_seen_subcommand_from delete; and not __fish_seen_subcommand_from increment; and not __fish_seen_subcommand_from reload" -s V -l version -d 'Print version information' +complete -c zoxide -n "__fish_seen_subcommand_from add" -s h -l help -d 'Print help' +complete -c zoxide -n "__fish_seen_subcommand_from add" -s V -l version -d 'Print version' +complete -c zoxide -n "__fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from decrement; and not __fish_seen_subcommand_from delete; and not __fish_seen_subcommand_from increment; and not __fish_seen_subcommand_from reload" -s h -l help -d 'Print help' +complete -c zoxide -n "__fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from decrement; and not __fish_seen_subcommand_from delete; and not __fish_seen_subcommand_from increment; and not __fish_seen_subcommand_from reload" -s V -l version -d 'Print version' complete -c zoxide -n "__fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from decrement; and not __fish_seen_subcommand_from delete; and not __fish_seen_subcommand_from increment; and not __fish_seen_subcommand_from reload" -f -a "decrement" complete -c zoxide -n "__fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from decrement; and not __fish_seen_subcommand_from delete; and not __fish_seen_subcommand_from increment; and not __fish_seen_subcommand_from reload" -f -a "delete" complete -c zoxide -n "__fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from decrement; and not __fish_seen_subcommand_from delete; and not __fish_seen_subcommand_from increment; and not __fish_seen_subcommand_from reload" -f -a "increment" complete -c zoxide -n "__fish_seen_subcommand_from edit; and not __fish_seen_subcommand_from decrement; and not __fish_seen_subcommand_from delete; and not __fish_seen_subcommand_from increment; and not __fish_seen_subcommand_from reload" -f -a "reload" -complete -c zoxide -n "__fish_seen_subcommand_from edit; and __fish_seen_subcommand_from decrement" -s h -l help -d 'Print help information' -complete -c zoxide -n "__fish_seen_subcommand_from edit; and __fish_seen_subcommand_from decrement" -s V -l version -d 'Print version information' -complete -c zoxide -n "__fish_seen_subcommand_from edit; and __fish_seen_subcommand_from delete" -s h -l help -d 'Print help information' -complete -c zoxide -n "__fish_seen_subcommand_from edit; and __fish_seen_subcommand_from delete" -s V -l version -d 'Print version information' -complete -c zoxide -n "__fish_seen_subcommand_from edit; and __fish_seen_subcommand_from increment" -s h -l help -d 'Print help information' -complete -c zoxide -n "__fish_seen_subcommand_from edit; and __fish_seen_subcommand_from increment" -s V -l version -d 'Print version information' -complete -c zoxide -n "__fish_seen_subcommand_from edit; and __fish_seen_subcommand_from reload" -s h -l help -d 'Print help information' -complete -c zoxide -n "__fish_seen_subcommand_from edit; and __fish_seen_subcommand_from reload" -s V -l version -d 'Print version information' +complete -c zoxide -n "__fish_seen_subcommand_from edit; and __fish_seen_subcommand_from decrement" -s h -l help -d 'Print help' +complete -c zoxide -n "__fish_seen_subcommand_from edit; and __fish_seen_subcommand_from decrement" -s V -l version -d 'Print version' +complete -c zoxide -n "__fish_seen_subcommand_from edit; and __fish_seen_subcommand_from delete" -s h -l help -d 'Print help' +complete -c zoxide -n "__fish_seen_subcommand_from edit; and __fish_seen_subcommand_from delete" -s V -l version -d 'Print version' +complete -c zoxide -n "__fish_seen_subcommand_from edit; and __fish_seen_subcommand_from increment" -s h -l help -d 'Print help' +complete -c zoxide -n "__fish_seen_subcommand_from edit; and __fish_seen_subcommand_from increment" -s V -l version -d 'Print version' +complete -c zoxide -n "__fish_seen_subcommand_from edit; and __fish_seen_subcommand_from reload" -s h -l help -d 'Print help' +complete -c zoxide -n "__fish_seen_subcommand_from edit; and __fish_seen_subcommand_from reload" -s V -l version -d 'Print version' complete -c zoxide -n "__fish_seen_subcommand_from import" -l from -d 'Application to import from' -r -f -a "{autojump ,z }" complete -c zoxide -n "__fish_seen_subcommand_from import" -l merge -d 'Merge into existing database' -complete -c zoxide -n "__fish_seen_subcommand_from import" -s h -l help -d 'Print help information' -complete -c zoxide -n "__fish_seen_subcommand_from import" -s V -l version -d 'Print version information' +complete -c zoxide -n "__fish_seen_subcommand_from import" -s h -l help -d 'Print help' +complete -c zoxide -n "__fish_seen_subcommand_from import" -s V -l version -d 'Print version' complete -c zoxide -n "__fish_seen_subcommand_from init" -l cmd -d 'Changes the prefix of the `z` and `zi` commands' -r complete -c zoxide -n "__fish_seen_subcommand_from init" -l hook -d 'Changes how often zoxide increments a directory\'s score' -r -f -a "{none ,prompt ,pwd }" complete -c zoxide -n "__fish_seen_subcommand_from init" -l no-cmd -d 'Prevents zoxide from defining the `z` and `zi` commands' -complete -c zoxide -n "__fish_seen_subcommand_from init" -s h -l help -d 'Print help information' -complete -c zoxide -n "__fish_seen_subcommand_from init" -s V -l version -d 'Print version information' +complete -c zoxide -n "__fish_seen_subcommand_from init" -s h -l help -d 'Print help' +complete -c zoxide -n "__fish_seen_subcommand_from init" -s V -l version -d 'Print version' complete -c zoxide -n "__fish_seen_subcommand_from query" -l exclude -d 'Exclude the current directory' -r -f -a "(__fish_complete_directories)" complete -c zoxide -n "__fish_seen_subcommand_from query" -l all -d 'Show deleted directories' complete -c zoxide -n "__fish_seen_subcommand_from query" -s i -l interactive -d 'Use interactive selection' complete -c zoxide -n "__fish_seen_subcommand_from query" -s l -l list -d 'List all matching directories' complete -c zoxide -n "__fish_seen_subcommand_from query" -s s -l score -d 'Print score with results' -complete -c zoxide -n "__fish_seen_subcommand_from query" -s h -l help -d 'Print help information' -complete -c zoxide -n "__fish_seen_subcommand_from query" -s V -l version -d 'Print version information' -complete -c zoxide -n "__fish_seen_subcommand_from remove" -s h -l help -d 'Print help information' -complete -c zoxide -n "__fish_seen_subcommand_from remove" -s V -l version -d 'Print version information' +complete -c zoxide -n "__fish_seen_subcommand_from query" -s h -l help -d 'Print help' +complete -c zoxide -n "__fish_seen_subcommand_from query" -s V -l version -d 'Print version' +complete -c zoxide -n "__fish_seen_subcommand_from remove" -s h -l help -d 'Print help' +complete -c zoxide -n "__fish_seen_subcommand_from remove" -s V -l version -d 'Print version' diff --git a/contrib/completions/zoxide.ts b/contrib/completions/zoxide.ts index 5f1d16f..4bfb0c2 100644 --- a/contrib/completions/zoxide.ts +++ b/contrib/completions/zoxide.ts @@ -8,11 +8,11 @@ const completion: Fig.Spec = { options: [ { name: ["-h", "--help"], - description: "Print help information", + description: "Print help", }, { name: ["-V", "--version"], - description: "Print version information", + description: "Print version", }, ], args: { @@ -31,11 +31,11 @@ const completion: Fig.Spec = { options: [ { name: ["-h", "--help"], - description: "Print help information", + description: "Print help", }, { name: ["-V", "--version"], - description: "Print version information", + description: "Print version", }, ], args: { @@ -48,11 +48,11 @@ const completion: Fig.Spec = { options: [ { name: ["-h", "--help"], - description: "Print help information", + description: "Print help", }, { name: ["-V", "--version"], - description: "Print version information", + description: "Print version", }, ], args: { @@ -65,11 +65,11 @@ const completion: Fig.Spec = { options: [ { name: ["-h", "--help"], - description: "Print help information", + description: "Print help", }, { name: ["-V", "--version"], - description: "Print version information", + description: "Print version", }, ], args: { @@ -82,11 +82,11 @@ const completion: Fig.Spec = { options: [ { name: ["-h", "--help"], - description: "Print help information", + description: "Print help", }, { name: ["-V", "--version"], - description: "Print version information", + description: "Print version", }, ], }, @@ -94,11 +94,11 @@ const completion: Fig.Spec = { options: [ { name: ["-h", "--help"], - description: "Print help information", + description: "Print help", }, { name: ["-V", "--version"], - description: "Print version information", + description: "Print version", }, ], }, @@ -124,11 +124,11 @@ const completion: Fig.Spec = { }, { name: ["-h", "--help"], - description: "Print help information", + description: "Print help", }, { name: ["-V", "--version"], - description: "Print version information", + description: "Print version", }, ], args: { @@ -169,11 +169,11 @@ const completion: Fig.Spec = { }, { name: ["-h", "--help"], - description: "Print help information", + description: "Print help", }, { name: ["-V", "--version"], - description: "Print version information", + description: "Print version", }, ], args: { @@ -230,11 +230,11 @@ const completion: Fig.Spec = { }, { name: ["-h", "--help"], - description: "Print help information", + description: "Print help", }, { name: ["-V", "--version"], - description: "Print version information", + description: "Print version", }, ], args: { @@ -249,11 +249,11 @@ const completion: Fig.Spec = { options: [ { name: ["-h", "--help"], - description: "Print help information", + description: "Print help", }, { name: ["-V", "--version"], - description: "Print version information", + description: "Print version", }, ], args: { @@ -267,11 +267,11 @@ const completion: Fig.Spec = { options: [ { name: ["-h", "--help"], - description: "Print help information", + description: "Print help", }, { name: ["-V", "--version"], - description: "Print version information", + description: "Print version", }, ], }; diff --git a/install.sh b/install.sh index 9f0784c..796c4d9 100755 --- a/install.sh +++ b/install.sh @@ -7,7 +7,7 @@ # extension. Note: Most shells limit `local` to 1 var per line, contra bash. main() { - if [ "$KSH_VERSION" = 'Version JM 93t+ 2010-03-05' ]; then + if [ "${KSH_VERSION-}" = 'Version JM 93t+ 2010-03-05' ]; then # The version of ksh93 that ships with many illumos systems does not # support the "local" extension. Print a message rather than fail in # subtle ways later on: @@ -18,56 +18,57 @@ main() { # Detect and print host target triple. ensure get_architecture - local _arch="$RETVAL" - assert_nz "$_arch" "arch" - echo "Detected architecture: $_arch" + local _arch="${RETVAL}" + assert_nz "${_arch}" "arch" + echo "Detected architecture: ${_arch}" # Create and enter a temporary directory. local _tmp_dir _tmp_dir="$(mktemp -d)" || err "mktemp: could not create temporary directory" - cd "$_tmp_dir" || err "cd: failed to enter directory: $_tmp_dir" + cd "${_tmp_dir}" || err "cd: failed to enter directory: ${_tmp_dir}" # Download and extract zoxide. - ensure download_zoxide "$_arch" - local _package="$RETVAL" - assert_nz "$_package" "package" - echo "Downloaded package: $_package" - case "$_package" in + ensure download_zoxide "${_arch}" + local _package="${RETVAL}" + assert_nz "${_package}" "package" + echo "Downloaded package: ${_package}" + case "${_package}" in *.tar.gz) need_cmd tar - ensure tar -xf "$_package" + ensure tar -xf "${_package}" ;; *.zip) need_cmd unzip - ensure unzip -oq "$_package" + ensure unzip -oq "${_package}" ;; *) - err "unsupported package format: $_package" + err "unsupported package format: ${_package}" ;; esac # Install binary. - local _bin_dir="$HOME/.local/bin" + local _bin_dir="${HOME}/.local/bin" local _bin_name - case "$_arch" in + case "${_arch}" in *windows*) _bin_name="zoxide.exe" ;; *) _bin_name="zoxide" ;; esac - ensure mkdir -p "$_bin_dir" - ensure cp "$_bin_name" "$_bin_dir" - echo "Installed zoxide to $_bin_dir" + ensure mkdir -p "${_bin_dir}" + ensure cp "${_bin_name}" "${_bin_dir}" + ensure chmod +x "${_bin_dir}/${_bin_name}" + echo "Installed zoxide to ${_bin_dir}" # Install manpages. - local _man_dir="$HOME/.local/share/man" - ensure mkdir -p "$_man_dir/man1" - ensure cp "man/man1/"* "$_man_dir/man1/" - echo "Installed manpages to $_man_dir" + local _man_dir="${HOME}/.local/share/man" + ensure mkdir -p "${_man_dir}/man1" + ensure cp "man/man1/"* "${_man_dir}/man1/" + echo "Installed manpages to ${_man_dir}" # Print success message and check $PATH. echo "" echo "zoxide is installed!" - if ! echo ":$PATH:" | grep -Fq ":$_bin_dir:"; then - echo "NOTE: $_bin_dir is not on your \$PATH. zoxide will not work unless it is added to \$PATH." + if ! echo ":${PATH}:" | grep -Fq ":${_bin_dir}:"; then + echo "NOTE: ${_bin_dir} is not on your \$PATH. zoxide will not work unless it is added to \$PATH." fi } @@ -85,33 +86,35 @@ download_zoxide() { local _releases_url="https://api.github.com/repos/ajeetdsouza/zoxide/releases/latest" local _releases - case "$_dld" in - curl) _releases="$(curl -sL "$_releases_url")" || - err "curl: failed to download $_releases_url" ;; - wget) _releases="$(wget -qO- "$_releases_url")" || - err "wget: failed to download $_releases_url" ;; + case "${_dld}" in + curl) _releases="$(curl -sL "${_releases_url}")" || + err "curl: failed to download ${_releases_url}" ;; + wget) _releases="$(wget -qO- "${_releases_url}")" || + err "wget: failed to download ${_releases_url}" ;; + *) err "unsupported downloader: ${_dld}" ;; esac - (echo "$_releases" | grep -q 'API rate limit exceeded') && + (echo "${_releases}" | grep -q 'API rate limit exceeded') && err "you have exceeded GitHub's API rate limit. Please try again later, or use a different installation method: https://github.com/ajeetdsouza/zoxide/#installation" local _package_url - _package_url="$(echo "$_releases" | grep "browser_download_url" | cut -d '"' -f 4 | grep "$_arch")" || - err "zoxide has not yet been packaged for your architecture ($_arch), please file an issue: https://github.com/ajeetdsouza/zoxide/issues" + _package_url="$(echo "${_releases}" | grep "browser_download_url" | cut -d '"' -f 4 | grep "${_arch}")" || + err "zoxide has not yet been packaged for your architecture (${_arch}), please file an issue: https://github.com/ajeetdsouza/zoxide/issues" local _ext - case "$_package_url" in + case "${_package_url}" in *.tar.gz) _ext="tar.gz" ;; *.zip) _ext="zip" ;; - *) err "unsupported package format: $_package_url" ;; + *) err "unsupported package format: ${_package_url}" ;; esac - local _package="zoxide.$_ext" - case "$_dld" in - curl) _releases="$(curl -sLo "$_package" "$_package_url")" || err "curl: failed to download $_package_url" ;; - wget) _releases="$(wget -qO "$_package" "$_package_url")" || err "wget: failed to download $_package_url" ;; + local _package="zoxide.${_ext}" + case "${_dld}" in + curl) _releases="$(curl -sLo "${_package}" "${_package_url}")" || err "curl: failed to download ${_package_url}" ;; + wget) _releases="$(wget -qO "${_package}" "${_package_url}")" || err "wget: failed to download ${_package_url}" ;; + *) err "unsupported downloader: ${_dld}" ;; esac - RETVAL="$_package" + RETVAL="${_package}" } # The below functions have been extracted with minor modifications from the @@ -125,25 +128,25 @@ get_architecture() { _cputype="$(uname -m)" _clibtype="musl" - if [ "$_ostype" = Linux ]; then - if [ "$(uname -o)" = Android ]; then + if [ "${_ostype}" = Linux ]; then + if [ "$(uname -o || true)" = Android ]; then _ostype=Android fi fi - if [ "$_ostype" = Darwin ] && [ "$_cputype" = i386 ]; then + if [ "${_ostype}" = Darwin ] && [ "${_cputype}" = i386 ]; then # Darwin `uname -m` lies if sysctl hw.optional.x86_64 | grep -q ': 1'; then _cputype=x86_64 fi fi - if [ "$_ostype" = SunOS ]; then + if [ "${_ostype}" = SunOS ]; then # Both Solaris and illumos presently announce as "SunOS" in "uname -s" # so use "uname -o" to disambiguate. We use the full path to the # system uname in case the user has coreutils uname first in PATH, # which has historically sometimes printed the wrong value here. - if [ "$(/usr/bin/uname -o)" = illumos ]; then + if [ "$(/usr/bin/uname -o || true)" = illumos ]; then _ostype=illumos fi @@ -151,18 +154,18 @@ get_architecture() { # machine hardware name; e.g., "i86pc" on both 32- and 64-bit x86 # systems. Check for the native (widest) instruction set on the # running kernel: - if [ "$_cputype" = i86pc ]; then + if [ "${_cputype}" = i86pc ]; then _cputype="$(isainfo -n)" fi fi - case "$_ostype" in + case "${_ostype}" in Android) _ostype=linux-android ;; Linux) check_proc - _ostype=unknown-linux-$_clibtype + _ostype=unknown-linux-${_clibtype} _bitness=$(get_bitness) ;; FreeBSD) @@ -184,23 +187,23 @@ get_architecture() { _ostype=pc-windows-msvc ;; *) - err "unrecognized OS type: $_ostype" + err "unrecognized OS type: ${_ostype}" ;; esac - case "$_cputype" in + case "${_cputype}" in i386 | i486 | i686 | i786 | x86) _cputype=i686 ;; xscale | arm) _cputype=arm - if [ "$_ostype" = "linux-android" ]; then + if [ "${_ostype}" = "linux-android" ]; then _ostype=linux-androideabi fi ;; armv6l) _cputype=arm - if [ "$_ostype" = "linux-android" ]; then + if [ "${_ostype}" = "linux-android" ]; then _ostype=linux-androideabi else _ostype="${_ostype}eabihf" @@ -208,7 +211,7 @@ get_architecture() { ;; armv7l | armv8l) _cputype=armv7 - if [ "$_ostype" = "linux-android" ]; then + if [ "${_ostype}" = "linux-android" ]; then _ostype=linux-androideabi else _ostype="${_ostype}eabihf" @@ -224,7 +227,7 @@ get_architecture() { _cputype=$(get_endianness mips '' el) ;; mips64) - if [ "$_bitness" -eq 64 ]; then + if [ "${_bitness}" -eq 64 ]; then # only n64 ABI is supported for now _ostype="${_ostype}abi64" _cputype=$(get_endianness mips64 '' el) @@ -246,13 +249,13 @@ get_architecture() { _cputype=riscv64gc ;; *) - err "unknown CPU type: $_cputype" + err "unknown CPU type: ${_cputype}" ;; esac # Detect 64-bit linux with 32-bit userland if [ "${_ostype}" = unknown-linux-musl ] && [ "${_bitness}" -eq 32 ]; then - case $_cputype in + case ${_cputype} in x86_64) # 32-bit executable for amd64 = x32 if is_host_amd64_elf; then { @@ -270,7 +273,7 @@ get_architecture() { ;; aarch64) _cputype=armv7 - if [ "$_ostype" = "linux-android" ]; then + if [ "${_ostype}" = "linux-android" ]; then _ostype=linux-androideabi else _ostype="${_ostype}eabihf" @@ -279,13 +282,14 @@ get_architecture() { riscv64gc) err "riscv64 with 32-bit userland unsupported" ;; + *) ;; esac fi # Detect armv7 but without the CPU features Rust needs in that build, # and fall back to arm. # See https://github.com/rust-lang/rustup.rs/issues/587. - if [ "$_ostype" = "unknown-linux-musleabihf" ] && [ "$_cputype" = armv7 ]; then + if [ "${_ostype}" = "unknown-linux-musleabihf" ] && [ "${_cputype}" = armv7 ]; then if ensure grep '^Features' /proc/cpuinfo | grep -q -v neon; then # At least one processor does not have NEON. _cputype=arm @@ -293,7 +297,7 @@ get_architecture() { fi _arch="${_cputype}-${_ostype}" - RETVAL="$_arch" + RETVAL="${_arch}" } get_bitness() { @@ -306,9 +310,9 @@ get_bitness() { # escape sequences, so we use those. local _current_exe_head _current_exe_head=$(head -c 5 /proc/self/exe) - if [ "$_current_exe_head" = "$(printf '\177ELF\001')" ]; then + if [ "${_current_exe_head}" = "$(printf '\177ELF\001')" ]; then echo 32 - elif [ "$_current_exe_head" = "$(printf '\177ELF\002')" ]; then + elif [ "${_current_exe_head}" = "$(printf '\177ELF\002')" ]; then echo 64 else err "unknown platform bitness" @@ -326,9 +330,9 @@ get_endianness() { local _current_exe_endianness _current_exe_endianness="$(head -c 6 /proc/self/exe | tail -c 1)" - if [ "$_current_exe_endianness" = "$(printf '\001')" ]; then + if [ "${_current_exe_endianness}" = "$(printf '\001')" ]; then echo "${cputype}${suffix_el}" - elif [ "$_current_exe_endianness" = "$(printf '\002')" ]; then + elif [ "${_current_exe_endianness}" = "$(printf '\002')" ]; then echo "${cputype}${suffix_eb}" else err "unknown platform endianness" @@ -343,7 +347,7 @@ is_host_amd64_elf() { # but we're interested in it being 0x3E to indicate amd64, or not that. local _current_exe_machine _current_exe_machine=$(head -c 19 /proc/self/exe | tail -c 1) - [ "$_current_exe_machine" = "$(printf '\076')" ] + [ "${_current_exe_machine}" = "$(printf '\076')" ] } check_proc() { diff --git a/justfile b/justfile new file mode 100644 index 0000000..18309da --- /dev/null +++ b/justfile @@ -0,0 +1,39 @@ +default: + @just --list + +[unix] +fmt: + nix-shell --cores 0 --pure --run 'cargo-fmt --all' + nix-shell --cores 0 --pure --run 'nixfmt -- *.nix' + nix-shell --cores 0 --pure --run 'shfmt --indent=4 --language-dialect=posix --simplify --write *.sh' + nix-shell --cores 0 --pure --run 'yamlfmt -- .github/workflows/*.yml' + +[windows] +fmt: + cargo +nightly fmt --all + +[unix] +lint: + nix-shell --cores 0 --pure --run 'cargo-fmt --all --check' + nix-shell --cores 0 --pure --run 'cargo clippy --all-features --all-targets -- -Dwarnings' + nix-shell --cores 0 --pure --run 'cargo msrv verify' + nix-shell --cores 0 --pure --run 'cargo udeps --all-features --all-targets --workspace' + nix-shell --cores 0 --pure --run 'mandoc -man -Wall -Tlint -- man/man1/*.1' + nix-shell --cores 0 --pure --run 'markdownlint *.md' + nix-shell --cores 0 --pure --run 'nixfmt --check -- *.nix' + # nix-shell --cores 0 --pure --run 'shellcheck --enable all *.sh' + nix-shell --cores 0 --pure --run 'shfmt --diff --indent=4 --language-dialect=posix --simplify *.sh' + nix-shell --cores 0 --pure --run 'yamlfmt -lint -- .github/workflows/*.yml' + +[windows] +lint: + cargo +nightly fmt --all --check + cargo +stable clippy --all-features --all-targets -- -Dwarnings + +[unix] +test *args: + nix-shell --cores 0 --pure --run 'cargo nextest run --all-features --no-fail-fast --workspace {{args}}' + +[windows] +test *args: + cargo +stable test --no-fail-fast --workspace {{args}} diff --git a/man/man1/zoxide-init.1 b/man/man1/zoxide-init.1 index e3331fb..0a44b51 100644 --- a/man/man1/zoxide-init.1 +++ b/man/man1/zoxide-init.1 @@ -28,8 +28,6 @@ Add this to your configuration (usually \fB~/.config/fish/config.fish\fR): .nf \fBzoxide init fish | source\fR .fi -.sp -Note: zoxide only supports fish v3.4.0 and above. .TP .B nushell Add this to your env file (find it by running \fB$nu.env-path\fR in Nushell): @@ -52,10 +50,7 @@ Add this to your configuration (find it by running \fBecho $profile\fR in PowerShell): .sp .nf - \fBInvoke-Expression (& { - $hook = if ($PSVersionTable.PSVersion.Major -lt 6) { 'prompt' } else { 'pwd' } - (zoxide init --hook $hook powershell | Out-String) - })\fR + \fBInvoke-Expression (& { (zoxide init powershell | Out-String) })\fR .fi .TP .B xonsh diff --git a/shell.nix b/shell.nix index ccbd3af..2059f4f 100644 --- a/shell.nix +++ b/shell.nix @@ -1,13 +1,22 @@ let - rust = import (builtins.fetchTarball - "https://github.com/oxalica/rust-overlay/archive/9096306d4a1c3adcc8d20f2c9dcaee3dee30d1ad.tar.gz"); pkgs = import (builtins.fetchTarball - "https://github.com/NixOS/nixpkgs/archive/5f902ae769594aaeaf326e8623a48482eeacfe89.tar.gz") { + "https://github.com/NixOS/nixpkgs/archive/22a6958f46fd8e14830d02856ff63b1d0e5cc3e4.tar.gz") { overlays = [ rust ]; }; + rust = import (builtins.fetchTarball + "https://github.com/oxalica/rust-overlay/archive/a61fcd9910229d097ffef92b5a2440065e3b64d5.tar.gz"); + + rust-nightly = + pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.minimal); + cargo-udeps = pkgs.writeShellScriptBin "cargo-udeps" '' + export RUSTC="${rust-nightly}/bin/rustc"; + export CARGO="${rust-nightly}/bin/cargo"; + exec "${pkgs.cargo-udeps}/bin/cargo-udeps" "$@" + ''; in pkgs.mkShell { buildInputs = [ # Rust + (pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.rustfmt)) pkgs.rust-bin.stable.latest.default # Shells @@ -21,8 +30,11 @@ in pkgs.mkShell { pkgs.zsh # Tools + cargo-udeps pkgs.cargo-msrv pkgs.cargo-nextest + pkgs.cargo-udeps + pkgs.just pkgs.mandoc pkgs.nixfmt pkgs.nodePackages.markdownlint-cli @@ -31,6 +43,7 @@ in pkgs.mkShell { pkgs.python3Packages.pylint pkgs.shellcheck pkgs.shfmt + pkgs.yamlfmt # Dependencies pkgs.cacert @@ -39,6 +52,5 @@ in pkgs.mkShell { pkgs.libiconv ]; - CARGO_INCREMENTAL = builtins.getEnv "CI" != ""; CARGO_TARGET_DIR = "target_nix"; } diff --git a/src/cmd/cmd.rs b/src/cmd/cmd.rs index 2ae88de..9a572b4 100644 --- a/src/cmd/cmd.rs +++ b/src/cmd/cmd.rs @@ -4,20 +4,28 @@ use std::path::PathBuf; use clap::{Parser, Subcommand, ValueEnum, ValueHint}; -const ENV_HELP: &str = "Environment variables: - _ZO_DATA_DIR Path for zoxide data files - _ZO_ECHO Print the matched directory before navigating to it when set to 1 - _ZO_EXCLUDE_DIRS List of directory globs to be excluded - _ZO_FZF_OPTS Custom flags to pass to fzf - _ZO_MAXAGE Maximum total age after which entries start getting deleted - _ZO_RESOLVE_SYMLINKS Resolve symlinks when storing paths"; +const HELP_TEMPLATE: &str = color_print::cstr!( + "\ +{before-help}{name} {version} +{author-with-newline}{about-with-newline} +{usage-heading} {usage} + +{all-args}{after-help} + +Environment variables: + _ZO_DATA_DIR Path for zoxide data files + _ZO_ECHO Print the matched directory before navigating to it when set to 1 + _ZO_EXCLUDE_DIRS List of directory globs to be excluded + _ZO_FZF_OPTS Custom flags to pass to fzf + _ZO_MAXAGE Maximum total age after which entries start getting deleted + _ZO_RESOLVE_SYMLINKS Resolve symlinks when storing paths" +); #[derive(Debug, Parser)] #[clap( - bin_name = env!("CARGO_PKG_NAME"), about, author, - after_help = ENV_HELP, + help_template = HELP_TEMPLATE, disable_help_subcommand = true, propagate_version = true, version = option_env!("ZOXIDE_VERSION").unwrap_or_default() @@ -33,6 +41,10 @@ pub enum Cmd { /// Add a new directory or increment its rank #[derive(Debug, Parser)] +#[clap( + author, + help_template = HELP_TEMPLATE, +)] pub struct Add { #[clap(num_args = 1.., required = true, value_hint = ValueHint::DirPath)] pub paths: Vec, @@ -40,6 +52,10 @@ pub struct Add { /// Edit the database #[derive(Debug, Parser)] +#[clap( + author, + help_template = HELP_TEMPLATE, +)] pub struct Edit { #[clap(subcommand)] pub cmd: Option, @@ -59,6 +75,10 @@ pub enum EditCommand { /// Import entries from another application #[derive(Debug, Parser)] +#[clap( + author, + help_template = HELP_TEMPLATE, +)] pub struct Import { #[clap(value_hint = ValueHint::FilePath)] pub path: PathBuf, @@ -75,11 +95,16 @@ pub struct Import { #[derive(ValueEnum, Clone, Debug)] pub enum ImportFrom { Autojump, + #[clap(alias = "fasd")] Z, } /// Generate shell configuration #[derive(Debug, Parser)] +#[clap( + author, + help_template = HELP_TEMPLATE, +)] pub struct Init { #[clap(value_enum)] pub shell: InitShell, @@ -118,6 +143,10 @@ pub enum InitShell { /// Search for a directory in the database #[derive(Debug, Parser)] +#[clap( + author, + help_template = HELP_TEMPLATE, +)] pub struct Query { pub keywords: Vec, @@ -144,6 +173,10 @@ pub struct Query { /// Remove a directory from the database #[derive(Debug, Parser)] +#[clap( + author, + help_template = HELP_TEMPLATE, +)] pub struct Remove { #[clap(value_hint = ValueHint::DirPath)] pub paths: Vec, diff --git a/src/cmd/import.rs b/src/cmd/import.rs index ae667d4..182a25f 100644 --- a/src/cmd/import.rs +++ b/src/cmd/import.rs @@ -31,17 +31,15 @@ fn import_autojump(db: &mut Database, buffer: &str) -> Result<()> { if line.is_empty() { continue; } - let mut split = line.splitn(2, '\t'); + let (rank, path) = + line.split_once('\t').with_context(|| format!("invalid entry: {line}"))?; - let rank = split.next().with_context(|| format!("invalid entry: {line}"))?; let mut rank = rank.parse::().with_context(|| format!("invalid rank: {rank}"))?; // Normalize the rank using a sigmoid function. Don't import actual ranks from // autojump, since its scoring algorithm is very different and might // take a while to get normalized. rank = sigmoid(rank); - let path = split.next().with_context(|| format!("invalid entry: {line}"))?; - db.add_unchecked(path, rank, 0); } diff --git a/src/cmd/init.rs b/src/cmd/init.rs index 2c7609d..60bad63 100644 --- a/src/cmd/init.rs +++ b/src/cmd/init.rs @@ -6,7 +6,7 @@ use askama::Template; use crate::cmd::{Init, InitShell, Run}; use crate::config; use crate::error::BrokenPipeHandler; -use crate::shell::{self, Opts}; +use crate::shell::{Bash, Elvish, Fish, Nushell, Opts, Posix, Powershell, Xonsh, Zsh}; impl Run for Init { fn run(&self) -> Result<()> { @@ -16,14 +16,14 @@ impl Run for Init { let opts = &Opts { cmd, hook: self.hook, echo, resolve_symlinks }; let source = match self.shell { - InitShell::Bash => shell::Bash(opts).render(), - InitShell::Elvish => shell::Elvish(opts).render(), - InitShell::Fish => shell::Fish(opts).render(), - InitShell::Nushell => shell::Nushell(opts).render(), - InitShell::Posix => shell::Posix(opts).render(), - InitShell::Powershell => shell::Powershell(opts).render(), - InitShell::Xonsh => shell::Xonsh(opts).render(), - InitShell::Zsh => shell::Zsh(opts).render(), + InitShell::Bash => Bash(opts).render(), + InitShell::Elvish => Elvish(opts).render(), + InitShell::Fish => Fish(opts).render(), + InitShell::Nushell => Nushell(opts).render(), + InitShell::Posix => Posix(opts).render(), + InitShell::Powershell => Powershell(opts).render(), + InitShell::Xonsh => Xonsh(opts).render(), + InitShell::Zsh => Zsh(opts).render(), } .context("could not render template")?; writeln!(io::stdout(), "{source}").pipe_exit("stdout") diff --git a/src/main.rs b/src/main.rs index 6c7545f..18ac3a6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,7 +30,7 @@ pub fn main() -> ExitCode { Err(e) => match e.downcast::() { Ok(SilentExit { code }) => code.into(), Err(e) => { - let _ = writeln!(io::stderr(), "zoxide: {e:?}"); + _ = writeln!(io::stderr(), "zoxide: {e:?}"); ExitCode::FAILURE } }, diff --git a/src/shell.rs b/src/shell.rs index 8321546..a50c184 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -85,7 +85,7 @@ mod tests { source.push('\n'); Command::new("shfmt") - .args(["-d", "-s", "-ln", "bash", "-i", "4", "-ci", "-"]) + .args(["--diff", "--indent=4", "--language-dialect=bash", "--simplify", "-"]) .write_stdin(source) .assert() .success() @@ -96,13 +96,11 @@ mod tests { #[apply(opts)] fn elvish_elvish(cmd: Option<&str>, hook: InitHook, echo: bool, resolve_symlinks: bool) { let opts = Opts { cmd, hook, echo, resolve_symlinks }; - let mut source = String::new(); + let mut source = String::default(); // Filter out lines using edit:*, since those functions are only available in // the interactive editor. - for line in - Elvish(&opts).render().unwrap().split('\n').filter(|line| !line.contains("edit:")) - { + for line in Elvish(&opts).render().unwrap().lines().filter(|line| !line.contains("edit:")) { source.push_str(line); source.push('\n'); } @@ -218,7 +216,7 @@ mod tests { source.push('\n'); Command::new("shfmt") - .args(["-d", "-s", "-ln", "posix", "-i", "4", "-ci", "-"]) + .args(["--diff", "--indent=4", "--language-dialect=posix", "--simplify", "-"]) .write_stdin(source) .assert() .success() diff --git a/src/util.rs b/src/util.rs index f980f33..47e7e93 100644 --- a/src/util.rs +++ b/src/util.rs @@ -35,6 +35,8 @@ impl Fzf { #[cfg(not(windows))] let program = "fzf"; + // TODO: check version of fzf here. + let mut cmd = Command::new(program); cmd.args([ // Search mode @@ -133,7 +135,7 @@ impl FzfChild { mem::drop(self.0.stdin.take()); let mut stdout = self.0.stdout.take().unwrap(); - let mut output = String::new(); + let mut output = String::default(); stdout.read_to_string(&mut output).context("failed to read from fzf")?; let status = self.0.wait().context("wait failed on fzf")?; @@ -158,7 +160,7 @@ pub fn write(path: impl AsRef, contents: impl AsRef<[u8]>) -> Result<()> { let (mut tmp_file, tmp_path) = tmpfile(dir)?; let result = (|| { // Write to the tmpfile. - let _ = tmp_file.set_len(contents.len() as u64); + _ = tmp_file.set_len(contents.len() as u64); tmp_file .write_all(contents) .with_context(|| format!("could not write to file: {}", tmp_path.display()))?; @@ -173,7 +175,7 @@ pub fn write(path: impl AsRef, contents: impl AsRef<[u8]>) -> Result<()> { let uid = Uid::from_raw(metadata.uid()); let gid = Gid::from_raw(metadata.gid()); - let _ = unistd::fchown(tmp_file.as_raw_fd(), Some(uid), Some(gid)); + _ = unistd::fchown(tmp_file.as_raw_fd(), Some(uid), Some(gid)); } // Close and rename the tmpfile. @@ -182,7 +184,7 @@ pub fn write(path: impl AsRef, contents: impl AsRef<[u8]>) -> Result<()> { })(); // In case of an error, delete the tmpfile. if result.is_err() { - let _ = fs::remove_file(&tmp_path); + _ = fs::remove_file(&tmp_path); } result } diff --git a/templates/bash.txt b/templates/bash.txt index cb44cef..aeec524 100644 --- a/templates/bash.txt +++ b/templates/bash.txt @@ -75,7 +75,7 @@ function __zoxide_z() { __zoxide_cd "${OLDPWD}" elif [[ $# -eq 1 && -d $1 ]]; then __zoxide_cd "$1" - elif [[ ${@: -1} == "${__zoxide_z_prefix}"* ]]; then + elif [[ ${@: -1} == "${__zoxide_z_prefix}"?* ]]; then # shellcheck disable=SC2124 \builtin local result="${@: -1}" __zoxide_cd "{{ "${result:${#__zoxide_z_prefix}}" }}" @@ -90,7 +90,7 @@ function __zoxide_z() { # Jump to a directory using interactive search. function __zoxide_zi() { \builtin local result - result="$(\command zoxide query -i -- "$@")" && __zoxide_cd "${result}" + result="$(\command zoxide query --interactive -- "$@")" && __zoxide_cd "${result}" } {{ section }} @@ -130,10 +130,10 @@ if [[ ${BASH_VERSINFO[0]:-0} -eq 4 && ${BASH_VERSINFO[1]:-0} -ge 4 || ${BASH_VER \builtin compgen -A directory -- "${COMP_WORDS[-1]}" || \builtin true ) # If there is a space after the last word, use interactive selection. - elif [[ -z ${COMP_WORDS[-1]} ]]; then + elif [[ -z ${COMP_WORDS[-1]} ]] && [[ ${COMP_WORDS[-2]} != "${__zoxide_z_prefix}"?* ]]; then \builtin local result # shellcheck disable=SC2312 - result="$(\command zoxide query --exclude "$(__zoxide_pwd)" -i -- "{{ "${COMP_WORDS[@]:1:${#COMP_WORDS[@]}-2}" }}")" && + result="$(\command zoxide query --exclude "$(__zoxide_pwd)" --interactive -- "{{ "${COMP_WORDS[@]:1:${#COMP_WORDS[@]}-2}" }}")" && COMPREPLY=("${__zoxide_z_prefix}${result}/") \builtin printf '\e[5n' fi diff --git a/templates/elvish.txt b/templates/elvish.txt index ea1a5b1..1f48a91 100644 --- a/templates/elvish.txt +++ b/templates/elvish.txt @@ -68,7 +68,7 @@ edit:add-var __zoxide_z~ $__zoxide_z~ fn __zoxide_zi {|@rest| var path try { - set path = (zoxide query -i -- $@rest) + set path = (zoxide query --interactive -- $@rest) } catch { } else { __zoxide_cd $path diff --git a/templates/fish.txt b/templates/fish.txt index 65de458..1db92b0 100644 --- a/templates/fish.txt +++ b/templates/fish.txt @@ -18,9 +18,9 @@ end # A copy of fish's internal cd function. This makes it possible to use # `alias cd=z` without causing an infinite loop. -if ! builtin functions -q __zoxide_cd_internal - if builtin functions -q cd - builtin functions -c cd __zoxide_cd_internal +if ! builtin functions --query __zoxide_cd_internal + if builtin functions --query cd + builtin functions --copy cd __zoxide_cd_internal else alias __zoxide_cd_internal='builtin cd' end @@ -62,20 +62,21 @@ end # When using zoxide with --no-cmd, alias these internal functions as desired. # -set __zoxide_z_prefix 'z!' +if test -z $__zoxide_z_prefix + set __zoxide_z_prefix 'z!' +end +set __zoxide_z_prefix_regex ^(string escape --style=regex $__zoxide_z_prefix) # Jump to a directory using only keywords. function __zoxide_z set -l argc (count $argv) - set -l completion_regex '^'(string escape --style=regex $__zoxide_z_prefix)'(.*)$' - if test $argc -eq 0 __zoxide_cd $HOME else if test "$argv" = - __zoxide_cd - else if test $argc -eq 1 -a -d $argv[1] __zoxide_cd $argv[1] - else if set -l result (string match --groups-only --regex $completion_regex $argv[-1]) + else if set -l result (string replace --regex $__zoxide_z_prefix_regex '' $argv[-1]); and test -n $result __zoxide_cd $result else set -l result (command zoxide query --exclude (__zoxide_pwd) -- $argv) @@ -90,11 +91,12 @@ function __zoxide_z_complete if test (count $tokens) -le 2 -a (count $curr_tokens) -eq 1 # If there are < 2 arguments, use `cd` completions. - __fish_complete_directories "$tokens[2]" '' - else if test (count $tokens) -eq (count $curr_tokens) - # If the last argument is empty, use interactive selection. + complete --do-complete "'' "(commandline --cut-at-cursor --current-token) | string match --regex '.*/$' + else if test (count $tokens) -eq (count $curr_tokens); and ! string match --quiet --regex $__zoxide_z_prefix_regex. $tokens[-1] + # If the last argument is empty and the one before doesn't start with + # $__zoxide_z_prefix, use interactive selection. set -l query $tokens[2..-1] - set -l result (zoxide query --exclude (__zoxide_pwd) -i -- $query) + set -l result (zoxide query --exclude (__zoxide_pwd) --interactive -- $query) and echo $__zoxide_z_prefix$result commandline --function repaint end @@ -103,7 +105,7 @@ complete --command __zoxide_z --no-files --arguments '(__zoxide_z_complete)' # Jump to a directory using interactive search. function __zoxide_zi - set -l result (command zoxide query -i -- $argv) + set -l result (command zoxide query --interactive -- $argv) and __zoxide_cd $result end @@ -131,5 +133,3 @@ alias {{cmd}}i=__zoxide_zi # ~/.config/fish/config.fish): # # zoxide init fish | source -# -# Note: zoxide only supports fish v3.4.0 and above. diff --git a/templates/nushell.txt b/templates/nushell.txt index 27310c0..b01d3f8 100644 --- a/templates/nushell.txt +++ b/templates/nushell.txt @@ -18,7 +18,7 @@ if (not ($env | default false __zoxide_hooked | get __zoxide_hooked)) { let-env config = ($env | default {} config).config let-env config = ($env.config | default {} hooks) let-env config = ($env.config | update hooks ($env.config.hooks | default [] pre_prompt)) - let-env config = ($env.config | update hooks.pre_prompt ($env.config.hooks.pre_prompt | append { + let-env config = ($env.config | update hooks.pre_prompt ($env.config.hooks.pre_prompt | append { || zoxide add -- $env.PWD })) {%- else if hook == InitHook::Pwd %} @@ -40,7 +40,6 @@ if (not ($env | default false __zoxide_hooked | get __zoxide_hooked)) { # Jump to a directory using only keywords. def-env __zoxide_z [...rest:string] { - # `z -` does not work yet, see https://github.com/nushell/nushell/issues/4769 let arg0 = ($rest | append '~').0 let path = if (($rest | length) <= 1) and ($arg0 == '-' or ($arg0 | path expand | path type) == dir) { $arg0 @@ -55,7 +54,7 @@ def-env __zoxide_z [...rest:string] { # Jump to a directory using interactive search. def-env __zoxide_zi [...rest:string] { - cd $'(zoxide query -i -- $rest | str trim -r -c "\n")' + cd $'(zoxide query --interactive -- $rest | str trim -r -c "\n")' {%- if echo %} echo $env.PWD {%- endif %} diff --git a/templates/posix.txt b/templates/posix.txt index 13be61c..ca4b53f 100644 --- a/templates/posix.txt +++ b/templates/posix.txt @@ -74,7 +74,7 @@ __zoxide_z() { # Jump to a directory using interactive search. __zoxide_zi() { - __zoxide_result="$(\command zoxide query -i -- "$@")" && __zoxide_cd "${__zoxide_result}" + __zoxide_result="$(\command zoxide query --interactive -- "$@")" && __zoxide_cd "${__zoxide_result}" } {{ section }} diff --git a/templates/powershell.txt b/templates/powershell.txt index 3df927a..00a0b05 100644 --- a/templates/powershell.txt +++ b/templates/powershell.txt @@ -30,7 +30,15 @@ function __zoxide_cd($dir, $literal) { $dir = if ($literal) { Set-Location -LiteralPath $dir -Passthru -ErrorAction Stop } else { - Set-Location -Path $dir -Passthru -ErrorAction Stop + if ($dir -eq '-' -and ($PSVersionTable.PSVersion -lt 6.1)) { + Write-Error "cd - is not supported below PowerShell 6.1. Please upgrade your version of PowerShell." + } + elseif ($dir -eq '+' -and ($PSVersionTable.PSVersion -lt 6.2)) { + Write-Error "cd + is not supported below PowerShell 6.2. Please upgrade your version of PowerShell." + } + else { + Set-Location -Path $dir -Passthru -ErrorAction Stop + } } {%- if echo %} Write-Output $dir.Path @@ -41,6 +49,15 @@ function __zoxide_cd($dir, $literal) { # Hook configuration for zoxide. # +{% if hook == InitHook::None -%} +{{ not_configured }} + +{%- else -%} +{#- + Initialize $__zoxide_hooked if it does not exist. Removing this will cause an + unset variable error in StrictMode. +-#} +{%- if hook == InitHook::Prompt -%} # Hook to add new entries to the database. function __zoxide_hook { $result = __zoxide_pwd @@ -48,37 +65,34 @@ function __zoxide_hook { zoxide add -- $result } } +{%- else if hook == InitHook::Pwd -%} +# Hook to add new entries to the database. +$global:__zoxide_oldpwd = __zoxide_pwd +function __zoxide_hook { + $result = __zoxide_pwd + if ($result -ne $global:__zoxide_oldpwd) { + if ($null -ne $result) { + zoxide add -- $result + } + $global:__zoxide_oldpwd = $result + } +} +{%- endif %} # Initialize hook. -{#- - Initialize $__zoxide_hooked if it does not exist. Removing this will cause an - unset variable error in StrictMode. -#} -$__zoxide_hooked = (Get-Variable __zoxide_hooked -ValueOnly -ErrorAction SilentlyContinue) +$__zoxide_hooked = (Get-Variable __zoxide_hooked -ErrorAction SilentlyContinue -ValueOnly) if ($__zoxide_hooked -ne 1) { $__zoxide_hooked = 1 -{%- match hook %} -{%- when InitHook::None %} - {{ not_configured }} -{%- when InitHook::Prompt %} - $prompt_old = $function:prompt + $__zoxide_prompt_old = $function:prompt + function prompt { - $null = __zoxide_hook - & $prompt_old - } -{%- when InitHook::Pwd %} - if ($PSVersionTable.PSVersion.Major -ge 6) { - $ExecutionContext.InvokeCommand.LocationChangedAction = { - $null = __zoxide_hook + if ($null -ne $__zoxide_prompt_old) { + & $__zoxide_prompt_old } + $null = __zoxide_hook } - else { - Write-Error ("`n" + - "zoxide: PWD hooks are not supported below powershell 6.`n" + - " Use 'zoxide init powershell --hook prompt' instead.") - } -{%- endmatch %} } +{%- endif %} {{ section }} # When using zoxide with --no-cmd, alias these internal functions as desired. @@ -89,12 +103,12 @@ function __zoxide_z { if ($args.Length -eq 0) { __zoxide_cd ~ $true } - elseif ( - $args.Length -eq 1 -and - (($args[0] -eq '-' -or $args[0] -eq '+') -or (Test-Path $args[0] -PathType Container)) - ) { + elseif ($args.Length -eq 1 -and ($args[0] -eq '-' -or $args[0] -eq '+')) { __zoxide_cd $args[0] $false } + elseif ($args.Length -eq 1 -and (Test-Path $args[0] -PathType Container)) { + __zoxide_cd $args[0] $true + } else { $result = __zoxide_pwd if ($null -ne $result) { @@ -137,4 +151,4 @@ Set-Alias -Name {{cmd}}i -Value __zoxide_zi -Option AllScope -Scope Global -Forc # To initialize zoxide, add this to your configuration (find it by running # `echo $profile` in PowerShell): # -# Invoke-Expression (& { $hook = if ($PSVersionTable.PSVersion.Major -ge 6) { 'pwd' } else { 'prompt' } (zoxide init powershell --hook $hook | Out-String) }) +# Invoke-Expression (& { (zoxide init powershell | Out-String) }) diff --git a/templates/zsh.txt b/templates/zsh.txt index d261a31..20ddd5c 100644 --- a/templates/zsh.txt +++ b/templates/zsh.txt @@ -61,7 +61,7 @@ function __zoxide_z() { __zoxide_cd ~ elif [[ "$#" -eq 1 ]] && { [[ -d "$1" ]] || [[ "$1" = '-' ]] || [[ "$1" =~ ^[-+][0-9]$ ]]; }; then __zoxide_cd "$1" - elif [[ "$@[-1]" == "${__zoxide_z_prefix}"* ]]; then + elif [[ "$@[-1]" == "${__zoxide_z_prefix}"?* ]]; then # shellcheck disable=SC2124 \builtin local result="${@[-1]}" __zoxide_cd "{{ "${result:${#__zoxide_z_prefix}}" }}" @@ -76,7 +76,7 @@ function __zoxide_z() { # Jump to a directory using interactive search. function __zoxide_zi() { \builtin local result - result="$(\command zoxide query -i -- "$@")" && __zoxide_cd "${result}" + result="$(\command zoxide query --interactive -- "$@")" && __zoxide_cd "${result}" } # Completions. @@ -88,10 +88,10 @@ if [[ -o zle ]]; then if [[ "{{ "${#words[@]}" }}" -eq 2 ]]; then _files -/ - elif [[ "${words[-1]}" == '' ]]; then + elif [[ "${words[-1]}" == '' ]] && [[ "${words[-2]}" != "${__zoxide_z_prefix}"?* ]]; then \builtin local result # shellcheck disable=SC2086,SC2312 - if result="$(\command zoxide query --exclude "$(__zoxide_pwd)" -i -- ${words[2,-1]})"; then + if result="$(\command zoxide query --exclude "$(__zoxide_pwd)" --interactive -- ${words[2,-1]})"; then result="${__zoxide_z_prefix}${result}" # shellcheck disable=SC2296 compadd -Q "${(q-)result}" diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml deleted file mode 100644 index 263575e..0000000 --- a/xtask/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "xtask" -version = "0.1.0" -edition = "2021" -publish = false - -[dependencies] -anyhow.workspace = true -clap.workspace = true -ignore.workspace = true -shell-words.workspace = true diff --git a/xtask/src/main.rs b/xtask/src/main.rs deleted file mode 100644 index 2dee47a..0000000 --- a/xtask/src/main.rs +++ /dev/null @@ -1,154 +0,0 @@ -use std::env; -use std::ffi::OsStr; -use std::path::PathBuf; -use std::process::{self, Command}; - -use anyhow::{bail, Context, Result}; -use clap::Parser; -use ignore::Walk; - -fn main() -> Result<()> { - let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - let dir = dir - .parent() - .with_context(|| format!("could not find workspace root: {}", dir.display()))?; - env::set_current_dir(dir) - .with_context(|| format!("could not set current directory: {}", dir.display()))?; - let nix_enabled = enable_nix(); - - let app = App::parse(); - match app { - App::CI => run_ci(nix_enabled)?, - App::Fmt { check } => run_fmt(nix_enabled, check)?, - App::Lint => run_lint(nix_enabled)?, - App::Test { name } => run_tests(nix_enabled, &name)?, - } - - Ok(()) -} - -#[derive(Parser)] -enum App { - CI, - Fmt { - #[clap(long)] - check: bool, - }, - Lint, - Test { - #[clap(default_value = "")] - name: String, - }, -} - -trait CommandExt { - fn run(self) -> Result<()>; -} - -impl CommandExt for &mut Command { - fn run(self) -> Result<()> { - println!(">>> {self:?}"); - let status = self.status().with_context(|| format!("command failed to start: {self:?}"))?; - if !status.success() { - bail!("command failed: {self:?} with status: {status:?}"); - } - Ok(()) - } -} - -fn run_ci(nix_enabled: bool) -> Result<()> { - run_fmt(nix_enabled, true)?; - run_lint(nix_enabled)?; - run_tests(nix_enabled, "")?; - run_msrv(nix_enabled) -} - -fn run_fmt(nix_enabled: bool, check: bool) -> Result<()> { - // Run cargo-fmt. - // let check_args: &[&str] = if check {&["--check", "--files-with-diff"] } else - // { &[] }; Command::new("cargo").args(&["fmt", "--all", - // "--"]).args(check_args).run()?; - - // Run nixfmt. - if nix_enabled { - for result in Walk::new("./") { - let entry = result.unwrap(); - let path = entry.path(); - if path.is_file() && path.extension() == Some(OsStr::new("nix")) { - let check_args: &[&str] = if check { &["--check"] } else { &[] }; - Command::new("nixfmt").args(check_args).arg("--").arg(path).run()?; - } - } - } - - Ok(()) -} - -fn run_lint(nix_enabled: bool) -> Result<()> { - // Run cargo-clippy. - Command::new("cargo") - .args(["clippy", "--all-features", "--all-targets"]) - .args(["--", "-Dwarnings"]) - .run()?; - - if nix_enabled { - // Run markdownlint. - for result in Walk::new("./") { - let entry = result.unwrap(); - let path = entry.path(); - if path.is_file() && path.extension() == Some(OsStr::new("md")) { - Command::new("markdownlint").arg(path).run()?; - } - } - - // Run mandoc with linting enabled. - for result in Walk::new("./man/") { - let entry = result.unwrap(); - let path = entry.path(); - if path.is_file() && path.extension() == Some(OsStr::new("1")) { - Command::new("mandoc").args(["-man", "-Wall", "-Tlint", "--"]).arg(path).run()?; - } - } - } - - Ok(()) -} - -fn run_msrv(nix_enabled: bool) -> Result<()> { - if nix_enabled { - // Run cargo-msrv. - Command::new("cargo-msrv").arg("verify").run()?; - } - Ok(()) -} - -fn run_tests(nix_enabled: bool, name: &str) -> Result<()> { - let args: &[&str] = if nix_enabled { &["nextest", "run", "--all-features"] } else { &["test"] }; - Command::new("cargo").args(args).args(["--no-fail-fast", "--workspace", "--", name]).run() -} - -fn enable_nix() -> bool { - let nix_supported = cfg!(any(target_os = "linux", target_os = "macos")); - if !nix_supported { - return false; - } - let nix_enabled = env::var_os("IN_NIX_SHELL").unwrap_or_default() == "pure"; - if nix_enabled { - return true; - } - let nix_detected = - Command::new("nix-shell").arg("--version").status().map(|s| s.success()).unwrap_or(false); - if !nix_detected { - return false; - } - - println!("Detected Nix in environment, re-running in Nix."); - let args = env::args(); - let cmd = shell_words::join(args); - - let status = Command::new("nix-shell") - .args(["--pure", "--run", &cmd, "--", "shell.nix"]) - .status() - .unwrap(); - process::exit(status.code().unwrap_or(1)); -}