mozilla-aws-cli icon indicating copy to clipboard operation
mozilla-aws-cli copied to clipboard

Prompt improvements, primarily for zsh users

Open floatingatoll opened this issue 3 years ago • 1 comments

I've been having some issues with the prompts set by maws on my macOS install, and so today I worked out what they are and improved prompt handling in the script. I've done limited testing of this on zsh and will be collecting additional reviews and testing now that I've reached a stable point. The changelog additions for this pull request are:

Fixed

  • Enable zsh dynamic prompts for users who don't already have them enabled.
  • Fix issues with double-whitespace when injecting into space-separated prompts

Changed

  • Convert conditionals to bash-native to simplify maintenance and readability
  • Add internal logic to allow more complex prefix/suffix whitespace logic
  • Remove blank lines and code comments when printing bash/zsh script

Added

  • Allow users to disable prompt modification with MAWS_PROMPT_DISABLE=1. (This also lets users implement their own custom prompts without forking, as long as they define function maws_profile () { } in bashrc/zshrc.)

floatingatoll avatar Jun 15 '21 21:06 floatingatoll

I've had these changes live on my workstation for the past four weeks with no issues, on macOS zsh with ktx and maws and correct whitespace:

source "$HOME"/ktx/ktx
function maws_profile () {} # overwritten on first run of maws

# disable maws prompt rewriting, and set the prefix/suffix to match my prompt
export MAWS_PROMPT_DISABLE=1
export MAWS_PROMPT_PREFIX=' '
export MAWS_PROMPT_SUFFIX=''

# DIY my own prompt for ktx + maws
export PS1='%1~/$(maws_profile) $( [[ -n $KUBECONFIG ]] && echo -n "[${KUBECONFIG##*/}] " )%# '
setopt prompt_subst

floatingatoll avatar Jul 12 '21 16:07 floatingatoll