From 93701b26b38b5f9102f150be5344f2e93170d25f Mon Sep 17 00:00:00 2001 From: BuggStream Date: Wed, 11 Dec 2019 21:31:30 +0100 Subject: [PATCH] feat: Add support for the ion shell (#704) --- README.md | 10 ++++++++++ docs/.vuepress/config.js | 6 +++--- install/install.sh | 5 +++++ src/init/mod.rs | 9 ++++++++- src/init/starship.ion | 15 +++++++++++++++ src/main.rs | 2 +- 6 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 src/init/starship.ion diff --git a/README.md b/README.md index 8560c2e3..77506ea7 100644 --- a/README.md +++ b/README.md @@ -192,6 +192,16 @@ The prompt shows information you need while you're working, while staying sleek 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 For details on how to configure Starship, check out our [documentation](https://starship.rs/config/). diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 385c1af2..92988cc7 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -19,15 +19,15 @@ module.exports = { // prettier-ignore head: [ ["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: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:url", content: "https://starship.rs/" }], ["meta", { property: "og:image", content: "https://starship.rs/icon.png" }], ["meta", { name: "twitter:card", content: "summary"}], ["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:alt", content: "Starship: Cross-Shell Prompt"}], ], diff --git a/install/install.sh b/install/install.sh index b03fcd15..94b87e43 100755 --- a/install/install.sh +++ b/install/install.sh @@ -261,4 +261,9 @@ info "Please follow the steps for your shell to complete the installation: 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) + " diff --git a/src/init/mod.rs b/src/init/mod.rs index 73f91a83..0e826b5d 100644 --- a/src/init/mod.rs +++ b/src/init/mod.rs @@ -109,6 +109,10 @@ fi"#, ); Some(script) } + Some("ion") => { + let script = format!("eval $({} init ion --print-full-init)", starship); + Some(script) + } None => { println!( "Invalid shell name provided: {}\\n\ @@ -122,7 +126,7 @@ fi"#, Some(shell_basename) => { println!( "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 \ see support for {0}:\\nhttps://github.com/starship/starship/issues/new\"\\n\\n", shell_basename @@ -146,6 +150,7 @@ pub fn init_main(shell_name: &str) -> io::Result<()> { "zsh" => Some(ZSH_INIT), "fish" => Some(FISH_INIT), "powershell" => Some(PWSH_INIT), + "ion" => Some(ION_INIT), _ => { println!( "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 PWSH_INIT: &str = include_str!("starship.ps1"); + +const ION_INIT: &str = include_str!("starship.ion"); diff --git a/src/init/starship.ion b/src/init/starship.ion new file mode 100644 index 00000000..5d9ef4f3 --- /dev/null +++ b/src/init/starship.ion @@ -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" diff --git a/src/main.rs b/src/main.rs index 66c60745..cc7e0a51 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,7 +34,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", + "The name of the currently running shell\nCurrently supported options: bash, zsh, fish, powershell, ion", ) .required(true);