Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I have a very simple prompt on my dev machine:

* I don't need the hostname. The lack of it = my machine.

* I don't need the username. I'm the only user.

* I don't need the full path. I know my machine pretty well. If I'm in doubt, pwd is half a second away.

* The prompt is red so I easily can scan what the output of this specific command was.

* Current Git-branch = helps me not make stupid mistakes.

  gitprompt() {
    PS1="\[\e[0;31m\]\W$(__git_ps1 " \[\e[1;31m\](%s)") \$ \[\e[m\]"
  }
  PROMPT_COMMAND=gitprompt


I'm tried to minimise the length of "user@host fullpath" too. This is what I ended up with (in zsh):

    PS1='[%(?..%?)%(?.. ! )$PR_GREEN%2>>%n%<<@%m$PR_NO_COLOR $PR_BLUE%30<...<%~%<<$PR_NO_COLOR]%(!.#.$) '
path is limited to 30 characters and the front is trimmed with '...'. There is a host, because I work on at least 5 at the same time every day, but the username is cut to only the first 2 letters (so it's either vi, or ro, or something else at uni). The return code is only visible when it's non-zero.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: