diff options
author | BuggStream <buggstream@tuta.io> | 2019-12-11 21:31:30 +0100 |
---|---|---|
committer | Matan Kushner <hello@matchai.me> | 2019-12-11 15:31:30 -0500 |
commit | 93701b26b38b5f9102f150be5344f2e93170d25f (patch) | |
tree | 4176798865d41aa55369b53e301d8be1ba697472 /src/init | |
parent | 835ecc3ae6c5d01c6e04d1cc77179e0529e697fc (diff) |
feat: Add support for the ion shell (#704)
Diffstat (limited to 'src/init')
-rw-r--r-- | src/init/mod.rs | 9 | ||||
-rw-r--r-- | src/init/starship.ion | 15 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/init/mod.rs b/src/init/mod.rs index 73f91a832..0e826b5d2 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 000000000..5d9ef4f33 --- /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" |