Skip to content

Commit

Permalink
Use PROMPT_STRING environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ajeetdsouza committed Aug 31, 2021
1 parent 3ca89d0 commit 9ff8993
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 36 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Changed

- Nushell: upgrade minimum supported version to v0.36.0.
- Nushell: easier installation instructions.

### Fixed

- Elvish: unable to `z` into directories by path.
- Elvish: don't show traceback when `z` or `zi` fails.
- Elvish: nested shells do not initialize correctly.

## [0.7.4] - 2020-08-15

Expand Down
44 changes: 22 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ rand = { version = "0.8.4", features = [
], default-features = false }

[dev-dependencies]
assert_cmd = "1.0.1"
assert_cmd = "2.0.0"
rstest = "0.11.0"

[build-dependencies]
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Add this to your configuration (usually `~/.elvish/rc.elv`):
eval (zoxide init elvish | slurp)
```

Note that zoxide only supports elvish v0.16.0+.
Note: zoxide only supports elvish v0.16.0 and above.

</details>

Expand All @@ -172,12 +172,10 @@ zoxide init fish | source
Add this to your configuration (find it by running `config path` in Nushell):

```toml
prompt = "__zoxide_hook;__zoxide_prompt"
startup = ["zoxide init nushell --hook prompt | save ~/.zoxide.nu", "source ~/.zoxide.nu"]
```

You can replace `__zoxide_prompt` with a custom prompt. Note that zoxide only
supports Nushell v0.33.0+.
Note: zoxide only supports Nushell v0.36.0 and above.

</details>

Expand Down
7 changes: 4 additions & 3 deletions man/zoxide-init.1
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Add this to your configuration (usually \fI~/.elvish/rc.elv\fR):
.nf
\fBeval $(zoxide init elvish | slurp)\fR
.fi
Note: zoxide only supports elvish v0.16.0 and above.
.TP
.B fish
Add this to your configuration (usually \fI~/.config/fish/config.fish\fR):
Expand All @@ -32,14 +33,14 @@ Add this to your configuration (find it by running \fBconfig path\fR in
Nushell):
.sp
.nf
\fBprompt = "__zoxide_hook;__zoxide_prompt"\fR
\fBstartup = ["zoxide init nushell --hook prompt | save ~/.zoxide.nu", "source ~/.zoxide.nu"]\fR
.fi
.sp
You can replace \fB__zoxide_prompt\fR with a custom prompt.
Note: zoxide only supports Nushell v0.36.0 and above.
.TP
.B powershell
Add this to your configuration (find it with \fIecho $profile\fR):
Add this to your configuration (find it by running \fBecho $profile\fR in
PowerShell):
.sp
.nf
\fBInvoke-Expression (& {
Expand Down
2 changes: 1 addition & 1 deletion templates/elvish.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ edit:add-var zi~ $__zoxide_zi~
#
# eval (zoxide init elvish | slurp)
#
# Note that zoxide only supports elvish v0.16.0 and above.
# Note: zoxide only supports elvish v0.16.0 and above.
18 changes: 13 additions & 5 deletions templates/nushell.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,25 @@ def __zoxide_prompt [] {
# Hook to add new entries to the database.
{%- match hook %}
{%- when InitHook::None %}
def __zoxide_hook [] {}
{{ not_configured }}

{%- when InitHook::Prompt %}
def __zoxide_hook [] {
shells | where active == $true && name == filesystem | get path | each { zoxide add -- $it }
}

# Initialize hook.
if ($nu.env | select PROMPT_STRING | empty?) {
if ($nu.config | select prompt | empty?) {
let-env PROMPT_STRING = '__zoxide_hook;__zoxide_prompt'
} {
let-env PROMPT_STRING = $'__zoxide_hook;($nu.config.prompt)'
}
} {
let-env PROMPT_STRING = $'__zoxide_hook;($nu.env.PROMPT_STRING)'
}

{%- when InitHook::Pwd %}
def __zoxide_hook [] {}
$'zoxide: PWD hooks are not supported on Nushell.(char nl)Use (char sq)zoxide init nushell --hook prompt(char sq) instead.(char nl)'
{%- endmatch %}

Expand Down Expand Up @@ -98,8 +108,6 @@ alias {{cmd}}i = __zoxide_zi
# To initialize zoxide, add this to your configuration (find it by running
# `config path` in Nushell):
#
# prompt = '__zoxide_hook;__zoxide_prompt'
# startup = ['zoxide init nushell --hook prompt | save ~/.zoxide.nu', 'source ~/.zoxide.nu']
#
# You can replace __zoxide_prompt with a custom prompt. Note that zoxide only
# supports Nushell v0.33.0+.
# Note: zoxide only supports Nushell v0.36.0 and above.

0 comments on commit 9ff8993

Please sign in to comment.