mirror of
https://github.com/starship/starship.git
synced 2026-06-23 02:05:51 +07:00
feat: Add support for the ion shell (#704)
This commit is contained in:
committed by
Matan Kushner
parent
835ecc3ae6
commit
93701b26b3
+8
-1
@@ -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");
|
||||
|
||||
@@ -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"
|
||||
+1
-1
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user