mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-12-01 01:04:00 +00:00
feat: add support for elvish shell (#1725)
* feat: add support for elvish shell * improve doc * elvish 0.15 is out * fix example init * update systax for 0.15 stable * udpate second init example too * remove warning from swift module * add warning to status module docs * prefix elvish version with v
This commit is contained in:
parent
10d5a7034b
commit
22dc8b842e
11
README.md
11
README.md
@ -224,6 +224,17 @@ shown below. Can't see yours? Have a look at the [extra platform instructions](h
|
||||
eval $(starship init ion)
|
||||
```
|
||||
|
||||
#### Elvish
|
||||
|
||||
**Warning** Only elvish v0.15 or higher is supported.
|
||||
Add the following to the end of `~/.elvish/rc.elv`:
|
||||
|
||||
```sh
|
||||
# ~/.elvish/rc.elv
|
||||
|
||||
eval (starship init elvish)
|
||||
```
|
||||
|
||||
## 🤝 Contributing
|
||||
|
||||
We are always looking for contributors of **all skill levels**! If you're looking to ease your way into the project, try out a [good first issue](https://github.com/starship/starship/labels/🌱%20good%20first%20issue).
|
||||
|
@ -101,3 +101,17 @@ description: Starship is the minimal, blazing fast, and extremely customizable p
|
||||
|
||||
eval $(starship init ion)
|
||||
```
|
||||
#### Elvish
|
||||
|
||||
::: warning
|
||||
Only elvish v0.15 or higher is supported.
|
||||
:::
|
||||
|
||||
Add the following to the end of `~/.elvish/rc.elv`:
|
||||
|
||||
```sh
|
||||
# ~/.elvish/rc.elv
|
||||
|
||||
eval (starship init elvish)
|
||||
```
|
||||
|
||||
|
@ -388,6 +388,10 @@ can do this in two ways:
|
||||
|
||||
By default it only changes color. If you also want to change it's shape take a
|
||||
look at [this example](#with-custom-error-shape).
|
||||
|
||||
::: warning
|
||||
`error_symbol` is not supported on elvish shell.
|
||||
:::
|
||||
|
||||
### Options
|
||||
|
||||
@ -2263,6 +2267,10 @@ To enable it, set `disabled` to `false` in your configuration file.
|
||||
|
||||
:::
|
||||
|
||||
::: warning
|
||||
This module is not supported on elvish shell.
|
||||
:::
|
||||
|
||||
### Options
|
||||
|
||||
| Option | Default | Description |
|
||||
|
@ -203,6 +203,7 @@ fn get_config_path(shell: &str) -> Option<PathBuf> {
|
||||
}
|
||||
}
|
||||
"zsh" => Some(".zshrc"),
|
||||
"elvish" => Some(".elvish/rc.elv"),
|
||||
_ => None,
|
||||
}
|
||||
.map(|path| home_dir.join(path))
|
||||
|
@ -208,6 +208,7 @@ impl<'a> Context<'a> {
|
||||
"ion" => Shell::Ion,
|
||||
"powershell" => Shell::PowerShell,
|
||||
"zsh" => Shell::Zsh,
|
||||
"elvish" => Shell::Elvish,
|
||||
_ => Shell::Unknown,
|
||||
}
|
||||
}
|
||||
@ -426,6 +427,7 @@ pub enum Shell {
|
||||
Ion,
|
||||
PowerShell,
|
||||
Zsh,
|
||||
Elvish,
|
||||
Unknown,
|
||||
}
|
||||
|
||||
|
@ -166,6 +166,13 @@ fi"#,
|
||||
let script = format!("eval $({} init ion --print-full-init)", starship.sprint()?);
|
||||
Some(script)
|
||||
}
|
||||
Some("elvish") => {
|
||||
let script = format!(
|
||||
"eval ({} init elvish --print-full-init | slurp)",
|
||||
starship.sprint_posix()?
|
||||
);
|
||||
Some(script)
|
||||
}
|
||||
None => {
|
||||
println!(
|
||||
"Invalid shell name provided: {}\\n\
|
||||
@ -204,6 +211,7 @@ pub fn init_main(shell_name: &str) -> io::Result<()> {
|
||||
"fish" => print_script(FISH_INIT, &starship_path.sprint_posix()?),
|
||||
"powershell" => print_script(PWSH_INIT, &starship_path.sprint()?),
|
||||
"ion" => print_script(ION_INIT, &starship_path.sprint()?),
|
||||
"elvish" => print_script(ELVISH_INIT, &starship_path.sprint_posix()?),
|
||||
_ => {
|
||||
println!(
|
||||
"printf \"Shell name detection failed on phase two init.\\n\
|
||||
@ -245,3 +253,5 @@ const FISH_INIT: &str = include_str!("starship.fish");
|
||||
const PWSH_INIT: &str = include_str!("starship.ps1");
|
||||
|
||||
const ION_INIT: &str = include_str!("starship.ion");
|
||||
|
||||
const ELVISH_INIT: &str = include_str!("starship.elv");
|
||||
|
33
src/init/starship.elv
Normal file
33
src/init/starship.elv
Normal file
@ -0,0 +1,33 @@
|
||||
set-env STARSHIP_SHELL "elvish"
|
||||
set-env STARSHIP_SESSION_KEY (::STARSHIP:: session)
|
||||
|
||||
# Define Hooks
|
||||
local:cmd-start-time = 0
|
||||
local:cmd-end-time = 0
|
||||
|
||||
fn starship-after-readline-hook [line]{
|
||||
cmd-start-time = (::STARSHIP:: time)
|
||||
}
|
||||
|
||||
fn starship-before-readline-hook {
|
||||
cmd-end-time = (::STARSHIP:: time)
|
||||
}
|
||||
|
||||
# Install Hooks
|
||||
edit:after-readline = [ $@edit:after-readline $starship-after-readline-hook~ ]
|
||||
edit:before-readline = [ $@edit:before-readline $starship-before-readline-hook~ ]
|
||||
|
||||
# Install starship
|
||||
edit:prompt = {
|
||||
# Note:
|
||||
# Elvish does not appear to support exit status codes (--status)
|
||||
|
||||
if (== $cmd-start-time 0) {
|
||||
::STARSHIP:: prompt --jobs=$num-bg-jobs
|
||||
} else {
|
||||
::STARSHIP:: prompt --jobs=$num-bg-jobs --cmd-duration=(- $cmd-end-time $cmd-start-time)
|
||||
}
|
||||
}
|
||||
|
||||
# Get rid of default rprompt
|
||||
edit:rprompt = { }
|
@ -31,7 +31,7 @@ fn main() {
|
||||
let shell_arg = Arg::with_name("shell")
|
||||
.value_name("SHELL")
|
||||
.help(
|
||||
"The name of the currently running shell\nCurrently supported options: bash, zsh, fish, powershell, ion",
|
||||
"The name of the currently running shell\nCurrently supported options: bash, zsh, fish, powershell, ion, elvish",
|
||||
)
|
||||
.required(true);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user