nitr0gear

Untitled

Sep 26th, 2025
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.24 KB | Source Code | 0 0
  1. # Nitrogear bash prompt
  2. # Features:
  3. # - the last command's exit code
  4. # - number and size of files in the current directory
  5. # - colored user (regular or root)
  6. # - colored git branch (master/qa/other)
  7. PS1="
  8. \[\033[1;37m\]┌($(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\H'; else echo '\[\033[01;34m\]\u@\h'; fi)\[\033[1;37m\])─(\$(if [[ \$? == 0 ]]; then echo \"\[\033[01;32m\]✓\"; else echo \"\[\033[01;31m\]✗\"; fi)\[\033[1;37m\])─(\[\033[1;34m\]\@ \d\[\033[1;37m\])
  9. └─(\[\033[1;32m\]\w\[\033[1;37m\])─(\[\033[1;32m\]\$(ls -1 | wc -l | sed 's: ::g') files, \$(ls -lah | grep -m 1 total | sed 's/total //')b\[\033[1;37m\])\$( \
  10.  if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then \
  11.    branch=\$(git rev-parse --abbrev-ref HEAD 2>/dev/null); \
  12.    if [[ \$branch == \"main\" || \$branch == \"master\" ]]; then \
  13.      echo '─(\[\033[1;31m\]git:'\$branch'\[\033[1;37m\])'; \
  14.    elif [[ \$branch == qa* ]]; then \
  15.      echo '─(\[\033[1;33m\]git:'\$branch'\[\033[1;37m\])'; \
  16.    elif [[ \$branch == dev* || \$branch == development ]]; then \
  17.      echo '─(\[\033[1;32m\]git:'\$branch'\[\033[1;37m\])'; \
  18.    else \
  19.      echo '─(\[\033[1;34m\]git:'\$branch'\[\033[1;37m\])'; \
  20.    fi; \
  21.  fi)\
  22. ─> \[\033[0m\]"
Tags: BASH Prompt
Advertisement
Add Comment
Please, Sign In to add comment