Use this bash init script snippet to get an improved prompt. Also can you donate to help us to get a friend out of jail?

4 risposte [Ultimo contenuto]
marioxcc
Offline
Iscritto: 08/13/2014

Hello fellow free software users!. I want to share with you a small snippet that I have in my .bashrc to make a custom prompt, as you can see in the attached image. It is licensed under the GNU General Public License version 3 or any later and you will find it attached to this post. Note that the exit status code of the previous command is displayed between the host name and the path.

I am also writing to ask for your help to raise funds for the legal defense of a friend who is currently in jail. He is known as Alina Davis among Russian users for his sometimes feminine and sometimes androgynous appearance and sense of fashion You can find information about Alina and how to help in this web site. Please help by donating, and also by linking to our fund-raising web site from your social media accounts. For those of you who use Facebook or Twitter, please help us by linking to Alina's fund raising web site from those social networks, especially among those groups that may sympathize with Alina's situation. Thanks.

AllegatoDimensione
screenshot.png19.42 KB
prompt.sh1.59 KB
marioxcc
Offline
Iscritto: 08/13/2014
# Copyright (c) 2017 Mario Castelán Castro
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

function set_color () {
    local RED GREEN CYAN END_COLOR
    RED="$(tput setaf 1)" &&
    GREEN="$(tput setaf 2)" &&
    CYAN="$(tput setaf 6)" &&
    END_COLOR="$(tput sgr0)"

    if [ $? != 0 ]; then
        local PRINT_EXIT_STATUS=\
"\$(E=\$?
if [ \$E == 0 ]; then
    echo \"[\$E]\"
else
    echo \"*\$E*\"
fi )"
        PS1="\u@\h $PRINT_EXIT_STATUS [\$PWD]\n\\$ "
    else
        if [ $(id -u) == 0 ]; then
            local USER_COLOR="$RED"
        else
            local USER_COLOR="$GREEN"
        fi
        local HOST_COLOR="$CYAN"
        local PRINT_EXIT_STATUS=\
"\$(E=\$?
if [ \$E == 0 ]; then
    echo \"\[$GREEN\][\$E]\[$END_COLOR\]\"
else
    echo \"\[$RED\][\$E]\[$END_COLOR\]\"
fi)"
        PS1="\[$USER_COLOR\]\u\[$END_COLOR\]\[$HOST_COLOR\]@\h\[$END_COLOR\] $PRINT_EXIT_STATUS \[$HOST_COLOR\][\$PWD]\[$END_COLOR\]\n\\[$USER_COLOR\]\\$\[$END_COLOR\] "
        PS2="\[$USER_COLOR\]>\[$END_COLOR\] "
    fi
}

set_color

The attachment seems to be broken, so I have posted the snippet above.

jorgesumle
Offline
Iscritto: 06/01/2016

This may be useful for Git users: https://github.com/magicmonty/bash-git-prompt

northernarcher
Offline
Iscritto: 12/24/2014

>Her, and her family's request to be held in a female prison until the trial was denied. She and her family then requested a single cell for Alina, but it was also denied. Alina is in a male prison and therefore her physical integrity and life are at risk.

Holy fuck. That is terrifying.

marioxcc
Offline
Iscritto: 08/13/2014

We have less than 24 hours to collect the required amount for Alina's legal defense. The trial will be on 2 March 2017 (time of Moscow, UTC+3) but we must have the money ready before that, taking into account the time it takes to exchange.

Now we can receive PayPal donations (send to the e-mail name at domain). We still receive Bitcoin donations (address: 1MCTLYKSAmBSjk8Tg32YcaUF9bKifHVA6N). Bitcoin donations are immediately made public and transparent in this or any other blockchain explorer.

The campaign has been partially sucessful with some donations, but a small fraction is still needed. Please donate and make the difference!