Merge branch 'main' into winget-releaser
This commit is contained in:
commit
8cc60db108
|
|
@ -2,4 +2,9 @@ version = 1
|
||||||
|
|
||||||
[[analyzers]]
|
[[analyzers]]
|
||||||
name = "rust"
|
name = "rust"
|
||||||
enabled = true
|
|
||||||
|
[analyzers.meta]
|
||||||
|
msrv = "stable"
|
||||||
|
|
||||||
|
[[analyzers]]
|
||||||
|
name = "shell"
|
||||||
|
|
@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
|
||||||
Examples of behavior that contributes to a positive environment for our
|
Examples of behavior that contributes to a positive environment for our
|
||||||
community include:
|
community include:
|
||||||
|
|
||||||
* Demonstrating empathy and kindness toward other people
|
- Demonstrating empathy and kindness toward other people
|
||||||
* Being respectful of differing opinions, viewpoints, and experiences
|
- Being respectful of differing opinions, viewpoints, and experiences
|
||||||
* Giving and gracefully accepting constructive feedback
|
- Giving and gracefully accepting constructive feedback
|
||||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
- Accepting responsibility and apologizing to those affected by our mistakes,
|
||||||
and learning from the experience
|
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
|
overall community
|
||||||
|
|
||||||
Examples of unacceptable behavior include:
|
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
|
advances of any kind
|
||||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
- Trolling, insulting or derogatory comments, and personal or political attacks
|
||||||
* Public or private harassment
|
- Public or private harassment
|
||||||
* Publishing others' private information, such as a physical or email
|
- Publishing others' private information, such as a physical or email
|
||||||
address, without their explicit permission
|
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
|
professional setting
|
||||||
|
|
||||||
## Enforcement Responsibilities
|
## Enforcement Responsibilities
|
||||||
|
|
@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
|
||||||
### 4. Permanent Ban
|
### 4. Permanent Ban
|
||||||
|
|
||||||
**Community Impact**: Demonstrating a pattern of violation of community
|
**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.
|
individual, or aggression toward or disparagement of classes of individuals.
|
||||||
|
|
||||||
**Consequence**: A permanent ban from any sort of public interaction within
|
**Consequence**: A permanent ban from any sort of public interaction within
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ env:
|
||||||
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
|
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
|
||||||
CARGO_INCREMENTAL: 0
|
CARGO_INCREMENTAL: 0
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
name: ${{ matrix.os }}
|
name: ${{ matrix.os }}
|
||||||
|
|
@ -16,33 +18,37 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest]
|
os: [ubuntu-latest, windows-latest]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
if: ${{ matrix.os == 'windows-latest' }}
|
if: ${{ matrix.os == 'windows-latest' }}
|
||||||
with:
|
with:
|
||||||
toolchain: stable
|
components: clippy
|
||||||
components: rustfmt, clippy
|
|
||||||
profile: minimal
|
profile: minimal
|
||||||
override: true
|
toolchain: stable
|
||||||
- uses: cachix/install-nix-action@v16
|
- 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' }}
|
if: ${{ matrix.os != 'windows-latest' }}
|
||||||
with:
|
with:
|
||||||
nix_path: nixpkgs=channel:nixos-unstable
|
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 != '' }}
|
if: ${{ matrix.os != 'windows-latest' && env.CACHIX_AUTH_TOKEN != '' }}
|
||||||
with:
|
with:
|
||||||
authToken: ${{ env.CACHIX_AUTH_TOKEN }}
|
authToken: ${{ env.CACHIX_AUTH_TOKEN }}
|
||||||
name: zoxide
|
name: zoxide
|
||||||
|
|
||||||
- name: Setup cache
|
- name: Setup cache
|
||||||
uses: Swatinem/rust-cache@v1
|
uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
key: ${{ matrix.target }}
|
key: ${{ matrix.os }}
|
||||||
|
- name: Install just
|
||||||
- run: cargo xtask ci
|
uses: taiki-e/install-action@v2
|
||||||
if: ${{ matrix.os == 'windows-latest' }}
|
with:
|
||||||
- run: nix-shell --cores 0 --pure --run 'rm -rf ~/.cargo/bin; cargo xtask ci'
|
tool: just
|
||||||
if: ${{ matrix.os != 'windows-latest' }}
|
- name: Run lints + tests
|
||||||
|
run: just lint test
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,6 @@ jobs:
|
||||||
daysUntilClose: 30
|
daysUntilClose: 30
|
||||||
responseRequiredLabel: waiting-for-response
|
responseRequiredLabel: waiting-for-response
|
||||||
closeComment: >
|
closeComment: >
|
||||||
This issue has been automatically closed due to inactivity. If you
|
This issue has been automatically closed due to inactivity. If you feel
|
||||||
feel this is still relevant, please comment here or create a fresh
|
this is still relevant, please comment here or create a fresh issue.
|
||||||
issue.
|
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,11 @@ on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
env:
|
env:
|
||||||
CARGO_INCREMENTAL: 0
|
CARGO_INCREMENTAL: 0
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
name: ${{ matrix.target }}
|
name: ${{ matrix.target }}
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
|
|
@ -26,29 +26,25 @@ jobs:
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
target: aarch64-unknown-linux-musl
|
target: aarch64-unknown-linux-musl
|
||||||
deb: true
|
deb: true
|
||||||
|
|
||||||
- os: macos-11
|
- os: macos-11
|
||||||
target: x86_64-apple-darwin
|
target: x86_64-apple-darwin
|
||||||
- os: macos-11
|
- os: macos-11
|
||||||
target: aarch64-apple-darwin
|
target: aarch64-apple-darwin
|
||||||
|
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
target: x86_64-pc-windows-msvc
|
target: x86_64-pc-windows-msvc
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
target: aarch64-pc-windows-msvc
|
target: aarch64-pc-windows-msvc
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Get version
|
- name: Get version
|
||||||
id: get_version
|
id: get_version
|
||||||
uses: SebRollen/toml-action@v1.0.2
|
uses: SebRollen/toml-action@v1.0.2
|
||||||
with:
|
with:
|
||||||
file: Cargo.toml
|
file: Cargo.toml
|
||||||
field: package.version
|
field: package.version
|
||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
|
|
@ -56,62 +52,52 @@ jobs:
|
||||||
profile: minimal
|
profile: minimal
|
||||||
override: true
|
override: true
|
||||||
target: ${{ matrix.target }}
|
target: ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Setup cache
|
- name: Setup cache
|
||||||
uses: Swatinem/rust-cache@v1
|
uses: Swatinem/rust-cache@v1.0.2
|
||||||
with:
|
with:
|
||||||
key: ${{ matrix.target }}
|
key: ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Build binary
|
- name: Build binary
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: build
|
command: build
|
||||||
args: --release --locked --target=${{ matrix.target }} --color=always --verbose
|
args: --release --locked --target=${{ matrix.target }} --color=always --verbose
|
||||||
use-cross: ${{ runner.os == 'Linux' }}
|
use-cross: ${{ runner.os == 'Linux' }}
|
||||||
|
|
||||||
- name: Install cargo-deb
|
- name: Install cargo-deb
|
||||||
if: ${{ matrix.deb == true }}
|
if: ${{ matrix.deb == true }}
|
||||||
uses: actions-rs/install@v0.1
|
uses: actions-rs/install@v0.1
|
||||||
with:
|
with:
|
||||||
crate: cargo-deb
|
crate: cargo-deb
|
||||||
|
|
||||||
- name: Build deb
|
- name: Build deb
|
||||||
if: ${{ matrix.deb == true }}
|
if: ${{ matrix.deb == true }}
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: deb
|
command: deb
|
||||||
args: --no-build --no-strip --output=. --target=${{ matrix.target }}
|
args: --no-build --no-strip --output=. --target=${{ matrix.target }}
|
||||||
|
|
||||||
- name: Package (*nix)
|
- name: Package (*nix)
|
||||||
if: runner.os != 'Windows'
|
if: runner.os != 'Windows'
|
||||||
run: >
|
run: |
|
||||||
tar -cv
|
tar -cv CHANGELOG.md LICENSE README.md man/ \
|
||||||
CHANGELOG.md LICENSE README.md
|
-C contrib/ completions/ -C ../ \
|
||||||
man/
|
-C target/${{ matrix.target }}/release/ zoxide |
|
||||||
-C contrib/ completions/ -C ../
|
gzip --best > \
|
||||||
-C target/${{ matrix.target }}/release/ zoxide
|
zoxide-${{ steps.get_version.outputs.value }}-${{ matrix.target }}.tar.gz
|
||||||
| gzip --best
|
|
||||||
> 'zoxide-${{ steps.get_version.outputs.value }}-${{ matrix.target }}.tar.gz'
|
|
||||||
- name: Package (Windows)
|
- name: Package (Windows)
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows'
|
||||||
run: >
|
run: |
|
||||||
7z a 'zoxide-${{ steps.get_version.outputs.value }}-${{ matrix.target }}.zip'
|
7z a zoxide-${{ steps.get_version.outputs.value }}-${{ matrix.target }}.zip `
|
||||||
CHANGELOG.md LICENSE README.md
|
CHANGELOG.md LICENSE README.md ./man/ ./contrib/completions/ `
|
||||||
./man/
|
./target/${{ matrix.target }}/release/zoxide.exe
|
||||||
./contrib/completions/
|
|
||||||
./target/${{ matrix.target }}/release/zoxide.exe
|
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.target }}
|
name: ${{ matrix.target }}
|
||||||
path: |
|
path: |
|
||||||
*.deb
|
*.deb
|
||||||
*.tar.gz
|
*.tar.gz
|
||||||
*.zip
|
*.zip
|
||||||
|
|
||||||
- name: Create release
|
- 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
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
draft: true
|
draft: true
|
||||||
|
|
|
||||||
19
CHANGELOG.md
19
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/),
|
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).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## Unreleased
|
## [0.9.1] - 2023-05-07
|
||||||
|
|
||||||
### Added
|
### 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
|
## [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.
|
- Nushell: upgrade minimum supported version to v0.73.0.
|
||||||
- Zsh: fix extra space in interactive completions when no match is found.
|
- Zsh: fix extra space in interactive completions when no match is found.
|
||||||
- Fzf: various improvements, upgrade minimum supported version to v0.33.0.
|
- 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
|
### Removed
|
||||||
|
|
||||||
|
|
@ -132,7 +142,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- PowerShell: Hook not initializing correctly.
|
- PowerShell: hook not initializing correctly.
|
||||||
|
|
||||||
## [0.7.6] - 2021-10-13
|
## [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.
|
- GitHub Actions pipeline to build and upload releases.
|
||||||
- Support for zsh.
|
- 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.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.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
|
[0.8.2]: https://github.com/ajeetdsouza/zoxide/compare/v0.8.1...v0.8.2
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
59
Cargo.toml
59
Cargo.toml
|
|
@ -10,67 +10,44 @@ name = "zoxide"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://github.com/ajeetdsouza/zoxide"
|
repository = "https://github.com/ajeetdsouza/zoxide"
|
||||||
rust-version = "1.65"
|
rust-version = "1.65"
|
||||||
version = "0.9.0"
|
version = "0.9.1"
|
||||||
|
|
||||||
[badges]
|
[badges]
|
||||||
maintenance = { status = "actively-developed" }
|
maintenance = { status = "actively-developed" }
|
||||||
|
|
||||||
[workspace]
|
[dependencies]
|
||||||
members = ["xtask/"]
|
|
||||||
|
|
||||||
[workspace.dependencies]
|
|
||||||
anyhow = "1.0.32"
|
anyhow = "1.0.32"
|
||||||
askama = { version = "0.11.0", default-features = false }
|
askama = { version = "0.12.0", default-features = false }
|
||||||
assert_cmd = "2.0.0"
|
|
||||||
bincode = "1.3.1"
|
bincode = "1.3.1"
|
||||||
clap = { version = "4.0.0", features = ["derive"] }
|
clap = { version = "4.0.0", features = ["derive"] }
|
||||||
clap_complete = "4.0.0"
|
color-print = "0.3.4"
|
||||||
clap_complete_fig = "4.0.0"
|
dirs = "5.0.0"
|
||||||
dirs = "4.0.0"
|
|
||||||
dunce = "1.0.1"
|
dunce = "1.0.1"
|
||||||
fastrand = "1.7.0"
|
fastrand = "1.7.0"
|
||||||
glob = "0.3.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 = [
|
nix = { version = "0.26.1", default-features = false, features = [
|
||||||
"fs",
|
"fs",
|
||||||
"user",
|
"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]
|
[target.'cfg(windows)'.dependencies]
|
||||||
which.workspace = true
|
which = "4.2.5"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
clap.workspace = true
|
clap = { version = "4.0.0", features = ["derive"] }
|
||||||
clap_complete.workspace = true
|
clap_complete = "4.0.0"
|
||||||
clap_complete_fig.workspace = true
|
clap_complete_fig = "4.0.0"
|
||||||
|
color-print = "0.3.4"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
assert_cmd.workspace = true
|
assert_cmd = "2.0.0"
|
||||||
rstest.workspace = true
|
rstest = { version = "0.17.0", default-features = false }
|
||||||
rstest_reuse.workspace = true
|
rstest_reuse = "0.5.0"
|
||||||
tempfile.workspace = true
|
tempfile = "3.1.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
|
|
|
||||||
56
README.md
56
README.md
|
|
@ -71,10 +71,10 @@ zoxide can be installed in 4 easy steps:
|
||||||
>
|
>
|
||||||
> | Distribution | Repository | Instructions |
|
> | Distribution | Repository | Instructions |
|
||||||
> | ------------------- | ----------------------- | ----------------------------------------------------------------------------------------------------- |
|
> | ------------------- | ----------------------- | ----------------------------------------------------------------------------------------------------- |
|
||||||
> | ***Any*** | **[crates.io]** | `cargo install zoxide --locked` |
|
> | **_Any_** | **[crates.io]** | `cargo install zoxide --locked` |
|
||||||
> | *Any* | [asdf] | `asdf plugin add zoxide https://github.com/nyrst/asdf-zoxide.git` <br /> `asdf install zoxide latest` |
|
> | _Any_ | [asdf] | `asdf plugin add zoxide https://github.com/nyrst/asdf-zoxide.git` <br /> `asdf install zoxide latest` |
|
||||||
> | *Any* | [conda-forge] | `conda install -c conda-forge zoxide` |
|
> | _Any_ | [conda-forge] | `conda install -c conda-forge zoxide` |
|
||||||
> | *Any* | [Linuxbrew] | `brew install zoxide` |
|
> | _Any_ | [Linuxbrew] | `brew install zoxide` |
|
||||||
> | Alpine Linux 3.13+ | [Alpine Linux Packages] | `apk add zoxide` |
|
> | Alpine Linux 3.13+ | [Alpine Linux Packages] | `apk add zoxide` |
|
||||||
> | Arch Linux | [Arch Linux Community] | `pacman -S zoxide` |
|
> | Arch Linux | [Arch Linux Community] | `pacman -S zoxide` |
|
||||||
> | CentOS 7+ | [Copr] | `dnf copr enable atim/zoxide` <br /> `dnf install zoxide` |
|
> | CentOS 7+ | [Copr] | `dnf copr enable atim/zoxide` <br /> `dnf install zoxide` |
|
||||||
|
|
@ -131,6 +131,12 @@ zoxide can be installed in 4 easy steps:
|
||||||
> | [Chocolatey] | `choco install zoxide` |
|
> | [Chocolatey] | `choco install zoxide` |
|
||||||
> | [conda-forge] | `conda install -c conda-forge zoxide` |
|
> | [conda-forge] | `conda install -c conda-forge zoxide` |
|
||||||
> | [Scoop] | `scoop install 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
|
||||||
|
> ```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
|
@ -141,7 +147,7 @@ zoxide can be installed in 4 easy steps:
|
||||||
>
|
>
|
||||||
> | Distribution | Repository | Instructions |
|
> | Distribution | Repository | Instructions |
|
||||||
> | ------------- | --------------- | ------------------------------- |
|
> | ------------- | --------------- | ------------------------------- |
|
||||||
> | ***Any*** | **[crates.io]** | `cargo install zoxide --locked` |
|
> | **_Any_** | **[crates.io]** | `cargo install zoxide --locked` |
|
||||||
> | DragonFly BSD | [DPorts] | `pkg install zoxide` |
|
> | DragonFly BSD | [DPorts] | `pkg install zoxide` |
|
||||||
> | FreeBSD | [FreshPorts] | `pkg install zoxide` |
|
> | FreeBSD | [FreshPorts] | `pkg install zoxide` |
|
||||||
> | NetBSD | [pkgsrc] | `pkgin install zoxide` |
|
> | NetBSD | [pkgsrc] | `pkgin install zoxide` |
|
||||||
|
|
@ -196,9 +202,6 @@ zoxide can be installed in 4 easy steps:
|
||||||
> ```fish
|
> ```fish
|
||||||
> zoxide init fish | source
|
> zoxide init fish | source
|
||||||
> ```
|
> ```
|
||||||
>
|
|
||||||
> **Note**
|
|
||||||
> zoxide only supports fish v3.4.0 and above.
|
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
|
@ -229,23 +232,9 @@ zoxide can be installed in 4 easy steps:
|
||||||
> Add this to your configuration (find it by running `echo $profile` in
|
> Add this to your configuration (find it by running `echo $profile` in
|
||||||
> PowerShell):
|
> PowerShell):
|
||||||
>
|
>
|
||||||
> - For zoxide v0.8.0+:
|
> ```powershell
|
||||||
>
|
> Invoke-Expression (& { (zoxide init powershell | Out-String) })
|
||||||
> ```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"
|
|
||||||
> })
|
|
||||||
> ```
|
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
|
@ -269,7 +258,7 @@ zoxide can be installed in 4 easy steps:
|
||||||
> eval "$(zoxide init zsh)"
|
> 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
|
> called. You may have to rebuild your completions cache by running
|
||||||
> `rm ~/.zcompdump*; compinit`.
|
> `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] |
|
| [nnn] | File manager | [nnn-autojump] |
|
||||||
| [ranger] | File manager | [ranger-zoxide] |
|
| [ranger] | File manager | [ranger-zoxide] |
|
||||||
| [telescope.nvim] | Fuzzy finder for Neovim | [telescope-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] |
|
| [vim] / [neovim] | Text editor | [zoxide.vim] |
|
||||||
| [xplr] | File manager | [zoxide.xplr] |
|
| [xplr] | File manager | [zoxide.xplr] |
|
||||||
| [xxh] | Transports shell configuration over SSH | [xxh-plugin-prerun-zoxide] |
|
| [xxh] | Transports shell configuration over SSH | [xxh-plugin-prerun-zoxide] |
|
||||||
| [zabb] | Finds the shortest possible query for a path | Natively supported |
|
| [zabb] | Finds the shortest possible query for a path | Natively supported |
|
||||||
| [zsh-autocomplete] | Realtime completions for zsh | Natively supported |
|
| [zsh-autocomplete] | Realtime completions for zsh | Natively supported |
|
||||||
|
|
||||||
[^1]: Debian / Ubuntu derivatives update their packages very slowly. If you're
|
[^1]:
|
||||||
using one of these distributions, consider using the install script instead.
|
Debian / Ubuntu derivatives update their packages very slowly. If you're
|
||||||
[^2]: If you're not sure how to set an environment variable on your shell, check
|
using one of these distributions, consider using the install script instead.
|
||||||
out the [wiki][wiki-env].
|
|
||||||
|
[^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-aging]: https://github.com/ajeetdsouza/zoxide/wiki/Algorithm#aging
|
||||||
[algorithm-matching]: https://github.com/ajeetdsouza/zoxide/wiki/Algorithm#matching
|
[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
|
[releases]: https://github.com/ajeetdsouza/zoxide/releases
|
||||||
[scoop]: https://github.com/ScoopInstaller/Main/tree/master/bucket/zoxide.json
|
[scoop]: https://github.com/ScoopInstaller/Main/tree/master/bucket/zoxide.json
|
||||||
[slackbuilds-howto]: https://slackbuilds.org/howto/
|
[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-zoxide]: https://github.com/jvgrootveld/telescope-zoxide
|
||||||
[telescope.nvim]: https://github.com/nvim-telescope/telescope.nvim
|
[telescope.nvim]: https://github.com/nvim-telescope/telescope.nvim
|
||||||
[termux]: https://github.com/termux/termux-packages/tree/master/packages/zoxide
|
[termux]: https://github.com/termux/termux-packages/tree/master/packages/zoxide
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,10 @@ _zoxide() {
|
||||||
|
|
||||||
local context curcontext="$curcontext" state line
|
local context curcontext="$curcontext" state line
|
||||||
_arguments "${_arguments_options[@]}" \
|
_arguments "${_arguments_options[@]}" \
|
||||||
'-h[Print help information]' \
|
'-h[Print help]' \
|
||||||
'--help[Print help information]' \
|
'--help[Print help]' \
|
||||||
'-V[Print version information]' \
|
'-V[Print version]' \
|
||||||
'--version[Print version information]' \
|
'--version[Print version]' \
|
||||||
":: :_zoxide_commands" \
|
":: :_zoxide_commands" \
|
||||||
"*::: :->zoxide" \
|
"*::: :->zoxide" \
|
||||||
&& ret=0
|
&& ret=0
|
||||||
|
|
@ -30,19 +30,19 @@ _zoxide() {
|
||||||
case $line[1] in
|
case $line[1] in
|
||||||
(add)
|
(add)
|
||||||
_arguments "${_arguments_options[@]}" \
|
_arguments "${_arguments_options[@]}" \
|
||||||
'-h[Print help information]' \
|
'-h[Print help]' \
|
||||||
'--help[Print help information]' \
|
'--help[Print help]' \
|
||||||
'-V[Print version information]' \
|
'-V[Print version]' \
|
||||||
'--version[Print version information]' \
|
'--version[Print version]' \
|
||||||
'*::paths:_files -/' \
|
'*::paths:_files -/' \
|
||||||
&& ret=0
|
&& ret=0
|
||||||
;;
|
;;
|
||||||
(edit)
|
(edit)
|
||||||
_arguments "${_arguments_options[@]}" \
|
_arguments "${_arguments_options[@]}" \
|
||||||
'-h[Print help information]' \
|
'-h[Print help]' \
|
||||||
'--help[Print help information]' \
|
'--help[Print help]' \
|
||||||
'-V[Print version information]' \
|
'-V[Print version]' \
|
||||||
'--version[Print version information]' \
|
'--version[Print version]' \
|
||||||
":: :_zoxide__edit_commands" \
|
":: :_zoxide__edit_commands" \
|
||||||
"*::: :->edit" \
|
"*::: :->edit" \
|
||||||
&& ret=0
|
&& ret=0
|
||||||
|
|
@ -55,37 +55,37 @@ _arguments "${_arguments_options[@]}" \
|
||||||
case $line[1] in
|
case $line[1] in
|
||||||
(decrement)
|
(decrement)
|
||||||
_arguments "${_arguments_options[@]}" \
|
_arguments "${_arguments_options[@]}" \
|
||||||
'-h[Print help information]' \
|
'-h[Print help]' \
|
||||||
'--help[Print help information]' \
|
'--help[Print help]' \
|
||||||
'-V[Print version information]' \
|
'-V[Print version]' \
|
||||||
'--version[Print version information]' \
|
'--version[Print version]' \
|
||||||
':path:' \
|
':path:' \
|
||||||
&& ret=0
|
&& ret=0
|
||||||
;;
|
;;
|
||||||
(delete)
|
(delete)
|
||||||
_arguments "${_arguments_options[@]}" \
|
_arguments "${_arguments_options[@]}" \
|
||||||
'-h[Print help information]' \
|
'-h[Print help]' \
|
||||||
'--help[Print help information]' \
|
'--help[Print help]' \
|
||||||
'-V[Print version information]' \
|
'-V[Print version]' \
|
||||||
'--version[Print version information]' \
|
'--version[Print version]' \
|
||||||
':path:' \
|
':path:' \
|
||||||
&& ret=0
|
&& ret=0
|
||||||
;;
|
;;
|
||||||
(increment)
|
(increment)
|
||||||
_arguments "${_arguments_options[@]}" \
|
_arguments "${_arguments_options[@]}" \
|
||||||
'-h[Print help information]' \
|
'-h[Print help]' \
|
||||||
'--help[Print help information]' \
|
'--help[Print help]' \
|
||||||
'-V[Print version information]' \
|
'-V[Print version]' \
|
||||||
'--version[Print version information]' \
|
'--version[Print version]' \
|
||||||
':path:' \
|
':path:' \
|
||||||
&& ret=0
|
&& ret=0
|
||||||
;;
|
;;
|
||||||
(reload)
|
(reload)
|
||||||
_arguments "${_arguments_options[@]}" \
|
_arguments "${_arguments_options[@]}" \
|
||||||
'-h[Print help information]' \
|
'-h[Print help]' \
|
||||||
'--help[Print help information]' \
|
'--help[Print help]' \
|
||||||
'-V[Print version information]' \
|
'-V[Print version]' \
|
||||||
'--version[Print version information]' \
|
'--version[Print version]' \
|
||||||
&& ret=0
|
&& ret=0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
@ -96,22 +96,22 @@ esac
|
||||||
_arguments "${_arguments_options[@]}" \
|
_arguments "${_arguments_options[@]}" \
|
||||||
'--from=[Application to import from]:FROM:(autojump z)' \
|
'--from=[Application to import from]:FROM:(autojump z)' \
|
||||||
'--merge[Merge into existing database]' \
|
'--merge[Merge into existing database]' \
|
||||||
'-h[Print help information]' \
|
'-h[Print help]' \
|
||||||
'--help[Print help information]' \
|
'--help[Print help]' \
|
||||||
'-V[Print version information]' \
|
'-V[Print version]' \
|
||||||
'--version[Print version information]' \
|
'--version[Print version]' \
|
||||||
':path:_files' \
|
':path:_files' \
|
||||||
&& ret=0
|
&& ret=0
|
||||||
;;
|
;;
|
||||||
(init)
|
(init)
|
||||||
_arguments "${_arguments_options[@]}" \
|
_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)' \
|
'--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]' \
|
'--no-cmd[Prevents zoxide from defining the \`z\` and \`zi\` commands]' \
|
||||||
'-h[Print help information]' \
|
'-h[Print help]' \
|
||||||
'--help[Print help information]' \
|
'--help[Print help]' \
|
||||||
'-V[Print version information]' \
|
'-V[Print version]' \
|
||||||
'--version[Print version information]' \
|
'--version[Print version]' \
|
||||||
':shell:(bash elvish fish nushell posix powershell xonsh zsh)' \
|
':shell:(bash elvish fish nushell posix powershell xonsh zsh)' \
|
||||||
&& ret=0
|
&& ret=0
|
||||||
;;
|
;;
|
||||||
|
|
@ -125,19 +125,19 @@ _arguments "${_arguments_options[@]}" \
|
||||||
'(-i --interactive)--list[List all matching directories]' \
|
'(-i --interactive)--list[List all matching directories]' \
|
||||||
'-s[Print score with results]' \
|
'-s[Print score with results]' \
|
||||||
'--score[Print score with results]' \
|
'--score[Print score with results]' \
|
||||||
'-h[Print help information]' \
|
'-h[Print help]' \
|
||||||
'--help[Print help information]' \
|
'--help[Print help]' \
|
||||||
'-V[Print version information]' \
|
'-V[Print version]' \
|
||||||
'--version[Print version information]' \
|
'--version[Print version]' \
|
||||||
'*::keywords:' \
|
'*::keywords:' \
|
||||||
&& ret=0
|
&& ret=0
|
||||||
;;
|
;;
|
||||||
(remove)
|
(remove)
|
||||||
_arguments "${_arguments_options[@]}" \
|
_arguments "${_arguments_options[@]}" \
|
||||||
'-h[Print help information]' \
|
'-h[Print help]' \
|
||||||
'--help[Print help information]' \
|
'--help[Print help]' \
|
||||||
'-V[Print version information]' \
|
'-V[Print version]' \
|
||||||
'--version[Print version information]' \
|
'--version[Print version]' \
|
||||||
'*::paths:_files -/' \
|
'*::paths:_files -/' \
|
||||||
&& ret=0
|
&& ret=0
|
||||||
;;
|
;;
|
||||||
|
|
@ -214,4 +214,8 @@ _zoxide__remove_commands() {
|
||||||
_describe -t commands 'zoxide remove commands' commands "$@"
|
_describe -t commands 'zoxide remove commands' commands "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
_zoxide "$@"
|
if [ "$funcstack[1]" = "_zoxide" ]; then
|
||||||
|
_zoxide "$@"
|
||||||
|
else
|
||||||
|
compdef _zoxide zoxide
|
||||||
|
fi
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,10 @@ Register-ArgumentCompleter -Native -CommandName 'zoxide' -ScriptBlock {
|
||||||
|
|
||||||
$completions = @(switch ($command) {
|
$completions = @(switch ($command) {
|
||||||
'zoxide' {
|
'zoxide' {
|
||||||
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information')
|
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information')
|
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information')
|
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information')
|
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
[CompletionResult]::new('add', 'add', [CompletionResultType]::ParameterValue, 'Add a new directory or increment its rank')
|
[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('edit', 'edit', [CompletionResultType]::ParameterValue, 'Edit the database')
|
||||||
[CompletionResult]::new('import', 'import', [CompletionResultType]::ParameterValue, 'Import entries from another application')
|
[CompletionResult]::new('import', 'import', [CompletionResultType]::ParameterValue, 'Import entries from another application')
|
||||||
|
|
@ -34,17 +34,17 @@ Register-ArgumentCompleter -Native -CommandName 'zoxide' -ScriptBlock {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
'zoxide;add' {
|
'zoxide;add' {
|
||||||
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information')
|
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information')
|
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information')
|
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information')
|
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
'zoxide;edit' {
|
'zoxide;edit' {
|
||||||
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information')
|
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information')
|
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information')
|
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information')
|
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
[CompletionResult]::new('decrement', 'decrement', [CompletionResultType]::ParameterValue, 'decrement')
|
[CompletionResult]::new('decrement', 'decrement', [CompletionResultType]::ParameterValue, 'decrement')
|
||||||
[CompletionResult]::new('delete', 'delete', [CompletionResultType]::ParameterValue, 'delete')
|
[CompletionResult]::new('delete', 'delete', [CompletionResultType]::ParameterValue, 'delete')
|
||||||
[CompletionResult]::new('increment', 'increment', [CompletionResultType]::ParameterValue, 'increment')
|
[CompletionResult]::new('increment', 'increment', [CompletionResultType]::ParameterValue, 'increment')
|
||||||
|
|
@ -52,50 +52,50 @@ Register-ArgumentCompleter -Native -CommandName 'zoxide' -ScriptBlock {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
'zoxide;edit;decrement' {
|
'zoxide;edit;decrement' {
|
||||||
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information')
|
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information')
|
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information')
|
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information')
|
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
'zoxide;edit;delete' {
|
'zoxide;edit;delete' {
|
||||||
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information')
|
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information')
|
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information')
|
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information')
|
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
'zoxide;edit;increment' {
|
'zoxide;edit;increment' {
|
||||||
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information')
|
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information')
|
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information')
|
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information')
|
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
'zoxide;edit;reload' {
|
'zoxide;edit;reload' {
|
||||||
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information')
|
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information')
|
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information')
|
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information')
|
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
'zoxide;import' {
|
'zoxide;import' {
|
||||||
[CompletionResult]::new('--from', 'from', [CompletionResultType]::ParameterName, 'Application to import from')
|
[CompletionResult]::new('--from', 'from', [CompletionResultType]::ParameterName, 'Application to import from')
|
||||||
[CompletionResult]::new('--merge', 'merge', [CompletionResultType]::ParameterName, 'Merge into existing database')
|
[CompletionResult]::new('--merge', 'merge', [CompletionResultType]::ParameterName, 'Merge into existing database')
|
||||||
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information')
|
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information')
|
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information')
|
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information')
|
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
'zoxide;init' {
|
'zoxide;init' {
|
||||||
[CompletionResult]::new('--cmd', 'cmd', [CompletionResultType]::ParameterName, 'Changes the prefix of the `z` and `zi` commands')
|
[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('--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('--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('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information')
|
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information')
|
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information')
|
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
'zoxide;query' {
|
'zoxide;query' {
|
||||||
|
|
@ -107,17 +107,17 @@ Register-ArgumentCompleter -Native -CommandName 'zoxide' -ScriptBlock {
|
||||||
[CompletionResult]::new('--list', 'list', [CompletionResultType]::ParameterName, 'List all matching directories')
|
[CompletionResult]::new('--list', 'list', [CompletionResultType]::ParameterName, 'List all matching directories')
|
||||||
[CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 'Print score with results')
|
[CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 'Print score with results')
|
||||||
[CompletionResult]::new('--score', 'score', [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('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information')
|
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information')
|
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information')
|
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
'zoxide;remove' {
|
'zoxide;remove' {
|
||||||
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information')
|
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information')
|
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information')
|
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information')
|
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
_zoxide() {
|
_zoxide() {
|
||||||
local i cur prev opts cmds
|
local i cur prev opts cmd
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,10 @@ set edit:completion:arg-completer[zoxide] = {|@words|
|
||||||
}
|
}
|
||||||
var completions = [
|
var completions = [
|
||||||
&'zoxide'= {
|
&'zoxide'= {
|
||||||
cand -h 'Print help information'
|
cand -h 'Print help'
|
||||||
cand --help 'Print help information'
|
cand --help 'Print help'
|
||||||
cand -V 'Print version information'
|
cand -V 'Print version'
|
||||||
cand --version 'Print version information'
|
cand --version 'Print version'
|
||||||
cand add 'Add a new directory or increment its rank'
|
cand add 'Add a new directory or increment its rank'
|
||||||
cand edit 'Edit the database'
|
cand edit 'Edit the database'
|
||||||
cand import 'Import entries from another application'
|
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'
|
cand remove 'Remove a directory from the database'
|
||||||
}
|
}
|
||||||
&'zoxide;add'= {
|
&'zoxide;add'= {
|
||||||
cand -h 'Print help information'
|
cand -h 'Print help'
|
||||||
cand --help 'Print help information'
|
cand --help 'Print help'
|
||||||
cand -V 'Print version information'
|
cand -V 'Print version'
|
||||||
cand --version 'Print version information'
|
cand --version 'Print version'
|
||||||
}
|
}
|
||||||
&'zoxide;edit'= {
|
&'zoxide;edit'= {
|
||||||
cand -h 'Print help information'
|
cand -h 'Print help'
|
||||||
cand --help 'Print help information'
|
cand --help 'Print help'
|
||||||
cand -V 'Print version information'
|
cand -V 'Print version'
|
||||||
cand --version 'Print version information'
|
cand --version 'Print version'
|
||||||
cand decrement 'decrement'
|
cand decrement 'decrement'
|
||||||
cand delete 'delete'
|
cand delete 'delete'
|
||||||
cand increment 'increment'
|
cand increment 'increment'
|
||||||
cand reload 'reload'
|
cand reload 'reload'
|
||||||
}
|
}
|
||||||
&'zoxide;edit;decrement'= {
|
&'zoxide;edit;decrement'= {
|
||||||
cand -h 'Print help information'
|
cand -h 'Print help'
|
||||||
cand --help 'Print help information'
|
cand --help 'Print help'
|
||||||
cand -V 'Print version information'
|
cand -V 'Print version'
|
||||||
cand --version 'Print version information'
|
cand --version 'Print version'
|
||||||
}
|
}
|
||||||
&'zoxide;edit;delete'= {
|
&'zoxide;edit;delete'= {
|
||||||
cand -h 'Print help information'
|
cand -h 'Print help'
|
||||||
cand --help 'Print help information'
|
cand --help 'Print help'
|
||||||
cand -V 'Print version information'
|
cand -V 'Print version'
|
||||||
cand --version 'Print version information'
|
cand --version 'Print version'
|
||||||
}
|
}
|
||||||
&'zoxide;edit;increment'= {
|
&'zoxide;edit;increment'= {
|
||||||
cand -h 'Print help information'
|
cand -h 'Print help'
|
||||||
cand --help 'Print help information'
|
cand --help 'Print help'
|
||||||
cand -V 'Print version information'
|
cand -V 'Print version'
|
||||||
cand --version 'Print version information'
|
cand --version 'Print version'
|
||||||
}
|
}
|
||||||
&'zoxide;edit;reload'= {
|
&'zoxide;edit;reload'= {
|
||||||
cand -h 'Print help information'
|
cand -h 'Print help'
|
||||||
cand --help 'Print help information'
|
cand --help 'Print help'
|
||||||
cand -V 'Print version information'
|
cand -V 'Print version'
|
||||||
cand --version 'Print version information'
|
cand --version 'Print version'
|
||||||
}
|
}
|
||||||
&'zoxide;import'= {
|
&'zoxide;import'= {
|
||||||
cand --from 'Application to import from'
|
cand --from 'Application to import from'
|
||||||
cand --merge 'Merge into existing database'
|
cand --merge 'Merge into existing database'
|
||||||
cand -h 'Print help information'
|
cand -h 'Print help'
|
||||||
cand --help 'Print help information'
|
cand --help 'Print help'
|
||||||
cand -V 'Print version information'
|
cand -V 'Print version'
|
||||||
cand --version 'Print version information'
|
cand --version 'Print version'
|
||||||
}
|
}
|
||||||
&'zoxide;init'= {
|
&'zoxide;init'= {
|
||||||
cand --cmd 'Changes the prefix of the `z` and `zi` commands'
|
cand --cmd 'Changes the prefix of the `z` and `zi` commands'
|
||||||
cand --hook 'Changes how often zoxide increments a directory''s score'
|
cand --hook 'Changes how often zoxide increments a directory''s score'
|
||||||
cand --no-cmd 'Prevents zoxide from defining the `z` and `zi` commands'
|
cand --no-cmd 'Prevents zoxide from defining the `z` and `zi` commands'
|
||||||
cand -h 'Print help information'
|
cand -h 'Print help'
|
||||||
cand --help 'Print help information'
|
cand --help 'Print help'
|
||||||
cand -V 'Print version information'
|
cand -V 'Print version'
|
||||||
cand --version 'Print version information'
|
cand --version 'Print version'
|
||||||
}
|
}
|
||||||
&'zoxide;query'= {
|
&'zoxide;query'= {
|
||||||
cand --exclude 'Exclude the current directory'
|
cand --exclude 'Exclude the current directory'
|
||||||
|
|
@ -95,16 +95,16 @@ set edit:completion:arg-completer[zoxide] = {|@words|
|
||||||
cand --list 'List all matching directories'
|
cand --list 'List all matching directories'
|
||||||
cand -s 'Print score with results'
|
cand -s 'Print score with results'
|
||||||
cand --score 'Print score with results'
|
cand --score 'Print score with results'
|
||||||
cand -h 'Print help information'
|
cand -h 'Print help'
|
||||||
cand --help 'Print help information'
|
cand --help 'Print help'
|
||||||
cand -V 'Print version information'
|
cand -V 'Print version'
|
||||||
cand --version 'Print version information'
|
cand --version 'Print version'
|
||||||
}
|
}
|
||||||
&'zoxide;remove'= {
|
&'zoxide;remove'= {
|
||||||
cand -h 'Print help information'
|
cand -h 'Print help'
|
||||||
cand --help 'Print help information'
|
cand --help 'Print help'
|
||||||
cand -V 'Print version information'
|
cand -V 'Print version'
|
||||||
cand --version 'Print version information'
|
cand --version 'Print version'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
$completions[$command]
|
$completions[$command]
|
||||||
|
|
|
||||||
|
|
@ -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 h -l help -d 'Print help'
|
||||||
complete -c zoxide -n "__fish_use_subcommand" -s V -l version -d 'Print version information'
|
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 "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 "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 "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 "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 "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_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 h -l help -d 'Print help'
|
||||||
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 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 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'
|
||||||
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 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 "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 "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 "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 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 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 information'
|
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 information'
|
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 information'
|
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 information'
|
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 information'
|
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 information'
|
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 information'
|
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 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" -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 h -l help -d 'Print help'
|
||||||
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 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 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 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" -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 h -l help -d 'Print help'
|
||||||
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 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 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" -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 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 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 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 h -l help -d 'Print help'
|
||||||
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 query" -s V -l version -d 'Print version'
|
||||||
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 h -l help -d 'Print help'
|
||||||
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 remove" -s V -l version -d 'Print version'
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,11 @@ const completion: Fig.Spec = {
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: ["-h", "--help"],
|
name: ["-h", "--help"],
|
||||||
description: "Print help information",
|
description: "Print help",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: ["-V", "--version"],
|
name: ["-V", "--version"],
|
||||||
description: "Print version information",
|
description: "Print version",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
args: {
|
args: {
|
||||||
|
|
@ -31,11 +31,11 @@ const completion: Fig.Spec = {
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: ["-h", "--help"],
|
name: ["-h", "--help"],
|
||||||
description: "Print help information",
|
description: "Print help",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: ["-V", "--version"],
|
name: ["-V", "--version"],
|
||||||
description: "Print version information",
|
description: "Print version",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
args: {
|
args: {
|
||||||
|
|
@ -48,11 +48,11 @@ const completion: Fig.Spec = {
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: ["-h", "--help"],
|
name: ["-h", "--help"],
|
||||||
description: "Print help information",
|
description: "Print help",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: ["-V", "--version"],
|
name: ["-V", "--version"],
|
||||||
description: "Print version information",
|
description: "Print version",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
args: {
|
args: {
|
||||||
|
|
@ -65,11 +65,11 @@ const completion: Fig.Spec = {
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: ["-h", "--help"],
|
name: ["-h", "--help"],
|
||||||
description: "Print help information",
|
description: "Print help",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: ["-V", "--version"],
|
name: ["-V", "--version"],
|
||||||
description: "Print version information",
|
description: "Print version",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
args: {
|
args: {
|
||||||
|
|
@ -82,11 +82,11 @@ const completion: Fig.Spec = {
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: ["-h", "--help"],
|
name: ["-h", "--help"],
|
||||||
description: "Print help information",
|
description: "Print help",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: ["-V", "--version"],
|
name: ["-V", "--version"],
|
||||||
description: "Print version information",
|
description: "Print version",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
@ -94,11 +94,11 @@ const completion: Fig.Spec = {
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: ["-h", "--help"],
|
name: ["-h", "--help"],
|
||||||
description: "Print help information",
|
description: "Print help",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: ["-V", "--version"],
|
name: ["-V", "--version"],
|
||||||
description: "Print version information",
|
description: "Print version",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
@ -124,11 +124,11 @@ const completion: Fig.Spec = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: ["-h", "--help"],
|
name: ["-h", "--help"],
|
||||||
description: "Print help information",
|
description: "Print help",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: ["-V", "--version"],
|
name: ["-V", "--version"],
|
||||||
description: "Print version information",
|
description: "Print version",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
args: {
|
args: {
|
||||||
|
|
@ -169,11 +169,11 @@ const completion: Fig.Spec = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: ["-h", "--help"],
|
name: ["-h", "--help"],
|
||||||
description: "Print help information",
|
description: "Print help",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: ["-V", "--version"],
|
name: ["-V", "--version"],
|
||||||
description: "Print version information",
|
description: "Print version",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
args: {
|
args: {
|
||||||
|
|
@ -230,11 +230,11 @@ const completion: Fig.Spec = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: ["-h", "--help"],
|
name: ["-h", "--help"],
|
||||||
description: "Print help information",
|
description: "Print help",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: ["-V", "--version"],
|
name: ["-V", "--version"],
|
||||||
description: "Print version information",
|
description: "Print version",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
args: {
|
args: {
|
||||||
|
|
@ -249,11 +249,11 @@ const completion: Fig.Spec = {
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: ["-h", "--help"],
|
name: ["-h", "--help"],
|
||||||
description: "Print help information",
|
description: "Print help",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: ["-V", "--version"],
|
name: ["-V", "--version"],
|
||||||
description: "Print version information",
|
description: "Print version",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
args: {
|
args: {
|
||||||
|
|
@ -267,11 +267,11 @@ const completion: Fig.Spec = {
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: ["-h", "--help"],
|
name: ["-h", "--help"],
|
||||||
description: "Print help information",
|
description: "Print help",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: ["-V", "--version"],
|
name: ["-V", "--version"],
|
||||||
description: "Print version information",
|
description: "Print version",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
|
||||||
130
install.sh
130
install.sh
|
|
@ -7,7 +7,7 @@
|
||||||
# extension. Note: Most shells limit `local` to 1 var per line, contra bash.
|
# extension. Note: Most shells limit `local` to 1 var per line, contra bash.
|
||||||
|
|
||||||
main() {
|
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
|
# The version of ksh93 that ships with many illumos systems does not
|
||||||
# support the "local" extension. Print a message rather than fail in
|
# support the "local" extension. Print a message rather than fail in
|
||||||
# subtle ways later on:
|
# subtle ways later on:
|
||||||
|
|
@ -18,56 +18,57 @@ main() {
|
||||||
|
|
||||||
# Detect and print host target triple.
|
# Detect and print host target triple.
|
||||||
ensure get_architecture
|
ensure get_architecture
|
||||||
local _arch="$RETVAL"
|
local _arch="${RETVAL}"
|
||||||
assert_nz "$_arch" "arch"
|
assert_nz "${_arch}" "arch"
|
||||||
echo "Detected architecture: $_arch"
|
echo "Detected architecture: ${_arch}"
|
||||||
|
|
||||||
# Create and enter a temporary directory.
|
# Create and enter a temporary directory.
|
||||||
local _tmp_dir
|
local _tmp_dir
|
||||||
_tmp_dir="$(mktemp -d)" || err "mktemp: could not create temporary directory"
|
_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.
|
# Download and extract zoxide.
|
||||||
ensure download_zoxide "$_arch"
|
ensure download_zoxide "${_arch}"
|
||||||
local _package="$RETVAL"
|
local _package="${RETVAL}"
|
||||||
assert_nz "$_package" "package"
|
assert_nz "${_package}" "package"
|
||||||
echo "Downloaded package: $_package"
|
echo "Downloaded package: ${_package}"
|
||||||
case "$_package" in
|
case "${_package}" in
|
||||||
*.tar.gz)
|
*.tar.gz)
|
||||||
need_cmd tar
|
need_cmd tar
|
||||||
ensure tar -xf "$_package"
|
ensure tar -xf "${_package}"
|
||||||
;;
|
;;
|
||||||
*.zip)
|
*.zip)
|
||||||
need_cmd unzip
|
need_cmd unzip
|
||||||
ensure unzip -oq "$_package"
|
ensure unzip -oq "${_package}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
err "unsupported package format: $_package"
|
err "unsupported package format: ${_package}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Install binary.
|
# Install binary.
|
||||||
local _bin_dir="$HOME/.local/bin"
|
local _bin_dir="${HOME}/.local/bin"
|
||||||
local _bin_name
|
local _bin_name
|
||||||
case "$_arch" in
|
case "${_arch}" in
|
||||||
*windows*) _bin_name="zoxide.exe" ;;
|
*windows*) _bin_name="zoxide.exe" ;;
|
||||||
*) _bin_name="zoxide" ;;
|
*) _bin_name="zoxide" ;;
|
||||||
esac
|
esac
|
||||||
ensure mkdir -p "$_bin_dir"
|
ensure mkdir -p "${_bin_dir}"
|
||||||
ensure cp "$_bin_name" "$_bin_dir"
|
ensure cp "${_bin_name}" "${_bin_dir}"
|
||||||
echo "Installed zoxide to $_bin_dir"
|
ensure chmod +x "${_bin_dir}/${_bin_name}"
|
||||||
|
echo "Installed zoxide to ${_bin_dir}"
|
||||||
|
|
||||||
# Install manpages.
|
# Install manpages.
|
||||||
local _man_dir="$HOME/.local/share/man"
|
local _man_dir="${HOME}/.local/share/man"
|
||||||
ensure mkdir -p "$_man_dir/man1"
|
ensure mkdir -p "${_man_dir}/man1"
|
||||||
ensure cp "man/man1/"* "$_man_dir/man1/"
|
ensure cp "man/man1/"* "${_man_dir}/man1/"
|
||||||
echo "Installed manpages to $_man_dir"
|
echo "Installed manpages to ${_man_dir}"
|
||||||
|
|
||||||
# Print success message and check $PATH.
|
# Print success message and check $PATH.
|
||||||
echo ""
|
echo ""
|
||||||
echo "zoxide is installed!"
|
echo "zoxide is installed!"
|
||||||
if ! echo ":$PATH:" | grep -Fq ":$_bin_dir:"; then
|
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."
|
echo "NOTE: ${_bin_dir} is not on your \$PATH. zoxide will not work unless it is added to \$PATH."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,33 +86,35 @@ download_zoxide() {
|
||||||
|
|
||||||
local _releases_url="https://api.github.com/repos/ajeetdsouza/zoxide/releases/latest"
|
local _releases_url="https://api.github.com/repos/ajeetdsouza/zoxide/releases/latest"
|
||||||
local _releases
|
local _releases
|
||||||
case "$_dld" in
|
case "${_dld}" in
|
||||||
curl) _releases="$(curl -sL "$_releases_url")" ||
|
curl) _releases="$(curl -sL "${_releases_url}")" ||
|
||||||
err "curl: failed to download $_releases_url" ;;
|
err "curl: failed to download ${_releases_url}" ;;
|
||||||
wget) _releases="$(wget -qO- "$_releases_url")" ||
|
wget) _releases="$(wget -qO- "${_releases_url}")" ||
|
||||||
err "wget: failed to download $_releases_url" ;;
|
err "wget: failed to download ${_releases_url}" ;;
|
||||||
|
*) err "unsupported downloader: ${_dld}" ;;
|
||||||
esac
|
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"
|
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
|
local _package_url
|
||||||
_package_url="$(echo "$_releases" | grep "browser_download_url" | cut -d '"' -f 4 | grep "$_arch")" ||
|
_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"
|
err "zoxide has not yet been packaged for your architecture (${_arch}), please file an issue: https://github.com/ajeetdsouza/zoxide/issues"
|
||||||
|
|
||||||
local _ext
|
local _ext
|
||||||
case "$_package_url" in
|
case "${_package_url}" in
|
||||||
*.tar.gz) _ext="tar.gz" ;;
|
*.tar.gz) _ext="tar.gz" ;;
|
||||||
*.zip) _ext="zip" ;;
|
*.zip) _ext="zip" ;;
|
||||||
*) err "unsupported package format: $_package_url" ;;
|
*) err "unsupported package format: ${_package_url}" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
local _package="zoxide.$_ext"
|
local _package="zoxide.${_ext}"
|
||||||
case "$_dld" in
|
case "${_dld}" in
|
||||||
curl) _releases="$(curl -sLo "$_package" "$_package_url")" || err "curl: failed to download $_package_url" ;;
|
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" ;;
|
wget) _releases="$(wget -qO "${_package}" "${_package_url}")" || err "wget: failed to download ${_package_url}" ;;
|
||||||
|
*) err "unsupported downloader: ${_dld}" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
RETVAL="$_package"
|
RETVAL="${_package}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# The below functions have been extracted with minor modifications from the
|
# The below functions have been extracted with minor modifications from the
|
||||||
|
|
@ -125,25 +128,25 @@ get_architecture() {
|
||||||
_cputype="$(uname -m)"
|
_cputype="$(uname -m)"
|
||||||
_clibtype="musl"
|
_clibtype="musl"
|
||||||
|
|
||||||
if [ "$_ostype" = Linux ]; then
|
if [ "${_ostype}" = Linux ]; then
|
||||||
if [ "$(uname -o)" = Android ]; then
|
if [ "$(uname -o || true)" = Android ]; then
|
||||||
_ostype=Android
|
_ostype=Android
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$_ostype" = Darwin ] && [ "$_cputype" = i386 ]; then
|
if [ "${_ostype}" = Darwin ] && [ "${_cputype}" = i386 ]; then
|
||||||
# Darwin `uname -m` lies
|
# Darwin `uname -m` lies
|
||||||
if sysctl hw.optional.x86_64 | grep -q ': 1'; then
|
if sysctl hw.optional.x86_64 | grep -q ': 1'; then
|
||||||
_cputype=x86_64
|
_cputype=x86_64
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$_ostype" = SunOS ]; then
|
if [ "${_ostype}" = SunOS ]; then
|
||||||
# Both Solaris and illumos presently announce as "SunOS" in "uname -s"
|
# Both Solaris and illumos presently announce as "SunOS" in "uname -s"
|
||||||
# so use "uname -o" to disambiguate. We use the full path to the
|
# 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,
|
# system uname in case the user has coreutils uname first in PATH,
|
||||||
# which has historically sometimes printed the wrong value here.
|
# 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
|
_ostype=illumos
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -151,18 +154,18 @@ get_architecture() {
|
||||||
# machine hardware name; e.g., "i86pc" on both 32- and 64-bit x86
|
# machine hardware name; e.g., "i86pc" on both 32- and 64-bit x86
|
||||||
# systems. Check for the native (widest) instruction set on the
|
# systems. Check for the native (widest) instruction set on the
|
||||||
# running kernel:
|
# running kernel:
|
||||||
if [ "$_cputype" = i86pc ]; then
|
if [ "${_cputype}" = i86pc ]; then
|
||||||
_cputype="$(isainfo -n)"
|
_cputype="$(isainfo -n)"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$_ostype" in
|
case "${_ostype}" in
|
||||||
Android)
|
Android)
|
||||||
_ostype=linux-android
|
_ostype=linux-android
|
||||||
;;
|
;;
|
||||||
Linux)
|
Linux)
|
||||||
check_proc
|
check_proc
|
||||||
_ostype=unknown-linux-$_clibtype
|
_ostype=unknown-linux-${_clibtype}
|
||||||
_bitness=$(get_bitness)
|
_bitness=$(get_bitness)
|
||||||
;;
|
;;
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
|
|
@ -184,23 +187,23 @@ get_architecture() {
|
||||||
_ostype=pc-windows-msvc
|
_ostype=pc-windows-msvc
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
err "unrecognized OS type: $_ostype"
|
err "unrecognized OS type: ${_ostype}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case "$_cputype" in
|
case "${_cputype}" in
|
||||||
i386 | i486 | i686 | i786 | x86)
|
i386 | i486 | i686 | i786 | x86)
|
||||||
_cputype=i686
|
_cputype=i686
|
||||||
;;
|
;;
|
||||||
xscale | arm)
|
xscale | arm)
|
||||||
_cputype=arm
|
_cputype=arm
|
||||||
if [ "$_ostype" = "linux-android" ]; then
|
if [ "${_ostype}" = "linux-android" ]; then
|
||||||
_ostype=linux-androideabi
|
_ostype=linux-androideabi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
armv6l)
|
armv6l)
|
||||||
_cputype=arm
|
_cputype=arm
|
||||||
if [ "$_ostype" = "linux-android" ]; then
|
if [ "${_ostype}" = "linux-android" ]; then
|
||||||
_ostype=linux-androideabi
|
_ostype=linux-androideabi
|
||||||
else
|
else
|
||||||
_ostype="${_ostype}eabihf"
|
_ostype="${_ostype}eabihf"
|
||||||
|
|
@ -208,7 +211,7 @@ get_architecture() {
|
||||||
;;
|
;;
|
||||||
armv7l | armv8l)
|
armv7l | armv8l)
|
||||||
_cputype=armv7
|
_cputype=armv7
|
||||||
if [ "$_ostype" = "linux-android" ]; then
|
if [ "${_ostype}" = "linux-android" ]; then
|
||||||
_ostype=linux-androideabi
|
_ostype=linux-androideabi
|
||||||
else
|
else
|
||||||
_ostype="${_ostype}eabihf"
|
_ostype="${_ostype}eabihf"
|
||||||
|
|
@ -224,7 +227,7 @@ get_architecture() {
|
||||||
_cputype=$(get_endianness mips '' el)
|
_cputype=$(get_endianness mips '' el)
|
||||||
;;
|
;;
|
||||||
mips64)
|
mips64)
|
||||||
if [ "$_bitness" -eq 64 ]; then
|
if [ "${_bitness}" -eq 64 ]; then
|
||||||
# only n64 ABI is supported for now
|
# only n64 ABI is supported for now
|
||||||
_ostype="${_ostype}abi64"
|
_ostype="${_ostype}abi64"
|
||||||
_cputype=$(get_endianness mips64 '' el)
|
_cputype=$(get_endianness mips64 '' el)
|
||||||
|
|
@ -246,13 +249,13 @@ get_architecture() {
|
||||||
_cputype=riscv64gc
|
_cputype=riscv64gc
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
err "unknown CPU type: $_cputype"
|
err "unknown CPU type: ${_cputype}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Detect 64-bit linux with 32-bit userland
|
# Detect 64-bit linux with 32-bit userland
|
||||||
if [ "${_ostype}" = unknown-linux-musl ] && [ "${_bitness}" -eq 32 ]; then
|
if [ "${_ostype}" = unknown-linux-musl ] && [ "${_bitness}" -eq 32 ]; then
|
||||||
case $_cputype in
|
case ${_cputype} in
|
||||||
x86_64)
|
x86_64)
|
||||||
# 32-bit executable for amd64 = x32
|
# 32-bit executable for amd64 = x32
|
||||||
if is_host_amd64_elf; then {
|
if is_host_amd64_elf; then {
|
||||||
|
|
@ -270,7 +273,7 @@ get_architecture() {
|
||||||
;;
|
;;
|
||||||
aarch64)
|
aarch64)
|
||||||
_cputype=armv7
|
_cputype=armv7
|
||||||
if [ "$_ostype" = "linux-android" ]; then
|
if [ "${_ostype}" = "linux-android" ]; then
|
||||||
_ostype=linux-androideabi
|
_ostype=linux-androideabi
|
||||||
else
|
else
|
||||||
_ostype="${_ostype}eabihf"
|
_ostype="${_ostype}eabihf"
|
||||||
|
|
@ -279,13 +282,14 @@ get_architecture() {
|
||||||
riscv64gc)
|
riscv64gc)
|
||||||
err "riscv64 with 32-bit userland unsupported"
|
err "riscv64 with 32-bit userland unsupported"
|
||||||
;;
|
;;
|
||||||
|
*) ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Detect armv7 but without the CPU features Rust needs in that build,
|
# Detect armv7 but without the CPU features Rust needs in that build,
|
||||||
# and fall back to arm.
|
# and fall back to arm.
|
||||||
# See https://github.com/rust-lang/rustup.rs/issues/587.
|
# 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
|
if ensure grep '^Features' /proc/cpuinfo | grep -q -v neon; then
|
||||||
# At least one processor does not have NEON.
|
# At least one processor does not have NEON.
|
||||||
_cputype=arm
|
_cputype=arm
|
||||||
|
|
@ -293,7 +297,7 @@ get_architecture() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_arch="${_cputype}-${_ostype}"
|
_arch="${_cputype}-${_ostype}"
|
||||||
RETVAL="$_arch"
|
RETVAL="${_arch}"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_bitness() {
|
get_bitness() {
|
||||||
|
|
@ -306,9 +310,9 @@ get_bitness() {
|
||||||
# escape sequences, so we use those.
|
# escape sequences, so we use those.
|
||||||
local _current_exe_head
|
local _current_exe_head
|
||||||
_current_exe_head=$(head -c 5 /proc/self/exe)
|
_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
|
echo 32
|
||||||
elif [ "$_current_exe_head" = "$(printf '\177ELF\002')" ]; then
|
elif [ "${_current_exe_head}" = "$(printf '\177ELF\002')" ]; then
|
||||||
echo 64
|
echo 64
|
||||||
else
|
else
|
||||||
err "unknown platform bitness"
|
err "unknown platform bitness"
|
||||||
|
|
@ -326,9 +330,9 @@ get_endianness() {
|
||||||
|
|
||||||
local _current_exe_endianness
|
local _current_exe_endianness
|
||||||
_current_exe_endianness="$(head -c 6 /proc/self/exe | tail -c 1)"
|
_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}"
|
echo "${cputype}${suffix_el}"
|
||||||
elif [ "$_current_exe_endianness" = "$(printf '\002')" ]; then
|
elif [ "${_current_exe_endianness}" = "$(printf '\002')" ]; then
|
||||||
echo "${cputype}${suffix_eb}"
|
echo "${cputype}${suffix_eb}"
|
||||||
else
|
else
|
||||||
err "unknown platform endianness"
|
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.
|
# but we're interested in it being 0x3E to indicate amd64, or not that.
|
||||||
local _current_exe_machine
|
local _current_exe_machine
|
||||||
_current_exe_machine=$(head -c 19 /proc/self/exe | tail -c 1)
|
_current_exe_machine=$(head -c 19 /proc/self/exe | tail -c 1)
|
||||||
[ "$_current_exe_machine" = "$(printf '\076')" ]
|
[ "${_current_exe_machine}" = "$(printf '\076')" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
check_proc() {
|
check_proc() {
|
||||||
|
|
|
||||||
|
|
@ -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}}
|
||||||
|
|
@ -28,8 +28,6 @@ Add this to your configuration (usually \fB~/.config/fish/config.fish\fR):
|
||||||
.nf
|
.nf
|
||||||
\fBzoxide init fish | source\fR
|
\fBzoxide init fish | source\fR
|
||||||
.fi
|
.fi
|
||||||
.sp
|
|
||||||
Note: zoxide only supports fish v3.4.0 and above.
|
|
||||||
.TP
|
.TP
|
||||||
.B nushell
|
.B nushell
|
||||||
Add this to your env file (find it by running \fB$nu.env-path\fR in 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):
|
PowerShell):
|
||||||
.sp
|
.sp
|
||||||
.nf
|
.nf
|
||||||
\fBInvoke-Expression (& {
|
\fBInvoke-Expression (& { (zoxide init powershell | Out-String) })\fR
|
||||||
$hook = if ($PSVersionTable.PSVersion.Major -lt 6) { 'prompt' } else { 'pwd' }
|
|
||||||
(zoxide init --hook $hook powershell | Out-String)
|
|
||||||
})\fR
|
|
||||||
.fi
|
.fi
|
||||||
.TP
|
.TP
|
||||||
.B xonsh
|
.B xonsh
|
||||||
|
|
|
||||||
20
shell.nix
20
shell.nix
|
|
@ -1,13 +1,22 @@
|
||||||
let
|
let
|
||||||
rust = import (builtins.fetchTarball
|
|
||||||
"https://github.com/oxalica/rust-overlay/archive/9096306d4a1c3adcc8d20f2c9dcaee3dee30d1ad.tar.gz");
|
|
||||||
pkgs = import (builtins.fetchTarball
|
pkgs = import (builtins.fetchTarball
|
||||||
"https://github.com/NixOS/nixpkgs/archive/5f902ae769594aaeaf326e8623a48482eeacfe89.tar.gz") {
|
"https://github.com/NixOS/nixpkgs/archive/22a6958f46fd8e14830d02856ff63b1d0e5cc3e4.tar.gz") {
|
||||||
overlays = [ rust ];
|
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 {
|
in pkgs.mkShell {
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
# Rust
|
# Rust
|
||||||
|
(pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.rustfmt))
|
||||||
pkgs.rust-bin.stable.latest.default
|
pkgs.rust-bin.stable.latest.default
|
||||||
|
|
||||||
# Shells
|
# Shells
|
||||||
|
|
@ -21,8 +30,11 @@ in pkgs.mkShell {
|
||||||
pkgs.zsh
|
pkgs.zsh
|
||||||
|
|
||||||
# Tools
|
# Tools
|
||||||
|
cargo-udeps
|
||||||
pkgs.cargo-msrv
|
pkgs.cargo-msrv
|
||||||
pkgs.cargo-nextest
|
pkgs.cargo-nextest
|
||||||
|
pkgs.cargo-udeps
|
||||||
|
pkgs.just
|
||||||
pkgs.mandoc
|
pkgs.mandoc
|
||||||
pkgs.nixfmt
|
pkgs.nixfmt
|
||||||
pkgs.nodePackages.markdownlint-cli
|
pkgs.nodePackages.markdownlint-cli
|
||||||
|
|
@ -31,6 +43,7 @@ in pkgs.mkShell {
|
||||||
pkgs.python3Packages.pylint
|
pkgs.python3Packages.pylint
|
||||||
pkgs.shellcheck
|
pkgs.shellcheck
|
||||||
pkgs.shfmt
|
pkgs.shfmt
|
||||||
|
pkgs.yamlfmt
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
pkgs.cacert
|
pkgs.cacert
|
||||||
|
|
@ -39,6 +52,5 @@ in pkgs.mkShell {
|
||||||
pkgs.libiconv
|
pkgs.libiconv
|
||||||
];
|
];
|
||||||
|
|
||||||
CARGO_INCREMENTAL = builtins.getEnv "CI" != "";
|
|
||||||
CARGO_TARGET_DIR = "target_nix";
|
CARGO_TARGET_DIR = "target_nix";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,20 +4,28 @@ use std::path::PathBuf;
|
||||||
|
|
||||||
use clap::{Parser, Subcommand, ValueEnum, ValueHint};
|
use clap::{Parser, Subcommand, ValueEnum, ValueHint};
|
||||||
|
|
||||||
const ENV_HELP: &str = "Environment variables:
|
const HELP_TEMPLATE: &str = color_print::cstr!(
|
||||||
_ZO_DATA_DIR Path for zoxide data files
|
"\
|
||||||
_ZO_ECHO Print the matched directory before navigating to it when set to 1
|
<bold><underline>{before-help}{name} {version}</underline></bold>
|
||||||
_ZO_EXCLUDE_DIRS List of directory globs to be excluded
|
{author-with-newline}{about-with-newline}
|
||||||
_ZO_FZF_OPTS Custom flags to pass to fzf
|
{usage-heading} {usage}
|
||||||
_ZO_MAXAGE Maximum total age after which entries start getting deleted
|
|
||||||
_ZO_RESOLVE_SYMLINKS Resolve symlinks when storing paths";
|
{all-args}{after-help}
|
||||||
|
|
||||||
|
<bold><underline>Environment variables:</underline></bold>
|
||||||
|
<bold>_ZO_DATA_DIR</bold> Path for zoxide data files
|
||||||
|
<bold>_ZO_ECHO</bold> Print the matched directory before navigating to it when set to 1
|
||||||
|
<bold>_ZO_EXCLUDE_DIRS</bold> List of directory globs to be excluded
|
||||||
|
<bold>_ZO_FZF_OPTS</bold> Custom flags to pass to fzf
|
||||||
|
<bold>_ZO_MAXAGE</bold> Maximum total age after which entries start getting deleted
|
||||||
|
<bold>_ZO_RESOLVE_SYMLINKS</bold> Resolve symlinks when storing paths"
|
||||||
|
);
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
#[clap(
|
#[clap(
|
||||||
bin_name = env!("CARGO_PKG_NAME"),
|
|
||||||
about,
|
about,
|
||||||
author,
|
author,
|
||||||
after_help = ENV_HELP,
|
help_template = HELP_TEMPLATE,
|
||||||
disable_help_subcommand = true,
|
disable_help_subcommand = true,
|
||||||
propagate_version = true,
|
propagate_version = true,
|
||||||
version = option_env!("ZOXIDE_VERSION").unwrap_or_default()
|
version = option_env!("ZOXIDE_VERSION").unwrap_or_default()
|
||||||
|
|
@ -33,6 +41,10 @@ pub enum Cmd {
|
||||||
|
|
||||||
/// Add a new directory or increment its rank
|
/// Add a new directory or increment its rank
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
|
#[clap(
|
||||||
|
author,
|
||||||
|
help_template = HELP_TEMPLATE,
|
||||||
|
)]
|
||||||
pub struct Add {
|
pub struct Add {
|
||||||
#[clap(num_args = 1.., required = true, value_hint = ValueHint::DirPath)]
|
#[clap(num_args = 1.., required = true, value_hint = ValueHint::DirPath)]
|
||||||
pub paths: Vec<PathBuf>,
|
pub paths: Vec<PathBuf>,
|
||||||
|
|
@ -40,6 +52,10 @@ pub struct Add {
|
||||||
|
|
||||||
/// Edit the database
|
/// Edit the database
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
|
#[clap(
|
||||||
|
author,
|
||||||
|
help_template = HELP_TEMPLATE,
|
||||||
|
)]
|
||||||
pub struct Edit {
|
pub struct Edit {
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
pub cmd: Option<EditCommand>,
|
pub cmd: Option<EditCommand>,
|
||||||
|
|
@ -59,6 +75,10 @@ pub enum EditCommand {
|
||||||
|
|
||||||
/// Import entries from another application
|
/// Import entries from another application
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
|
#[clap(
|
||||||
|
author,
|
||||||
|
help_template = HELP_TEMPLATE,
|
||||||
|
)]
|
||||||
pub struct Import {
|
pub struct Import {
|
||||||
#[clap(value_hint = ValueHint::FilePath)]
|
#[clap(value_hint = ValueHint::FilePath)]
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
|
|
@ -75,11 +95,16 @@ pub struct Import {
|
||||||
#[derive(ValueEnum, Clone, Debug)]
|
#[derive(ValueEnum, Clone, Debug)]
|
||||||
pub enum ImportFrom {
|
pub enum ImportFrom {
|
||||||
Autojump,
|
Autojump,
|
||||||
|
#[clap(alias = "fasd")]
|
||||||
Z,
|
Z,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate shell configuration
|
/// Generate shell configuration
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
|
#[clap(
|
||||||
|
author,
|
||||||
|
help_template = HELP_TEMPLATE,
|
||||||
|
)]
|
||||||
pub struct Init {
|
pub struct Init {
|
||||||
#[clap(value_enum)]
|
#[clap(value_enum)]
|
||||||
pub shell: InitShell,
|
pub shell: InitShell,
|
||||||
|
|
@ -118,6 +143,10 @@ pub enum InitShell {
|
||||||
|
|
||||||
/// Search for a directory in the database
|
/// Search for a directory in the database
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
|
#[clap(
|
||||||
|
author,
|
||||||
|
help_template = HELP_TEMPLATE,
|
||||||
|
)]
|
||||||
pub struct Query {
|
pub struct Query {
|
||||||
pub keywords: Vec<String>,
|
pub keywords: Vec<String>,
|
||||||
|
|
||||||
|
|
@ -144,6 +173,10 @@ pub struct Query {
|
||||||
|
|
||||||
/// Remove a directory from the database
|
/// Remove a directory from the database
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
|
#[clap(
|
||||||
|
author,
|
||||||
|
help_template = HELP_TEMPLATE,
|
||||||
|
)]
|
||||||
pub struct Remove {
|
pub struct Remove {
|
||||||
#[clap(value_hint = ValueHint::DirPath)]
|
#[clap(value_hint = ValueHint::DirPath)]
|
||||||
pub paths: Vec<String>,
|
pub paths: Vec<String>,
|
||||||
|
|
|
||||||
|
|
@ -31,17 +31,15 @@ fn import_autojump(db: &mut Database, buffer: &str) -> Result<()> {
|
||||||
if line.is_empty() {
|
if line.is_empty() {
|
||||||
continue;
|
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::<f64>().with_context(|| format!("invalid rank: {rank}"))?;
|
let mut rank = rank.parse::<f64>().with_context(|| format!("invalid rank: {rank}"))?;
|
||||||
// Normalize the rank using a sigmoid function. Don't import actual ranks from
|
// Normalize the rank using a sigmoid function. Don't import actual ranks from
|
||||||
// autojump, since its scoring algorithm is very different and might
|
// autojump, since its scoring algorithm is very different and might
|
||||||
// take a while to get normalized.
|
// take a while to get normalized.
|
||||||
rank = sigmoid(rank);
|
rank = sigmoid(rank);
|
||||||
|
|
||||||
let path = split.next().with_context(|| format!("invalid entry: {line}"))?;
|
|
||||||
|
|
||||||
db.add_unchecked(path, rank, 0);
|
db.add_unchecked(path, rank, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use askama::Template;
|
||||||
use crate::cmd::{Init, InitShell, Run};
|
use crate::cmd::{Init, InitShell, Run};
|
||||||
use crate::config;
|
use crate::config;
|
||||||
use crate::error::BrokenPipeHandler;
|
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 {
|
impl Run for Init {
|
||||||
fn run(&self) -> Result<()> {
|
fn run(&self) -> Result<()> {
|
||||||
|
|
@ -16,14 +16,14 @@ impl Run for Init {
|
||||||
let opts = &Opts { cmd, hook: self.hook, echo, resolve_symlinks };
|
let opts = &Opts { cmd, hook: self.hook, echo, resolve_symlinks };
|
||||||
|
|
||||||
let source = match self.shell {
|
let source = match self.shell {
|
||||||
InitShell::Bash => shell::Bash(opts).render(),
|
InitShell::Bash => Bash(opts).render(),
|
||||||
InitShell::Elvish => shell::Elvish(opts).render(),
|
InitShell::Elvish => Elvish(opts).render(),
|
||||||
InitShell::Fish => shell::Fish(opts).render(),
|
InitShell::Fish => Fish(opts).render(),
|
||||||
InitShell::Nushell => shell::Nushell(opts).render(),
|
InitShell::Nushell => Nushell(opts).render(),
|
||||||
InitShell::Posix => shell::Posix(opts).render(),
|
InitShell::Posix => Posix(opts).render(),
|
||||||
InitShell::Powershell => shell::Powershell(opts).render(),
|
InitShell::Powershell => Powershell(opts).render(),
|
||||||
InitShell::Xonsh => shell::Xonsh(opts).render(),
|
InitShell::Xonsh => Xonsh(opts).render(),
|
||||||
InitShell::Zsh => shell::Zsh(opts).render(),
|
InitShell::Zsh => Zsh(opts).render(),
|
||||||
}
|
}
|
||||||
.context("could not render template")?;
|
.context("could not render template")?;
|
||||||
writeln!(io::stdout(), "{source}").pipe_exit("stdout")
|
writeln!(io::stdout(), "{source}").pipe_exit("stdout")
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ pub fn main() -> ExitCode {
|
||||||
Err(e) => match e.downcast::<SilentExit>() {
|
Err(e) => match e.downcast::<SilentExit>() {
|
||||||
Ok(SilentExit { code }) => code.into(),
|
Ok(SilentExit { code }) => code.into(),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let _ = writeln!(io::stderr(), "zoxide: {e:?}");
|
_ = writeln!(io::stderr(), "zoxide: {e:?}");
|
||||||
ExitCode::FAILURE
|
ExitCode::FAILURE
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
10
src/shell.rs
10
src/shell.rs
|
|
@ -85,7 +85,7 @@ mod tests {
|
||||||
source.push('\n');
|
source.push('\n');
|
||||||
|
|
||||||
Command::new("shfmt")
|
Command::new("shfmt")
|
||||||
.args(["-d", "-s", "-ln", "bash", "-i", "4", "-ci", "-"])
|
.args(["--diff", "--indent=4", "--language-dialect=bash", "--simplify", "-"])
|
||||||
.write_stdin(source)
|
.write_stdin(source)
|
||||||
.assert()
|
.assert()
|
||||||
.success()
|
.success()
|
||||||
|
|
@ -96,13 +96,11 @@ mod tests {
|
||||||
#[apply(opts)]
|
#[apply(opts)]
|
||||||
fn elvish_elvish(cmd: Option<&str>, hook: InitHook, echo: bool, resolve_symlinks: bool) {
|
fn elvish_elvish(cmd: Option<&str>, hook: InitHook, echo: bool, resolve_symlinks: bool) {
|
||||||
let opts = Opts { cmd, hook, echo, resolve_symlinks };
|
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
|
// Filter out lines using edit:*, since those functions are only available in
|
||||||
// the interactive editor.
|
// the interactive editor.
|
||||||
for line in
|
for line in Elvish(&opts).render().unwrap().lines().filter(|line| !line.contains("edit:")) {
|
||||||
Elvish(&opts).render().unwrap().split('\n').filter(|line| !line.contains("edit:"))
|
|
||||||
{
|
|
||||||
source.push_str(line);
|
source.push_str(line);
|
||||||
source.push('\n');
|
source.push('\n');
|
||||||
}
|
}
|
||||||
|
|
@ -218,7 +216,7 @@ mod tests {
|
||||||
source.push('\n');
|
source.push('\n');
|
||||||
|
|
||||||
Command::new("shfmt")
|
Command::new("shfmt")
|
||||||
.args(["-d", "-s", "-ln", "posix", "-i", "4", "-ci", "-"])
|
.args(["--diff", "--indent=4", "--language-dialect=posix", "--simplify", "-"])
|
||||||
.write_stdin(source)
|
.write_stdin(source)
|
||||||
.assert()
|
.assert()
|
||||||
.success()
|
.success()
|
||||||
|
|
|
||||||
10
src/util.rs
10
src/util.rs
|
|
@ -35,6 +35,8 @@ impl Fzf {
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
let program = "fzf";
|
let program = "fzf";
|
||||||
|
|
||||||
|
// TODO: check version of fzf here.
|
||||||
|
|
||||||
let mut cmd = Command::new(program);
|
let mut cmd = Command::new(program);
|
||||||
cmd.args([
|
cmd.args([
|
||||||
// Search mode
|
// Search mode
|
||||||
|
|
@ -133,7 +135,7 @@ impl FzfChild {
|
||||||
mem::drop(self.0.stdin.take());
|
mem::drop(self.0.stdin.take());
|
||||||
|
|
||||||
let mut stdout = self.0.stdout.take().unwrap();
|
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")?;
|
stdout.read_to_string(&mut output).context("failed to read from fzf")?;
|
||||||
|
|
||||||
let status = self.0.wait().context("wait failed on fzf")?;
|
let status = self.0.wait().context("wait failed on fzf")?;
|
||||||
|
|
@ -158,7 +160,7 @@ pub fn write(path: impl AsRef<Path>, contents: impl AsRef<[u8]>) -> Result<()> {
|
||||||
let (mut tmp_file, tmp_path) = tmpfile(dir)?;
|
let (mut tmp_file, tmp_path) = tmpfile(dir)?;
|
||||||
let result = (|| {
|
let result = (|| {
|
||||||
// Write to the tmpfile.
|
// Write to the tmpfile.
|
||||||
let _ = tmp_file.set_len(contents.len() as u64);
|
_ = tmp_file.set_len(contents.len() as u64);
|
||||||
tmp_file
|
tmp_file
|
||||||
.write_all(contents)
|
.write_all(contents)
|
||||||
.with_context(|| format!("could not write to file: {}", tmp_path.display()))?;
|
.with_context(|| format!("could not write to file: {}", tmp_path.display()))?;
|
||||||
|
|
@ -173,7 +175,7 @@ pub fn write(path: impl AsRef<Path>, contents: impl AsRef<[u8]>) -> Result<()> {
|
||||||
|
|
||||||
let uid = Uid::from_raw(metadata.uid());
|
let uid = Uid::from_raw(metadata.uid());
|
||||||
let gid = Gid::from_raw(metadata.gid());
|
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.
|
// Close and rename the tmpfile.
|
||||||
|
|
@ -182,7 +184,7 @@ pub fn write(path: impl AsRef<Path>, contents: impl AsRef<[u8]>) -> Result<()> {
|
||||||
})();
|
})();
|
||||||
// In case of an error, delete the tmpfile.
|
// In case of an error, delete the tmpfile.
|
||||||
if result.is_err() {
|
if result.is_err() {
|
||||||
let _ = fs::remove_file(&tmp_path);
|
_ = fs::remove_file(&tmp_path);
|
||||||
}
|
}
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ function __zoxide_z() {
|
||||||
__zoxide_cd "${OLDPWD}"
|
__zoxide_cd "${OLDPWD}"
|
||||||
elif [[ $# -eq 1 && -d $1 ]]; then
|
elif [[ $# -eq 1 && -d $1 ]]; then
|
||||||
__zoxide_cd "$1"
|
__zoxide_cd "$1"
|
||||||
elif [[ ${@: -1} == "${__zoxide_z_prefix}"* ]]; then
|
elif [[ ${@: -1} == "${__zoxide_z_prefix}"?* ]]; then
|
||||||
# shellcheck disable=SC2124
|
# shellcheck disable=SC2124
|
||||||
\builtin local result="${@: -1}"
|
\builtin local result="${@: -1}"
|
||||||
__zoxide_cd "{{ "${result:${#__zoxide_z_prefix}}" }}"
|
__zoxide_cd "{{ "${result:${#__zoxide_z_prefix}}" }}"
|
||||||
|
|
@ -90,7 +90,7 @@ function __zoxide_z() {
|
||||||
# Jump to a directory using interactive search.
|
# Jump to a directory using interactive search.
|
||||||
function __zoxide_zi() {
|
function __zoxide_zi() {
|
||||||
\builtin local result
|
\builtin local result
|
||||||
result="$(\command zoxide query -i -- "$@")" && __zoxide_cd "${result}"
|
result="$(\command zoxide query --interactive -- "$@")" && __zoxide_cd "${result}"
|
||||||
}
|
}
|
||||||
|
|
||||||
{{ section }}
|
{{ 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
|
\builtin compgen -A directory -- "${COMP_WORDS[-1]}" || \builtin true
|
||||||
)
|
)
|
||||||
# If there is a space after the last word, use interactive selection.
|
# 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
|
\builtin local result
|
||||||
# shellcheck disable=SC2312
|
# 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}/")
|
COMPREPLY=("${__zoxide_z_prefix}${result}/")
|
||||||
\builtin printf '\e[5n'
|
\builtin printf '\e[5n'
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ edit:add-var __zoxide_z~ $__zoxide_z~
|
||||||
fn __zoxide_zi {|@rest|
|
fn __zoxide_zi {|@rest|
|
||||||
var path
|
var path
|
||||||
try {
|
try {
|
||||||
set path = (zoxide query -i -- $@rest)
|
set path = (zoxide query --interactive -- $@rest)
|
||||||
} catch {
|
} catch {
|
||||||
} else {
|
} else {
|
||||||
__zoxide_cd $path
|
__zoxide_cd $path
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@ end
|
||||||
|
|
||||||
# A copy of fish's internal cd function. This makes it possible to use
|
# A copy of fish's internal cd function. This makes it possible to use
|
||||||
# `alias cd=z` without causing an infinite loop.
|
# `alias cd=z` without causing an infinite loop.
|
||||||
if ! builtin functions -q __zoxide_cd_internal
|
if ! builtin functions --query __zoxide_cd_internal
|
||||||
if builtin functions -q cd
|
if builtin functions --query cd
|
||||||
builtin functions -c cd __zoxide_cd_internal
|
builtin functions --copy cd __zoxide_cd_internal
|
||||||
else
|
else
|
||||||
alias __zoxide_cd_internal='builtin cd'
|
alias __zoxide_cd_internal='builtin cd'
|
||||||
end
|
end
|
||||||
|
|
@ -62,20 +62,21 @@ end
|
||||||
# When using zoxide with --no-cmd, alias these internal functions as desired.
|
# 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.
|
# Jump to a directory using only keywords.
|
||||||
function __zoxide_z
|
function __zoxide_z
|
||||||
set -l argc (count $argv)
|
set -l argc (count $argv)
|
||||||
set -l completion_regex '^'(string escape --style=regex $__zoxide_z_prefix)'(.*)$'
|
|
||||||
|
|
||||||
if test $argc -eq 0
|
if test $argc -eq 0
|
||||||
__zoxide_cd $HOME
|
__zoxide_cd $HOME
|
||||||
else if test "$argv" = -
|
else if test "$argv" = -
|
||||||
__zoxide_cd -
|
__zoxide_cd -
|
||||||
else if test $argc -eq 1 -a -d $argv[1]
|
else if test $argc -eq 1 -a -d $argv[1]
|
||||||
__zoxide_cd $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
|
__zoxide_cd $result
|
||||||
else
|
else
|
||||||
set -l result (command zoxide query --exclude (__zoxide_pwd) -- $argv)
|
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 test (count $tokens) -le 2 -a (count $curr_tokens) -eq 1
|
||||||
# If there are < 2 arguments, use `cd` completions.
|
# If there are < 2 arguments, use `cd` completions.
|
||||||
__fish_complete_directories "$tokens[2]" ''
|
complete --do-complete "'' "(commandline --cut-at-cursor --current-token) | string match --regex '.*/$'
|
||||||
else if test (count $tokens) -eq (count $curr_tokens)
|
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, use interactive selection.
|
# 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 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
|
and echo $__zoxide_z_prefix$result
|
||||||
commandline --function repaint
|
commandline --function repaint
|
||||||
end
|
end
|
||||||
|
|
@ -103,7 +105,7 @@ complete --command __zoxide_z --no-files --arguments '(__zoxide_z_complete)'
|
||||||
|
|
||||||
# Jump to a directory using interactive search.
|
# Jump to a directory using interactive search.
|
||||||
function __zoxide_zi
|
function __zoxide_zi
|
||||||
set -l result (command zoxide query -i -- $argv)
|
set -l result (command zoxide query --interactive -- $argv)
|
||||||
and __zoxide_cd $result
|
and __zoxide_cd $result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -131,5 +133,3 @@ alias {{cmd}}i=__zoxide_zi
|
||||||
# ~/.config/fish/config.fish):
|
# ~/.config/fish/config.fish):
|
||||||
#
|
#
|
||||||
# zoxide init fish | source
|
# zoxide init fish | source
|
||||||
#
|
|
||||||
# Note: zoxide only supports fish v3.4.0 and above.
|
|
||||||
|
|
|
||||||
|
|
@ -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 | default {} config).config
|
||||||
let-env config = ($env.config | default {} hooks)
|
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 ($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
|
zoxide add -- $env.PWD
|
||||||
}))
|
}))
|
||||||
{%- else if hook == InitHook::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.
|
# Jump to a directory using only keywords.
|
||||||
def-env __zoxide_z [...rest:string] {
|
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 arg0 = ($rest | append '~').0
|
||||||
let path = if (($rest | length) <= 1) and ($arg0 == '-' or ($arg0 | path expand | path type) == dir) {
|
let path = if (($rest | length) <= 1) and ($arg0 == '-' or ($arg0 | path expand | path type) == dir) {
|
||||||
$arg0
|
$arg0
|
||||||
|
|
@ -55,7 +54,7 @@ def-env __zoxide_z [...rest:string] {
|
||||||
|
|
||||||
# Jump to a directory using interactive search.
|
# Jump to a directory using interactive search.
|
||||||
def-env __zoxide_zi [...rest:string] {
|
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 %}
|
{%- if echo %}
|
||||||
echo $env.PWD
|
echo $env.PWD
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ __zoxide_z() {
|
||||||
|
|
||||||
# Jump to a directory using interactive search.
|
# Jump to a directory using interactive search.
|
||||||
__zoxide_zi() {
|
__zoxide_zi() {
|
||||||
__zoxide_result="$(\command zoxide query -i -- "$@")" && __zoxide_cd "${__zoxide_result}"
|
__zoxide_result="$(\command zoxide query --interactive -- "$@")" && __zoxide_cd "${__zoxide_result}"
|
||||||
}
|
}
|
||||||
|
|
||||||
{{ section }}
|
{{ section }}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,15 @@ function __zoxide_cd($dir, $literal) {
|
||||||
$dir = if ($literal) {
|
$dir = if ($literal) {
|
||||||
Set-Location -LiteralPath $dir -Passthru -ErrorAction Stop
|
Set-Location -LiteralPath $dir -Passthru -ErrorAction Stop
|
||||||
} else {
|
} 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 %}
|
{%- if echo %}
|
||||||
Write-Output $dir.Path
|
Write-Output $dir.Path
|
||||||
|
|
@ -41,6 +49,15 @@ function __zoxide_cd($dir, $literal) {
|
||||||
# Hook configuration for zoxide.
|
# 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.
|
# Hook to add new entries to the database.
|
||||||
function __zoxide_hook {
|
function __zoxide_hook {
|
||||||
$result = __zoxide_pwd
|
$result = __zoxide_pwd
|
||||||
|
|
@ -48,37 +65,34 @@ function __zoxide_hook {
|
||||||
zoxide add -- $result
|
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 hook.
|
||||||
{#-
|
$__zoxide_hooked = (Get-Variable __zoxide_hooked -ErrorAction SilentlyContinue -ValueOnly)
|
||||||
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)
|
|
||||||
if ($__zoxide_hooked -ne 1) {
|
if ($__zoxide_hooked -ne 1) {
|
||||||
$__zoxide_hooked = 1
|
$__zoxide_hooked = 1
|
||||||
{%- match hook %}
|
$__zoxide_prompt_old = $function:prompt
|
||||||
{%- when InitHook::None %}
|
|
||||||
{{ not_configured }}
|
|
||||||
{%- when InitHook::Prompt %}
|
|
||||||
$prompt_old = $function:prompt
|
|
||||||
function prompt {
|
function prompt {
|
||||||
$null = __zoxide_hook
|
if ($null -ne $__zoxide_prompt_old) {
|
||||||
& $prompt_old
|
& $__zoxide_prompt_old
|
||||||
}
|
|
||||||
{%- when InitHook::Pwd %}
|
|
||||||
if ($PSVersionTable.PSVersion.Major -ge 6) {
|
|
||||||
$ExecutionContext.InvokeCommand.LocationChangedAction = {
|
|
||||||
$null = __zoxide_hook
|
|
||||||
}
|
}
|
||||||
|
$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 }}
|
{{ section }}
|
||||||
# When using zoxide with --no-cmd, alias these internal functions as desired.
|
# When using zoxide with --no-cmd, alias these internal functions as desired.
|
||||||
|
|
@ -89,12 +103,12 @@ function __zoxide_z {
|
||||||
if ($args.Length -eq 0) {
|
if ($args.Length -eq 0) {
|
||||||
__zoxide_cd ~ $true
|
__zoxide_cd ~ $true
|
||||||
}
|
}
|
||||||
elseif (
|
elseif ($args.Length -eq 1 -and ($args[0] -eq '-' -or $args[0] -eq '+')) {
|
||||||
$args.Length -eq 1 -and
|
|
||||||
(($args[0] -eq '-' -or $args[0] -eq '+') -or (Test-Path $args[0] -PathType Container))
|
|
||||||
) {
|
|
||||||
__zoxide_cd $args[0] $false
|
__zoxide_cd $args[0] $false
|
||||||
}
|
}
|
||||||
|
elseif ($args.Length -eq 1 -and (Test-Path $args[0] -PathType Container)) {
|
||||||
|
__zoxide_cd $args[0] $true
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
$result = __zoxide_pwd
|
$result = __zoxide_pwd
|
||||||
if ($null -ne $result) {
|
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
|
# To initialize zoxide, add this to your configuration (find it by running
|
||||||
# `echo $profile` in PowerShell):
|
# `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) })
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ function __zoxide_z() {
|
||||||
__zoxide_cd ~
|
__zoxide_cd ~
|
||||||
elif [[ "$#" -eq 1 ]] && { [[ -d "$1" ]] || [[ "$1" = '-' ]] || [[ "$1" =~ ^[-+][0-9]$ ]]; }; then
|
elif [[ "$#" -eq 1 ]] && { [[ -d "$1" ]] || [[ "$1" = '-' ]] || [[ "$1" =~ ^[-+][0-9]$ ]]; }; then
|
||||||
__zoxide_cd "$1"
|
__zoxide_cd "$1"
|
||||||
elif [[ "$@[-1]" == "${__zoxide_z_prefix}"* ]]; then
|
elif [[ "$@[-1]" == "${__zoxide_z_prefix}"?* ]]; then
|
||||||
# shellcheck disable=SC2124
|
# shellcheck disable=SC2124
|
||||||
\builtin local result="${@[-1]}"
|
\builtin local result="${@[-1]}"
|
||||||
__zoxide_cd "{{ "${result:${#__zoxide_z_prefix}}" }}"
|
__zoxide_cd "{{ "${result:${#__zoxide_z_prefix}}" }}"
|
||||||
|
|
@ -76,7 +76,7 @@ function __zoxide_z() {
|
||||||
# Jump to a directory using interactive search.
|
# Jump to a directory using interactive search.
|
||||||
function __zoxide_zi() {
|
function __zoxide_zi() {
|
||||||
\builtin local result
|
\builtin local result
|
||||||
result="$(\command zoxide query -i -- "$@")" && __zoxide_cd "${result}"
|
result="$(\command zoxide query --interactive -- "$@")" && __zoxide_cd "${result}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Completions.
|
# Completions.
|
||||||
|
|
@ -88,10 +88,10 @@ if [[ -o zle ]]; then
|
||||||
|
|
||||||
if [[ "{{ "${#words[@]}" }}" -eq 2 ]]; then
|
if [[ "{{ "${#words[@]}" }}" -eq 2 ]]; then
|
||||||
_files -/
|
_files -/
|
||||||
elif [[ "${words[-1]}" == '' ]]; then
|
elif [[ "${words[-1]}" == '' ]] && [[ "${words[-2]}" != "${__zoxide_z_prefix}"?* ]]; then
|
||||||
\builtin local result
|
\builtin local result
|
||||||
# shellcheck disable=SC2086,SC2312
|
# 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}"
|
result="${__zoxide_z_prefix}${result}"
|
||||||
# shellcheck disable=SC2296
|
# shellcheck disable=SC2296
|
||||||
compadd -Q "${(q-)result}"
|
compadd -Q "${(q-)result}"
|
||||||
|
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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));
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue