From 2eeaf522c0359e455f4827281cd6d149ba10c399 Mon Sep 17 00:00:00 2001 From: tbhaxor Date: Thu, 14 Mar 2019 01:54:35 +0530 Subject: [PATCH] added parrot os like terminal prompt --- themes/parrot/parrot.theme.bash | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 themes/parrot/parrot.theme.bash diff --git a/themes/parrot/parrot.theme.bash b/themes/parrot/parrot.theme.bash new file mode 100644 index 00000000..63e1cf33 --- /dev/null +++ b/themes/parrot/parrot.theme.bash @@ -0,0 +1,38 @@ +# +# ~/.bashrc +# + +# git branch parser +function parse_git_branch() { + echo -e "\033[1;34m$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/')\033[0m" +} + +function parse_git_branch_no_color() { + echo -e "$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/')" +} + +function promp() { + # If not running interactively, don't do anything + [[ $- != *i* ]] && return + + force_color_prompt=yes + + if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi + fi + + if [ "$color_prompt" = yes ]; then + PS1="\[\033[0;31m\]\342\224\214\342\224\200\$([[ \$? != 0 ]] && echo \"[\[\033[0;31m\]\342\234\227\[\033[0;37m\]]\342\224\200\")[$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]root\[\033[01;33m\]@\[\033[01;96m\]\h'; else echo '\[\033[0;39m\]\u\[\033[01;33m\]@\[\033[01;96m\]\h'; fi)\[\033[0;31m\]]\342\224\200[\[\033[0;32m\]\w\[\033[0;31m\]]\n\[\033[0;31m\]\342\224\224\342\224\200\342\224\200\342\225\274 \[\033[0m\]\[\e[01;33m\]$(parse_git_branch) $\[\e[0m\] " + + else + PS1='┌──[\u@\h]─[\w]\n└──╼ $(parse_git_branch_no_color) $ ' + fi +} +