Live data from Hacker News

Ask HN: Looking for a directory of PS1 command prompts. Like awesome lists

news.ycombinator.com

1–6 of 6 posts

Ask HN: Looking for a directory of PS1 command prompts. Like awesome lists

#1
Command line bros, assemble!

PS1 is the settings that give you the cool prompts on the command line.

I've gone searching for a directory of PS1's where I can browse, save, and try out different command prompts.

Do i need to make this? Or is my google-fu, perplexity-fu, and gpt-fu just not where it needs to be?

Or do I need to make one?

Re: Ask HN: Looking for a directory of PS1 command prompts. Like awesome lists

#5
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.