Skip to content

Commit

Permalink
feat: Add support for the ion shell (starship#704)
Browse files Browse the repository at this point in the history
  • Loading branch information
BuggStream authored and matchai committed Dec 11, 2019
1 parent 835ecc3 commit 93701b2
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 5 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).
Expand Down
6 changes: 3 additions & 3 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"}],
],
Expand Down
5 changes: 5 additions & 0 deletions install/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
"
9 changes: 8 additions & 1 deletion src/init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand All @@ -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
Expand All @@ -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\
Expand Down Expand Up @@ -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");
15 changes: 15 additions & 0 deletions src/init/starship.ion
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 93701b2

Please sign in to comment.