Skip to content

Commit

Permalink
feat: add fish function for changing working directory on quit (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
uncenter authored Oct 12, 2023
1 parent c2c719b commit fda01dc
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion usage/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.

<Tabs>
<TabItem value="bash-zsh" label="Bash / Zsh" default>

```bash
function ya() {
Expand All @@ -135,3 +141,35 @@ function ya() {
rm -f -- "$tmp"
}
```

</TabItem>
<TabItem value="fish" label="Fish">

```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
```
</TabItem>
<TabItem value="nushell" label="Nushell">
```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
}
```
</TabItem>
</Tabs>

0 comments on commit fda01dc

Please sign in to comment.