Comment by skydhash

Comment by skydhash 17 hours ago

0 replies

Here is mine as an example. I started with oh-my-zsh, then moved to bash and just keep the basic information I need.

  # Simple prompt
  function set_bash_prompt {
    status=$?
    container=""
    if test -f /run/.containerenv; then
      container="($(cat /run/.containerenv | grep name | cut -d\" -f2)) "
    fi
    if test $status -eq 0 ; then
        # Last command succeeded, set prompt to green
        PS1="\[\e[0;32m\]"
    else
        # Last command failed, set prompt to red
        PS1="\[\e[0;31m\]"
    fi
    PS1+="$container\w \$ \[\e[0m\]"
  }

  if [ -n "$SSH_CONNECTION" ]; then
      export PS1="\u@\h: \w \$ "
  else
     #  export PS1="\e[0;32m\]\w $ \[\e[0m\]"
      PROMPT_COMMAND=set_bash_prompt
  fi
  export PROMPT_DIRTRIM=1 # number of trailing directory to retain when using \w
Note: I've used toolbox and distrobox, so the function at the top was just to add what current env I'm in. Kinda like venv.