mirror of
https://github.com/starship/starship.git
synced 2025-01-23 06:39:47 +01:00
stuff
This commit is contained in:
parent
b108d03bcc
commit
eff714d784
@ -174,6 +174,11 @@ pub fn init_stub(shell_name: &str) -> io::Result<()> {
|
||||
r#"eval `({} init tcsh --print-full-init)`"#,
|
||||
starship.sprint_posix()?
|
||||
),
|
||||
"mksh" => print!(
|
||||
r#"eval "$({} init mksh --print-full-init)""#,
|
||||
starship.sprint_posix()?
|
||||
),
|
||||
|
||||
"nu" => print_script(NU_INIT, &StarshipPath::init()?.sprint()?),
|
||||
"xonsh" => print!(
|
||||
r#"execx($({} init xonsh --print-full-init))"#,
|
||||
@ -194,6 +199,7 @@ pub fn init_stub(shell_name: &str) -> io::Result<()> {
|
||||
* nu\n\
|
||||
* xonsh\n\
|
||||
* cmd\n\
|
||||
* mksh\n\
|
||||
\n\
|
||||
Please open an issue in the starship repo if you would like to \
|
||||
see support for {shell_basename}:\n\
|
||||
@ -211,6 +217,7 @@ pub fn init_main(shell_name: &str) -> io::Result<()> {
|
||||
|
||||
match shell_name {
|
||||
"bash" => print_script(BASH_INIT, &starship_path.sprint_posix()?),
|
||||
"mksh" => print_script(MKSH_INIT, &starship_path.sprint_posix()?),
|
||||
"zsh" => print_script(ZSH_INIT, &starship_path.sprint_posix()?),
|
||||
"fish" => print_script(FISH_INIT, &starship_path.sprint_posix()?),
|
||||
"powershell" => print_script(PWSH_INIT, &starship_path.sprint_pwsh()?),
|
||||
@ -250,7 +257,7 @@ starship binary.
|
||||
*/
|
||||
|
||||
const BASH_INIT: &str = include_str!("starship.bash");
|
||||
|
||||
const MKSH_INIT: &str = include_str!("starship.mksh");
|
||||
const ZSH_INIT: &str = include_str!("starship.zsh");
|
||||
|
||||
const FISH_INIT: &str = include_str!("starship.fish");
|
||||
|
39
src/init/starship.mksh
Normal file
39
src/init/starship.mksh
Normal file
@ -0,0 +1,39 @@
|
||||
|
||||
# Define a function to capture time in milliseconds
|
||||
__starship_get_time() {
|
||||
STARSHIP_CAPTURED_TIME=$(date +%s%3N) # Using date command for compatibility
|
||||
}
|
||||
|
||||
# Function to calculate command duration and manage prompt variables
|
||||
prompt_starship_precmd() {
|
||||
STARSHIP_CMD_STATUS=$? # Save last command status
|
||||
|
||||
# Calculate duration if STARSHIP_START_TIME is set
|
||||
if [ -n "$STARSHIP_START_TIME" ]; then
|
||||
__starship_get_time
|
||||
STARSHIP_DURATION=$((STARSHIP_CAPTURED_TIME - STARSHIP_START_TIME))
|
||||
unset STARSHIP_START_TIME
|
||||
else
|
||||
unset STARSHIP_DURATION STARSHIP_CMD_STATUS
|
||||
fi
|
||||
|
||||
# MKSH does not support jobstates array directly, simplifying jobs count
|
||||
STARSHIP_JOBS_COUNT=$(jobs | wc -l)
|
||||
}
|
||||
|
||||
# Function to set start time before executing a command
|
||||
prompt_starship_preexec() {
|
||||
__starship_get_time && STARSHIP_START_TIME=$STARSHIP_CAPTURED_TIME
|
||||
}
|
||||
|
||||
# Setup prompt
|
||||
PS1='$(::STARSHIP:: prompt --terminal-width="$COLUMNS" --status="$STARSHIP_CMD_STATUS" --cmd-duration="${STARSHIP_DURATION:-}") '
|
||||
|
||||
# Export necessary variables
|
||||
export STARSHIP_SHELL="mksh"
|
||||
|
||||
# Simplified session key generation
|
||||
STARSHIP_SESSION_KEY=$(od -vAn -N4 -tu4 < /dev/urandom); export STARSHIP_SESSION_KEY=${STARSHIP_SESSION_KEY:0:16};
|
||||
|
||||
VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||
|
Loading…
Reference in New Issue
Block a user