From fda01dcef2994ba236390abfe491b59d2f2c747c Mon Sep 17 00:00:00 2001 From: uncenter <47499684+uncenter@users.noreply.github.com> Date: Thu, 12 Oct 2023 10:20:14 -0400 Subject: [PATCH] feat: add fish function for changing working directory on quit (#3) --- usage/quick-start.md | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/usage/quick-start.md b/usage/quick-start.md index 167cd715..aacd265e 100644 --- a/usage/quick-start.md +++ b/usage/quick-start.md @@ -2,6 +2,9 @@ sidebar_position: 2 --- +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + # Quick Start After [installing](./installation.md), use the following command to run it: @@ -123,7 +126,10 @@ _Observation: `, ⇒ a` indicates pressing the `,` key followed by pressing the ## Changing working directory when exiting Yazi -There is a wrapper of Yazi, that provides the ability to change the current working directory when exiting Yazi, feel free to use it: +You can also use this convenient wrapper that provides the ability to change the current working directory when exiting Yazi. + + + ```bash function ya() { @@ -135,3 +141,35 @@ function ya() { rm -f -- "$tmp" } ``` + + + + +```shell +function ya + set tmp (mktemp -t "yazi-cwd.XXXXX") + yazi --cwd-file="$tmp" + if set cwd (cat -- "$tmp"); and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ] + cd -- "$cwd" + end + rm -f -- "$tmp" +end +``` + + + + +```shell +def-env ya [] { + let tmp = (mktemp -t "yazi-cwd.XXXXX") + yazi --cwd-file $tmp + let cwd = (cat -- $tmp) + if $cwd != "" and $cwd != $env.PWD { + cd $cwd + } + rm -f $tmp +} +``` + + +