bakks/butterfish

Would be nice to have some kind of indicator that you're in shell mode, Or...

Closed this issue · 6 comments

...at least a quick way to query if you're in shell mode

bakks commented

I was thinking this as well - I was considering replacing the shell prompt (e.g. the > or $) with an indicator, maybe 🐠 for fun. Is that the kind of thing you're thinking of? Open to suggestions here.

I think it's a great idea. You can actually change my shell prompt from your go binary? That's beyond cool!

I think if they're going to run your wrapped shell you pretty much have license to manipulate anybody's prompt, I'd just want to preserve my current path inside it (mostly every prompt has this today right?).

I would want to control my prompt myself. Maybe you can offer the bash or zsh functions that the user can include in their brash prompt if they so choose.

The way I do it is the following:

function butterfish_shell {
	[[ $BUTTERFISH_SHELL == "true" ]] && echo -ne " 🐠 "
}

    local FIRST_LINE="......  \${K8S_CONTEXT} \$(butterfish_shell)"
    PS1=${TERM_RESET}${PS1_START_MARK}${TERM_TITLE}${FIRST_LINE}${SECOND_LINE}${REGULAR_TEXT}${COMMAND_START_MARK}

Then start butterfish with BUTTERFISH_SHELL=true butterfish shell

If anything, a standard env var that butterfish sets itself would make my config more generic.

bakks commented

Ahh, @DavidGamba a standard env var is a great idea. This is a helpful discussion, I will play around and get something working.

bakks commented

Added related commits:

Let me summarize what I've done:

  • By default, butterfish will append "🐠 " to your PS1, meaning it will show up on the command line at each prompt. You can execute with -p '' if you don't want anything appended, e.g. butterfish shell -p ''.
  • We now set BUTTERFISH_SHELL as an env var, so you can detect this in your .profile (or whatever shell config). If BUTTERFISH_SHELL is set then it will exit rather than wrapping the shell twice.
  • You can now run Status as a prompt, which will print out the current shell configuration, e.g. which models you're currently using.

I will package this in a new release soon!

bakks commented

This is released in v0.0.31, please update and let me know what you think!