Add default prompt for nushell (#191)

This commit is contained in:
Ajeet D'Souza 2021-04-27 17:37:38 +05:30
parent 7d9ca0de43
commit 0f5fde5afa
11 changed files with 55 additions and 54 deletions

View File

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- Manpages for each subcommand. - Manpages for each subcommand.
- Default prompt for Nushell.
### Fixed ### Fixed

View File

@ -107,7 +107,7 @@ zoxide import --from autojump path/to/db
#### `bash` #### `bash`
Add the following line to your configuration file (usually `~/.bashrc`): Add this to your configuration (usually `~/.bashrc`):
```sh ```sh
eval "$(zoxide init bash)" eval "$(zoxide init bash)"
@ -115,7 +115,7 @@ eval "$(zoxide init bash)"
#### `elvish` #### `elvish`
Add the following line to your configuration file (usually `~/.elvish/rc.elv`): Add this to your configuration (usually `~/.elvish/rc.elv`):
```sh ```sh
eval $(zoxide init elvish | slurp) eval $(zoxide init elvish | slurp)
@ -123,8 +123,7 @@ eval $(zoxide init elvish | slurp)
#### `fish` #### `fish`
Add the following line to your configuration file (usually Add this to your configuration (usually `~/.config/fish/config.fish`):
`~/.config/fish/config.fish`):
```fish ```fish
zoxide init fish | source zoxide init fish | source
@ -138,16 +137,18 @@ Initialize zoxide's Nushell script:
zoxide init nushell --hook prompt | save ~/.zoxide.nu zoxide init nushell --hook prompt | save ~/.zoxide.nu
``` ```
Then, in your Nushell configuration file: Add this to your configuration (usually `~/.config/nu/config.toml`):
- Prepend `__zoxide_hook;` to the `prompt` variable. ```toml
- Add the following lines to the `startup` variable: prompt = "__zoxide_hook;__zoxide_prompt"
- `zoxide init nushell --hook prompt | save ~/.zoxide.nu` startup = ["zoxide init nushell --hook prompt | save ~/.zoxide.nu", "source ~/.zoxide.nu"]
- `source ~/.zoxide.nu` ```
You can replace `__zoxide_prompt` with a custom prompt.
#### `powershell` #### `powershell`
Add the following line to your profile: Add this to your configuration (the location is stored in `$profile`):
```powershell ```powershell
Invoke-Expression (& { Invoke-Expression (& {
@ -158,7 +159,7 @@ Invoke-Expression (& {
#### `xonsh` #### `xonsh`
Add the following line to your configuration file (usually `~/.xonshrc`): Add this to your configuration (usually `~/.xonshrc`):
```python ```python
execx($(zoxide init xonsh), 'exec', __xonsh__.ctx, filename='zoxide') execx($(zoxide init xonsh), 'exec', __xonsh__.ctx, filename='zoxide')
@ -166,7 +167,7 @@ execx($(zoxide init xonsh), 'exec', __xonsh__.ctx, filename='zoxide')
#### `zsh` #### `zsh`
Add the following line to your configuration file (usually `~/.zshrc`): Add this to your configuration (usually `~/.zshrc`):
```sh ```sh
eval "$(zoxide init zsh)" eval "$(zoxide init zsh)"
@ -174,8 +175,7 @@ eval "$(zoxide init zsh)"
#### Any POSIX shell #### Any POSIX shell
Add the following line to your configuration file (usually Add this to your configuration:
`~/.config/nu/config.toml`):
```sh ```sh
eval "$(zoxide init posix --hook prompt)" eval "$(zoxide init posix --hook prompt)"

View File

@ -7,49 +7,44 @@ zoxide-init - generate shell configuration for zoxide
To initialize zoxide on your shell: To initialize zoxide on your shell:
.TP .TP
.B bash .B bash
Add the following line to your configuration file (usually \fI~/.bashrc\fR): Add this to your configuration (usually \fI~/.bashrc\fR):
.sp .sp
.nf .nf
\fBeval "$(zoxide init bash)"\fR \fBeval "$(zoxide init bash)"\fR
.fi .fi
.TP .TP
.B elvish .B elvish
Add the following line to your configuration file (usually Add this to your configuration (usually \fI~/.elvish/rc.elv\fR):
\fI~/.elvish/rc.elv\fR):
.sp .sp
.nf .nf
\fBeval $(zoxide init elvish | slurp)\fR \fBeval $(zoxide init elvish | slurp)\fR
.fi .fi
.TP .TP
.B fish .B fish
Add the following line to your configuration file (usually Add this to your configuration (usually \fI~/.config/fish/config.fish\fR):
\fI~/.config/fish/config.fish\fR):
.sp .sp
.nf .nf
\fBzoxide init fish | source\fR \fBzoxide init fish | source\fR
.fi .fi
.TP .TP
.B nushell .B nushell
Initialize zoxide's Nushell script: Create a Nushell script:
.sp .sp
.nf .nf
\fBzoxide init nushell --hook prompt | save ~/.zoxide.nu\fR \fBzoxide init nushell --hook prompt | save ~/.zoxide.nu\fR
.fi .fi
.sp .sp
Then, in your Nushell configuration file (usually Add this to your configuration (usually \fI~/.config/nu/config.toml\fR):
\fI~/.config/nu/config.toml\fR):
.sp
* Prepend \fB__zoxide_hook;\fR to the \fBprompt\fR variable.
.sp
* Add the following lines to the \fBstartup\fR variable:
.sp .sp
.nf .nf
\fBzoxide init nushell --hook prompt | save ~/.zoxide.nu \fBprompt = "__zoxide_hook;__zoxide_prompt"\fR
source ~/.zoxide.nu\fR \fBstartup = ["zoxide init nushell --hook prompt | save ~/.zoxide.nu", "source ~/.zoxide.nu"]\fR
.fi .fi
.sp
You can replace \fB__zoxide_prompt\fR with a custom prompt.
.TP .TP
.B powershell .B powershell
Add the following line to your profile: Add this to your configuration (the location is stored in \fI$profile\fR):
.sp .sp
.nf .nf
\fBInvoke-Expression (& { \fBInvoke-Expression (& {
@ -59,14 +54,14 @@ Add the following line to your profile:
.fi .fi
.TP .TP
.B xonsh .B xonsh
Add the following line to your configuration file (usually \fI~/.xonshrc\fR): Add this to your configuration (usually \fI~/.xonshrc\fR):
.sp .sp
.nf .nf
\fBexecx($(zoxide init xonsh), 'exec', __xonsh__.ctx, filename='zoxide')\fR \fBexecx($(zoxide init xonsh), 'exec', __xonsh__.ctx, filename='zoxide')\fR
.fi .fi
.TP .TP
.B zsh .B zsh
Add the following line to your configuration file (usually \fI~/.zshrc\fR): Add this to your configuration (usually \fI~/.zshrc\fR):
.sp .sp
.nf .nf
\fBeval "$(zoxide init zsh)"\fR \fBeval "$(zoxide init zsh)"\fR
@ -74,7 +69,7 @@ Add the following line to your configuration file (usually \fI~/.zshrc\fR):
.TP .TP
.B Any POSIX shell .B Any POSIX shell
.sp .sp
Add the following line to your configuration file: Add this to your configuration:
.sp .sp
.nf .nf
\fBeval "$(zoxide init posix --hook prompt)"\fR \fBeval "$(zoxide init posix --hook prompt)"\fR

View File

@ -120,7 +120,6 @@ function {{cmd}}i() {
{%- endmatch %} {%- endmatch %}
{{ section }} {{ section }}
# To initialize zoxide with bash, add the following line to your bash # To initialize zoxide, add this to your configuration (usually ~/.bashrc):
# configuration file (usually ~/.bashrc):
# #
# eval "$(zoxide init bash)" # eval "$(zoxide init bash)"

View File

@ -80,7 +80,7 @@ edit:add-var zi~ $__zoxide_zi~
{%- endmatch %} {%- endmatch %}
{{ section }} {{ section }}
# To initialize zoxide with xonsh, add the following line to your elvish # To initialize zoxide, add this to your configuration (usually
# configuration file (usually ~/.elvish/rc.elv): # ~/.elvish/rc.elv):
# #
# eval $(zoxide init elvish | slurp) # eval $(zoxide init elvish | slurp)

View File

@ -104,7 +104,7 @@ end
{%- endmatch %} {%- endmatch %}
{{ section }} {{ section }}
# To initialize zoxide with fish, add the following line to your fish # To initialize zoxide, add this to your configuration (usually
# configuration file (usually ~/.config/fish/config.fish): # ~/.config/fish/config.fish):
# #
# zoxide init fish | source # zoxide init fish | source

View File

@ -1,6 +1,16 @@
{%- let section = "# =============================================================================\n#" -%} {%- let section = "# =============================================================================\n#" -%}
{%- let not_configured = "# -- not configured --" -%} {%- let not_configured = "# -- not configured --" -%}
{{ section }}
# Utility functions for zoxide.
#
# Default prompt for Nushell.
# Taken from: <https://github.com/nushell/nushell/blob/main/docs/sample_config/config.toml>
def __zoxide_prompt [] {
build-string $(ansi gb) $(pwd) $(ansi reset) '(' $(ansi cb) $(do -i { git rev-parse --abbrev-ref HEAD } | str trim) $(ansi reset) ')' $(ansi yb) $(date format '%m/%d/%Y %I:%M:%S%.3f %p') $(ansi reset) '> '
}
{{ section }} {{ section }}
# Hook configuration for zoxide. # Hook configuration for zoxide.
# #
@ -79,14 +89,13 @@ alias {{cmd}}i = __zoxide_zi ''
{%- endmatch %} {%- endmatch %}
{{ section }} {{ section }}
# To initialize zoxide with Nushell: # To initialize zoxide, first create a Nushell script:
#
# Initialize zoxide's Nushell script:
# #
# zoxide init nushell --hook prompt | save ~/.zoxide.nu # zoxide init nushell --hook prompt | save ~/.zoxide.nu
# #
# Then, in your Nushell configuration file: # Add this to your configuration (usually ~/.config/nu/config.toml):
# - Prepend `__zoxide_hook;` to the `prompt` variable. #
# - Add the following lines to the `startup` variable: # prompt = "__zoxide_hook;__zoxide_prompt"
# - `zoxide init nushell --hook prompt | save ~/.zoxide.nu` # startup = ["zoxide init nushell --hook prompt | save ~/.zoxide.nu", "source ~/.zoxide.nu"]
# - `source ~/.zoxide.nu` #
# You can replace __zoxide_prompt with a custom prompt.

View File

@ -115,7 +115,6 @@ __zoxide_unset '{{cmd}}i'
{%- endmatch %} {%- endmatch %}
{{ section }} {{ section }}
# To initialize zoxide with your POSIX shell, add the following line to your # To initialize zoxide, add this to your configuration:
# shell configuration file:
# #
# eval "$(zoxide init posix --hook prompt)" # eval "$(zoxide init posix --hook prompt)"

View File

@ -101,7 +101,7 @@ Set-Alias {{cmd}}i __zoxide_zi
{%- endmatch %} {%- endmatch %}
{{ section }} {{ section }}
# To initialize zoxide with powershell, add the following line to your # To initialize zoxide, add this to your configuration (the location is stored
# powershell configuration file (the location is stored in $profile): # in $profile):
# #
# Invoke-Expression (& { $hook = if ($PSVersionTable.PSVersion.Major -ge 6) { 'pwd' } else { 'prompt' } (zoxide init powershell --hook $hook) -join "`n" }) # Invoke-Expression (& { $hook = if ($PSVersionTable.PSVersion.Major -ge 6) { 'pwd' } else { 'prompt' } (zoxide init powershell --hook $hook) -join "`n" })

View File

@ -163,7 +163,6 @@ aliases["{{cmd}}i"] = __zoxide_zi
{%- endmatch %} {%- endmatch %}
{{ section }} {{ section }}
# To initialize zoxide with xonsh, add the following line to your xonsh # To initialize zoxide, add this to your configuration (usually ~/.xonshrc):
# configuration file (usually ~/.xonshrc):
# #
# execx($(zoxide init xonsh), 'exec', __xonsh__.ctx, filename='zoxide') # execx($(zoxide init xonsh), 'exec', __xonsh__.ctx, filename='zoxide')

View File

@ -105,7 +105,6 @@ function {{cmd}}i() {
{%- endmatch %} {%- endmatch %}
{{ section }} {{ section }}
# To initialize zoxide with zsh, add the following line to your zsh # To initialize zoxide, add this to your configuration (usually ~/.zshrc):
# configuration file (usually ~/.zshrc):
# #
# eval "$(zoxide init zsh)" # eval "$(zoxide init zsh)"