I’m looking for inspiration for a custom Bash prompt[1]. I’d love to see yours! 😊 If possible, include both the prompt’s PS1, and a screenshot/example of what it looks like.

References
  1. Type: Documentation. Title: “Bash Reference Manual”. Publisher: Gnu Project. Edition: 5.2. Published: 2022-09-19. Accessed: 2025-03-21T02:46Z. URI: https://www.gnu.org/software/bash/manual/html_node/index.html.

Crossposts:

  • beirdobaggins@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    23 days ago

    Mine shows the full path and a new line for commands.

    It will also print the exit code of the last command in red above the prompt, if the exit code is not 0.

    PS1='$(ec=“$?”; if [ $ec -gt 0 ]; then echo -e “\n”[\e[91m]“exit code: $ec”[\e[0m]; fi)\n[\e[92m]\u[\e[38;5;213m]@[\e[38;5;39m]\h[\e[0m]:$PWD\n$ ’

    • Ephera@lemmy.ml
      link
      fedilink
      English
      arrow-up
      2
      ·
      25 days ago

      Same. I guess, this is the Starship thread now. My config:

      I adapted it from the Gruvbox Rainbow theme.
      I can post my config, if anyone wants specifically that. (It does kind of assume a light background, though.)

    • tankplanker@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      24 days ago

      Another starship user. Mostly want it to summarise useful stuff for folders pulled from git or whatever so it’s pretty plain rest of the time. I use the same on all my boxes

  • Daniel Quinn@lemmy.ca
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    22 days ago

    My shit is custom and rather elaborate.

    Screenshot of the prompt

    From left-to-right:

    • name@server-name
    • Uptime (multiplied by 10 and rounded to the nearest integer to save space)
    • Percentage disk space available on /
    • Number on established network connections
    • Git branch : commit
    • Python virtualenv
    • [new line]
    • date and time

    The code for this is on GitLab.

  • z3rOR0ne@lemmy.ml
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    24 days ago

    I use zsh, but my old Bash prompt looks almost the same as my Zsh prompt. Sorry, no screenshot, but here’s the code:

    export PS1='\[\033[01;34m\][\[\033[01;37m\] \W\[\033[01;34m\]]\$\033[01;34m\] $(git branch 2>/dev/null | grep '^*' | colrm 1 2)\n\033[01;34m└─>\033[37m '
    
    • PlutoniumAcid@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      24 days ago

      I recently started with fish and dislike that I can’t drop bash commands into it because it parses differently. That is enough to annoy me to uninstall.

      • mbirth@lemmy.ml
        link
        fedilink
        arrow-up
        1
        ·
        24 days ago

        You shouldn’t just “drop bash commands into it” anyways. And if you really need it, bash is only one bash away.

  • Xanza@lemm.ee
    link
    fedilink
    English
    arrow-up
    1
    ·
    25 days ago
    export PS1="\[\e[31m\][\[\e[m\]\[\e[38;5;172m\]\u\[\e[m\]@\[\e[38;5;153m\]\h\[\e[m\] \[\e[38;5;214m\]\W\[\e[m\]\[\e[31m\]]\[\e[m\]\\$ "
    
        • billwashere@lemmy.world
          link
          fedilink
          English
          arrow-up
          1
          ·
          24 days ago

          Best I can tell is it’s a normal `username@hostname current_directory$ sorta prompt with some coloring: • Red for the square brackets • Orange (color 172) for the username • Light blue (color 153) for the hostname • Amber (color 214) for the current working directory

          Other than being hard to read from the embedded coloring I’m not sure why this is a war crime.

  • winety@lemmy.zip
    link
    fedilink
    arrow-up
    1
    ·
    25 days ago

    Mine’s really simple; I just make the path bold and yellow:

    My Bash prompt

    What I like to do is change the colour depending on the machine I ssh into, e.g. make the path red on my Raspberry Pi.

  • DeuxChevaux@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    25 days ago

    Mine is simple (inspired by Kali Linux, if that’s even correct)
    PS1='\[\033[0;32m\]┌──[\t] (\u@\h)-[\w]\n└─$ \[\033[0m\]'

  • catloaf@lemm.ee
    link
    fedilink
    English
    arrow-up
    1
    ·
    25 days ago
    export PS1="\[\e]0;\u@\h:\w\a\]\[\e[1;34m\]\u@\h:\w\[\e[0m\]\$ "
    

    I am a simple man.

  • Rivalarrival@lemmy.today
    link
    fedilink
    English
    arrow-up
    1
    ·
    25 days ago

    I didn’t even know I needed to edit my prompt, but now I don’t know how I have lived with it for so long.