Bash Shell Prompt Customization

Bild

How can I make the Bash prompt look like this I use KDE 5.19. I saw this thing on arch Linux? Is it possible to make it on Manjaro?

That’s not bash but zsh. As far as I know, bash does not support that kind of theming. :thinking:

I myself do use a customized bash prompt, with a shell function that allows me to choose a different color for the prompt if I want to. I’ve done this by adding the following to my ~/.bashrc. :arrow_down:

cprompt () {

  if [ ! -z $1 ]
  then
    case $1 in

      "green"  )
         clrprompt="\[\e[1;32m\]\n[\h:\$(/usr/bin/tty)][\${PWD}]\n[\t][\u] \[\e[1;37m\]>\[\e[0m\] "
         ;;
      "yellow" )
         clrprompt="\[\e[1;33m\]\n[\h:\$(/usr/bin/tty)][\${PWD}]\n[\t][\u] \[\e[1;37m\]>\[\e[0m\] "
         ;;
      "blue"   )
         clrprompt="\[\e[1;34m\]\n[\h:\$(/usr/bin/tty)][\${PWD}]\n[\t][\u] \[\e[1;37m\]>\[\e[0m\] "
         ;;
      "pink"   )
         clrprompt="\[\e[1;35m\]\n[\h:\$(/usr/bin/tty)][\${PWD}]\n[\t][\u] \[\e[1;37m\]>\[\e[0m\] "
         ;;
      "cyan"   )
         clrprompt="\[\e[1;36m\]\n[\h:\$(/usr/bin/tty)][\${PWD}]\n[\t][\u] \[\e[1;37m\]>\[\e[0m\] "
         ;;
      "white"  )
         clrprompt="\[\e[1;37m\]\n[\h:\$(/usr/bin/tty)][\${PWD}]\n[\t][\u] \[\e[1;37m\]>\[\e[0m\] "
         ;;
      *        )
         echo
         echo "     The only options available are: "
         echo
         echo "         green | yellow | blue | pink | cyan | white"
         echo
         return
         ;;
    esac
    PS1=${clrprompt}
  else
         echo
         echo "     No color specified."
         echo
         return
  fi

}

cprompt yellow
export PS1
export -f cprompt

As for what my prompt then looks like… :arrow_down:

[nx-74205:/dev/pts/3][/home/aragorn]
[17:10:17][aragorn] > 
1 Like

Ok I will try the zsh, Is it also the archiso shell?

2 Likes

Yes, zsh is the default interactive shell in the latest Manjaro installers, and I believe in Arch as well. :wink:

Cool I found the completion so nice but I was unable to install GRUB correctly (and I’m happy that it don’t worked: Manjaro is the best)

1 Like

The ZSH does not have the theme by default.

But the distribution called https://ohmyz.sh/ has such a theme.

Install

yay -S oh-my-zsh-git oh-my-zsh-powerline-theme-git

Then export envrironment variable @ ~/.zshrc

# Path oh-my-zsh installation.
export ZSH=/usr/share/oh-my-zsh/

Set the theme

ZSH_THEME="agnoster"

1 Like

I seem to remember @codesardine mentioning that the Manjaro devs are working on a new default zsh theme for Manjaro as well. :wink:

3 Likes

I’m not sure, try pureline https://github.com/chris-marsh/pureline

2 Likes

Wow, that’s cool. :+1:

I’ll mark your post as the solution ─ it’s much better than my own answer. :wink:

Exists also powerline go, silver and other … for bash or zsh or fish
Contrary to others, they are compiled programs and therefore faster

1 Like

Looks like powerline-shell (GitHub - b-ryan/powerline-shell: A beautiful and useful prompt for your shell), install via AUR. To setup for bash, check here: GitHub - b-ryan/powerline-shell: A beautiful and useful prompt for your shell

It’s in the regular repo as well. I’ve just checked. :wink:

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.