Skip to content

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

5 pointssimplecto5 comments
On HN

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?

Comments

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.

I wonder if Oh my Zsh and its equivalents for other shells might be what you're really after?

https://ohmyz.sh/

That is basically what Oh My Zsh does for zsh: https://ohmyz.sh/ Even if you don't use zsh you can look at the source code and adapt the prompts for the shell you are using.

I think people mostly just use powerlevel10k and various themes.

You can just use Starship

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.