feat: Add support for the ion shell (#704)

This commit is contained in:
BuggStream 2019-12-11 21:31:30 +01:00 committed by Matan Kushner
parent 835ecc3ae6
commit 93701b26b3
6 changed files with 42 additions and 5 deletions

View File

@ -192,6 +192,16 @@ The prompt shows information you need while you're working, while staying sleek
Invoke-Expression (&starship init powershell) Invoke-Expression (&starship init powershell)
``` ```
#### Ion
Add the following to the end of `~/.config/ion/initrc`:
```sh
# ~/.config/ion/initrc
eval $(starship init ion)
```
## 🔧 Configuration ## 🔧 Configuration
For details on how to configure Starship, check out our [documentation](https://starship.rs/config/). For details on how to configure Starship, check out our [documentation](https://starship.rs/config/).

View File

@ -19,15 +19,15 @@ module.exports = {
// prettier-ignore // prettier-ignore
head: [ head: [
["link", { rel: "icon", href: "/icon.png" }], ["link", { rel: "icon", href: "/icon.png" }],
["meta", { name: "description", content: "Starship is the minimal, blazing fast, and extremely customizable prompt for any shell! Shows the information you need, while staying sleek and minimal. Quick installation available for Bash, Fish, ZSH, and Powershell." }], ["meta", { name: "description", content: "Starship is the minimal, blazing fast, and extremely customizable prompt for any shell! Shows the information you need, while staying sleek and minimal. Quick installation available for Bash, Fish, ZSH, Ion, and Powershell." }],
["meta", { property: "og:title", content: "Starship: Cross-Shell Prompt" }], ["meta", { property: "og:title", content: "Starship: Cross-Shell Prompt" }],
["meta", { property: "og:description", content: "Starship is the minimal, blazing fast, and extremely customizable prompt for any shell! Shows the information you need, while staying sleek and minimal. Quick installation available for Bash, Fish, ZSH, and Powershell."}], ["meta", { property: "og:description", content: "Starship is the minimal, blazing fast, and extremely customizable prompt for any shell! Shows the information you need, while staying sleek and minimal. Quick installation available for Bash, Fish, ZSH, Ion, and Powershell."}],
["meta", { property: "og:type", content: "website" }], ["meta", { property: "og:type", content: "website" }],
["meta", { property: "og:url", content: "https://starship.rs/" }], ["meta", { property: "og:url", content: "https://starship.rs/" }],
["meta", { property: "og:image", content: "https://starship.rs/icon.png" }], ["meta", { property: "og:image", content: "https://starship.rs/icon.png" }],
["meta", { name: "twitter:card", content: "summary"}], ["meta", { name: "twitter:card", content: "summary"}],
["meta", { name: "twitter:title", content: "Starship: Cross-Shell Prompt"}], ["meta", { name: "twitter:title", content: "Starship: Cross-Shell Prompt"}],
["meta", { name: "twitter:description", content: "Starship is the minimal, blazing fast, and extremely customizable prompt for any shell! Shows the information you need, while staying sleek and minimal. Quick installation available for Bash, Fish, ZSH, and Powershell.Starship is the minimal, blazing fast, and extremely customizable prompt for any shell! Shows the information you need, while staying sleek and minimal. Quick installation available for Bash, Fish, ZSH, and Powershell."}], ["meta", { name: "twitter:description", content: "Starship is the minimal, blazing fast, and extremely customizable prompt for any shell! Shows the information you need, while staying sleek and minimal. Quick installation available for Bash, Fish, ZSH, Ion, and Powershell."}],
["meta", { name: "twitter:image", content: "https://starship.rs/icon.png"}], ["meta", { name: "twitter:image", content: "https://starship.rs/icon.png"}],
["meta", { name: "twitter:alt", content: "Starship: Cross-Shell Prompt"}], ["meta", { name: "twitter:alt", content: "Starship: Cross-Shell Prompt"}],
], ],

View File

@ -261,4 +261,9 @@ info "Please follow the steps for your shell to complete the installation:
eval \"\$(starship init zsh)\" eval \"\$(starship init zsh)\"
${BOLD}${UNDERLINE}Ion${NO_COLOR}
Add the following to the end of ${BOLD}~/.config/ion/initrc${NO_COLOR}:
eval $(starship init ion)
" "

View File

@ -109,6 +109,10 @@ fi"#,
); );
Some(script) Some(script)
} }
Some("ion") => {
let script = format!("eval $({} init ion --print-full-init)", starship);
Some(script)
}
None => { None => {
println!( println!(
"Invalid shell name provided: {}\\n\ "Invalid shell name provided: {}\\n\
@ -122,7 +126,7 @@ fi"#,
Some(shell_basename) => { Some(shell_basename) => {
println!( println!(
"printf \"\\n{0} is not yet supported by starship.\\n\ "printf \"\\n{0} is not yet supported by starship.\\n\
For the time being, we support bash, zsh, and fish.\\n\ For the time being, we support bash, zsh, fish, and ion.\\n\
Please open an issue in the starship repo if you would like to \ Please open an issue in the starship repo if you would like to \
see support for {0}:\\nhttps://github.com/starship/starship/issues/new\"\\n\\n", see support for {0}:\\nhttps://github.com/starship/starship/issues/new\"\\n\\n",
shell_basename shell_basename
@ -146,6 +150,7 @@ pub fn init_main(shell_name: &str) -> io::Result<()> {
"zsh" => Some(ZSH_INIT), "zsh" => Some(ZSH_INIT),
"fish" => Some(FISH_INIT), "fish" => Some(FISH_INIT),
"powershell" => Some(PWSH_INIT), "powershell" => Some(PWSH_INIT),
"ion" => Some(ION_INIT),
_ => { _ => {
println!( println!(
"printf \"Shell name detection failed on phase two init.\\n\ "printf \"Shell name detection failed on phase two init.\\n\
@ -186,3 +191,5 @@ const ZSH_INIT: &str = include_str!("starship.zsh");
const FISH_INIT: &str = include_str!("starship.fish"); const FISH_INIT: &str = include_str!("starship.fish");
const PWSH_INIT: &str = include_str!("starship.ps1"); const PWSH_INIT: &str = include_str!("starship.ps1");
const ION_INIT: &str = include_str!("starship.ion");

15
src/init/starship.ion Normal file
View File

@ -0,0 +1,15 @@
# The PROMPT function is called whenever a prompt needs to be drawn. Docs: https://doc.redox-os.org/ion-manual/html/misc/06-prompt_fn.html
fn PROMPT
# Save the status immediately, since the status is also updated after variable assignment, etc.
let STARSHIP_ION_STATUS = $?
# Save the ION_CMD_DURATION before running any other commands, but after the status since the
# duration is not updated during variable assignment
let STARSHIP_ION_CMD_DURATION = $ION_CMD_DURATION
# The STARSHIP between the colons will be replaced with the actual path to the starship executable.
# The jobs command outputs to stderr, therefore we need to pipe stderr to `wc -l`.
::STARSHIP:: prompt --status $STARSHIP_ION_STATUS --jobs $(jobs ^| wc -l) --cmd-duration $STARSHIP_ION_CMD_DURATION
end
# Export the correct name of the shell
export STARSHIP_SHELL="ion"

View File

@ -34,7 +34,7 @@ fn main() {
let shell_arg = Arg::with_name("shell") let shell_arg = Arg::with_name("shell")
.value_name("SHELL") .value_name("SHELL")
.help( .help(
"The name of the currently running shell\nCurrently supported options: bash, zsh, fish, powershell", "The name of the currently running shell\nCurrently supported options: bash, zsh, fish, powershell, ion",
) )
.required(true); .required(true);