From fbf4c0165b00116891c07a3eb6dc7af0260c202c Mon Sep 17 00:00:00 2001 From: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> Date: Mon, 24 Mar 2025 01:54:22 +0100 Subject: [PATCH] Quick refactor Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> --- docs/cheatsheet/examples/example.cheat | 6 -- docs/cheatsheet/examples/navi.cheat | 44 ---------- .../examples/config_file_example.yaml | 39 --------- docs/{utilisation => usage}/README.md | 0 .../shell-scripting/README.md | 80 +++++++++---------- 5 files changed, 40 insertions(+), 129 deletions(-) delete mode 100644 docs/cheatsheet/examples/example.cheat delete mode 100644 docs/cheatsheet/examples/navi.cheat delete mode 100644 docs/configuration/examples/config_file_example.yaml rename docs/{utilisation => usage}/README.md (100%) rename docs/{utilisation => usage}/shell-scripting/README.md (96%) diff --git a/docs/cheatsheet/examples/example.cheat b/docs/cheatsheet/examples/example.cheat deleted file mode 100644 index 2b22f55..0000000 --- a/docs/cheatsheet/examples/example.cheat +++ /dev/null @@ -1,6 +0,0 @@ -% first cheat - -# print something -echo "My name is !" - -$ name: whoami diff --git a/docs/cheatsheet/examples/navi.cheat b/docs/cheatsheet/examples/navi.cheat deleted file mode 100644 index 0e68698..0000000 --- a/docs/cheatsheet/examples/navi.cheat +++ /dev/null @@ -1,44 +0,0 @@ -% cheatsheets - -# Download default cheatsheets -navi repo add denisidoro/cheats - -# Browse for cheatsheet repos -navi repo browse - -# Edit main local cheatsheets -f="$(navi info cheats-path)/main.cheat" -[ -f "$f" ] || navi info cheats-example > "$f" -${EDITOR:-nano} "$f" - - -% config - -# Edit config file -f="$(navi info config-path)" -[ -f "$f" ] || navi info config-example > "$f" -${EDITOR:-nano} "$f" - - -% 3rd-party - -# Search using tldr -navi --tldr "" - -# Search using cheatsh -navi --cheatsh "" - - -% widget - -# Load shell widget -shell="$(basename $SHELL)"; eval "$(navi widget $shell)" - - -% help - -# Read command-line help text -navi --help - -# Read project README.md -navi fn url::open "https://github.com/denisidoro/navi" diff --git a/docs/configuration/examples/config_file_example.yaml b/docs/configuration/examples/config_file_example.yaml deleted file mode 100644 index ae2706f..0000000 --- a/docs/configuration/examples/config_file_example.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# THIS IS EXPERIMENTAL -# the config file schema may change at any time - -style: - tag: - color: cyan # text color. possible values: https://bit.ly/3gloNNI - width_percentage: 26 # column width relative to the terminal window - min_width: 20 # minimum column width as number of characters - comment: - color: blue - width_percentage: 42 - min_width: 45 - snippet: - color: white - -finder: - command: fzf # equivalent to the --finder option - # overrides: --tac # equivalent to the --fzf-overrides option - # overrides_var: --tac # equivalent to the --fzf-overrides-var option - # delimiter_var: \s\s+ # equivalent to the --delimiter option that is used with --column option when you extract a column from the selected result for a variable - -# cheats: -# paths: -# - /path/to/some/dir # on unix-like os -# - F:\\path\\to\\dir # on Windows -# path: /path/to/some/dir # (DEPRECATED) equivalent to the --path option - -# search: -# tags: git,!checkout # equivalent to the --tag-rules option - -# client: -# tealdeer: true # enables tealdeer support for navi --tldr - -shell: - # Shell used for shell out. Possible values: bash, zsh, dash, ... - # For Windows, use `cmd.exe` instead. - command: bash - - # finder_command: bash # similar, but for fzf's internals diff --git a/docs/utilisation/README.md b/docs/usage/README.md similarity index 100% rename from docs/utilisation/README.md rename to docs/usage/README.md diff --git a/docs/utilisation/shell-scripting/README.md b/docs/usage/shell-scripting/README.md similarity index 96% rename from docs/utilisation/shell-scripting/README.md rename to docs/usage/shell-scripting/README.md index 83eb136..5a90ec8 100644 --- a/docs/utilisation/shell-scripting/README.md +++ b/docs/usage/shell-scripting/README.md @@ -1,40 +1,40 @@ -## Using it for shell scripting - -For a real world scenario example, please check this [blog post](https://denisidoro.github.io/posts/cli-templates/). - -Let's say you want to write a bash script that, among other things, asks the user to write the name of a git branch that should be checked out. - -If you already have the [cheatsheet above](#cheatsheet-syntax), then you could write the following in your script: - -```sh -navi --query "change branch" --best-match -``` - -**navi** will ask the user to fill all arguments needed. - -If you want to set the `` beforehand in your script: - -```sh -branch="master" navi --query "change branch" --best-match -``` - -- no interactive input will be shown -- the value for `` will be exactly the one passed as argument - -If you want to filter some results for ``: - -```sh -branch__query="master" navi --query "change branch" --best-match -``` - -- an interactive input will be shown, unless a single entry is autoselected -- the value for `` will be the one selected - -If you want to select the best match for ``: - -```sh -branch__best="master" navi --query "change branch" --best-match -``` - -- no interactive input will be shown -- the value for `` will be the one that best matches the one passed as argument +## Using it for shell scripting + +For a real world scenario example, please check this [blog post](https://denisidoro.github.io/posts/cli-templates/). + +Let's say you want to write a bash script that, among other things, asks the user to write the name of a git branch that should be checked out. + +If you already have the [cheatsheet above](#cheatsheet-syntax), then you could write the following in your script: + +```sh +navi --query "change branch" --best-match +``` + +**navi** will ask the user to fill all arguments needed. + +If you want to set the `` beforehand in your script: + +```sh +branch="master" navi --query "change branch" --best-match +``` + +- no interactive input will be shown +- the value for `` will be exactly the one passed as argument + +If you want to filter some results for ``: + +```sh +branch__query="master" navi --query "change branch" --best-match +``` + +- an interactive input will be shown, unless a single entry is autoselected +- the value for `` will be the one selected + +If you want to select the best match for ``: + +```sh +branch__best="master" navi --query "change branch" --best-match +``` + +- no interactive input will be shown +- the value for `` will be the one that best matches the one passed as argument