diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..83a0a0b --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +contrib/completions/* linguist-generated=true +contrib/completions/README.md linguist-generated=false diff --git a/README.md b/README.md index b4afc8f..9c6732d 100644 --- a/README.md +++ b/README.md @@ -3,23 +3,35 @@ "code_blocks": false, "tables": false }, - "MD033": false + "MD033": false, + "MD041": false } --> +
+ # zoxide [![crates.io][crates.io-badge]][crates.io] [![Downloads][downloads-badge]][releases] [![Built with Nix][builtwithnix-badge]][builtwithnix] -zoxide is a smarter cd command, inspired by z and autojump. It keeps track of -the directories you use most frequently, and uses a ranking algorithm to -navigate to the best match. +zoxide is a **smarter cd command**, inspired by z and autojump. + +It remembers which directories you use most frequently, so you can "jump" to +them in just a few keystrokes.
+zoxide works on all major shells. + +[Getting started](#getting-started) • +[Installation](#installation) • +[Configuration](#configuration) • +[Integrations](#third-party-integrations) + +
+ +## Getting started ![Tutorial][tutorial] -## Examples - ```sh z foo # cd into highest ranked directory matching foo z foo bar # cd into highest ranked directory matching foo and bar @@ -34,7 +46,7 @@ zi foo # cd with interactive selection (using fzf) Read more about the matching algorithm [here][algorithm-matching]. -## Getting started +## Installation ### *Step 1: Install zoxide* @@ -137,7 +149,7 @@ To install zoxide, use a package manager: To start using zoxide, add it to your shell.
-bash +Bash Add this to your configuration (usually `~/.bashrc`): @@ -148,7 +160,7 @@ eval "$(zoxide init bash)"
-elvish +Elvish Add this to your configuration (usually `~/.elvish/rc.elv`): @@ -161,7 +173,7 @@ Note: zoxide only supports elvish v0.16.0 and above.
-fish +Fish Add this to your configuration (usually `~/.config/fish/config.fish`): @@ -172,7 +184,7 @@ zoxide init fish | source
-nushell +Nushell Add this to your configuration (find it by running `config path` in Nushell): @@ -185,7 +197,7 @@ Note: zoxide only supports Nushell v0.37.0 and above.
-powershell +PowerShell Add this to your configuration (find it by running `echo $profile` in PowerShell): @@ -200,7 +212,7 @@ Invoke-Expression (& {
-xonsh +Xonsh Add this to your configuration (usually `~/.xonshrc`): @@ -211,7 +223,7 @@ execx($(zoxide init xonsh), 'exec', __xonsh__.ctx, filename='zoxide')
-zsh +Zsh Add this to your configuration (usually `~/.zshrc`): @@ -222,7 +234,7 @@ eval "$(zoxide init zsh)"
-any POSIX shell +Any POSIX shell Add this to your configuration: diff --git a/contrib/completions/README.md b/contrib/completions/README.md index 2de3803..50c00dd 100644 --- a/contrib/completions/README.md +++ b/contrib/completions/README.md @@ -1,8 +1,6 @@ # completions -Shell completions for zoxide, auto-generated by [`clap`][clap]. - -Since `clap` itself is in beta at the moment, these completions should not be -treated as stable either. +Shell completions for zoxide, generated by [clap]. Since clap is in beta, these +completions should not be treated as stable. [clap]: https://github.com/clap-rs/clap diff --git a/src/app/_app.rs b/src/app/_app.rs index ec33a91..e40e3e7 100644 --- a/src/app/_app.rs +++ b/src/app/_app.rs @@ -4,7 +4,7 @@ use clap::{AppSettings, ArgEnum, Parser, ValueHint}; const ENV_HELP: &str = "ENVIRONMENT VARIABLES: _ZO_DATA_DIR Path for zoxide data files - _ZO_ECHO Prints the matched directory before navigating to it when set to 1 + _ZO_ECHO Print the matched directory before navigating to it when set to 1 _ZO_EXCLUDE_DIRS List of directory globs to be excluded _ZO_FZF_OPTS Custom flags to pass to fzf _ZO_MAXAGE Maximum total age after which entries start getting deleted diff --git a/src/shell.rs b/src/shell.rs index ae44243..aed2bee 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -286,7 +286,7 @@ mod tests { let opts = Opts { cmd, hook, echo, resolve_symlinks }; let source = Xonsh(&opts).render().unwrap(); - Command::new("mypy").args(&["--command", &source]).assert().success().stderr(""); + Command::new("mypy").args(&["--command", &source, "--strict"]).assert().success().stderr(""); } #[rstest] diff --git a/templates/xonsh.txt b/templates/xonsh.txt index 522f2be..e08afa8 100644 --- a/templates/xonsh.txt +++ b/templates/xonsh.txt @@ -8,7 +8,7 @@ import os import os.path import subprocess import sys -from typing import AnyStr, Dict, List, Optional +import typing import xonsh.dirstack # type: ignore # pylint: disable=import-error import xonsh.environ # type: ignore # pylint: disable=import-error @@ -20,13 +20,13 @@ import xonsh.environ # type: ignore # pylint: disable=import-error def __zoxide_bin() -> str: """Finds and returns the location of the zoxide binary.""" - zoxide = xonsh.environ.locate_binary("zoxide") + zoxide = typing.cast(str, xonsh.environ.locate_binary("zoxide")) if zoxide is None: zoxide = "zoxide" return zoxide -def __zoxide_env() -> Dict[str, str]: +def __zoxide_env() -> typing.Dict[str, str]: """Returns the current environment.""" return builtins.__xonsh__.env.detype() # type: ignore # pylint:disable=no-member @@ -43,7 +43,7 @@ def __zoxide_pwd() -> str: return pwd -def __zoxide_cd(path: Optional[AnyStr] = None): +def __zoxide_cd(path: typing.Optional[typing.AnyStr] = None) -> None: """cd + custom logic based on the value of _ZO_ECHO.""" if path is None: args = [] @@ -63,10 +63,12 @@ class ZoxideSilentException(Exception): """Exit without complaining.""" -def __zoxide_errhandler(func): +def __zoxide_errhandler( + func: typing.Callable[[typing.List[str]], None] +) -> typing.Callable[[typing.List[str]], int]: """Print exception and exit with error code 1.""" - def wrapper(args: List[str]): + def wrapper(args: typing.List[str]) -> int: try: func(args) return 0 @@ -94,7 +96,7 @@ if "__zoxide_hook" not in globals(): {%- else if hook == InitHook::Pwd %} @builtins.events.on_chdir # type: ignore # pylint:disable=no-member {%- endif %} - def __zoxide_hook(**_kwargs): + def __zoxide_hook(**_kwargs: typing.Any) -> None: """Hook to add new entries to the database.""" pwd = __zoxide_pwd() zoxide = __zoxide_bin() @@ -114,7 +116,7 @@ if "__zoxide_hook" not in globals(): @__zoxide_errhandler -def __zoxide_z(args: List[str]): +def __zoxide_z(args: typing.List[str]) -> None: """Jump to a directory using only keywords.""" if args == []: __zoxide_cd() @@ -139,7 +141,7 @@ def __zoxide_z(args: List[str]): @__zoxide_errhandler -def __zoxide_zi(args: List[str]): +def __zoxide_zi(args: typing.List[str]) -> None: """Jump to a directory using interactive search.""" try: zoxide = __zoxide_bin()