Modifying the konsole prompt
Moderators: b1o, jkerr82508
					Forum rules
Please feel free to post your tip it does not have to be advanced. Also ask questions directly related to the tip here. But do not start new threads with questions or ask for help here. That is what the help section is for. forum rules: http://bjoernvold.com/forum/viewtopic.php?f=8&t=568
	Please feel free to post your tip it does not have to be advanced. Also ask questions directly related to the tip here. But do not start new threads with questions or ask for help here. That is what the help section is for. forum rules: http://bjoernvold.com/forum/viewtopic.php?f=8&t=568
Re: Modifying the konsole prompt
No I don't think you need to install cope-git. That was Arch specifics.
			
									
									Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. +  Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"
						"There are no stupid questions - Only stupid answers!"
- dedanna1029
 - Sound-Berserk
 - Posts: 8784
 - Joined: 14 Mar 2010, 20:29
 - Contact:
 
Re: Modifying the konsole prompt
Ok. Got it.
Next question, how do I get purple to go purple? It's not wanting to do it. I had to adjust text color in Preferences to get it to go. Here's how it looks for now. I still have to get rvause's code in, so Tilda and Yakuake look a tad bare for now. I also can not get Yakuake's text to go purple. There's nothing in preferences for it to change text color, and there is nothing also that I can find to turn off "Always on top" for it.
My two fav colors are there. The purple's a bit light for me in Tilda, but at least it's there. I can darken the background of the terminal itself to see it better, or change it again in preferences.
Even still, it's nice to know I can still do something pretty on ugly desktops (actually, the Linux Mint Gnome3 default desktop isn't really bad, it just lacks features I need). Clickety-click:

Thanks.
			
									
									Next question, how do I get purple to go purple? It's not wanting to do it. I had to adjust text color in Preferences to get it to go. Here's how it looks for now. I still have to get rvause's code in, so Tilda and Yakuake look a tad bare for now. I also can not get Yakuake's text to go purple. There's nothing in preferences for it to change text color, and there is nothing also that I can find to turn off "Always on top" for it.
My two fav colors are there. The purple's a bit light for me in Tilda, but at least it's there. I can darken the background of the terminal itself to see it better, or change it again in preferences.
Even still, it's nice to know I can still do something pretty on ugly desktops (actually, the Linux Mint Gnome3 default desktop isn't really bad, it just lacks features I need). Clickety-click:

Thanks.
I'd rather be a free person who fears terrorists, than be a "safe" person who fears the government.
No gods, no masters.
"A druid is by nature anarchistic, that is, submits to no one."
http://uk.druidcollege.org/faqs.html
						No gods, no masters.
"A druid is by nature anarchistic, that is, submits to no one."
http://uk.druidcollege.org/faqs.html
- dedanna1029
 - Sound-Berserk
 - Posts: 8784
 - Joined: 14 Mar 2010, 20:29
 - Contact:
 
Re: Modifying the konsole prompt
I'm writing this down here because I had to create a new ~/.bashrc and ~/.bash_profile for the CentOS install in /home. Not surprising really, as I'd saved /home and it didn't install them (it was a downgrade in a lot of ways). I used the above script, and this to create them.
			
									
									I'd rather be a free person who fears terrorists, than be a "safe" person who fears the government.
No gods, no masters.
"A druid is by nature anarchistic, that is, submits to no one."
http://uk.druidcollege.org/faqs.html
						No gods, no masters.
"A druid is by nature anarchistic, that is, submits to no one."
http://uk.druidcollege.org/faqs.html
Re: Modifying the konsole prompt
Thanks! That is how it works! If you need to write it down - write it down here. That will benefit others too.
			
									
									Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. +  Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"
						"There are no stupid questions - Only stupid answers!"
- dedanna1029
 - Sound-Berserk
 - Posts: 8784
 - Joined: 14 Mar 2010, 20:29
 - Contact:
 
Re: Modifying the konsole prompt
I'm having issues with it. Will post in Help.
			
									
									I'd rather be a free person who fears terrorists, than be a "safe" person who fears the government.
No gods, no masters.
"A druid is by nature anarchistic, that is, submits to no one."
http://uk.druidcollege.org/faqs.html
						No gods, no masters.
"A druid is by nature anarchistic, that is, submits to no one."
http://uk.druidcollege.org/faqs.html
- dedanna1029
 - Sound-Berserk
 - Posts: 8784
 - Joined: 14 Mar 2010, 20:29
 - Contact:
 
 Re: Modifying the konsole prompt; PATH=, ENV=, USERNAME=
													
							
						
			
			
			
			I appear to have a difference between the .bashrc for my own user (dedanna), and the one for root. Root's is as so (look at the top in these):
Here's mine (for user dedanna):
If you notice, root's has the section with PATH=, ENV-, etc., dedanna's doesn't. I'm wondering if that section is supposed to be commented out to add your part of the script to it, or should I have it commented out (is it supposed to be there for all users)? At the same time, should I have it for my ~/.bashrc (changing USERNAME="root" to USERNAME="dedanna"}? Is it best to have that section there, or commented out, when your part of the script is added?
Thanks.
			
									
									Code: Select all
# .bashrc
#This section here is the difference
PATH=
/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin
ENV=$HOME/.bashrc
USERNAME="root"
export USERNAME ENV PATH
# Source global definitions
#if [ -f /etc/bashrc ]; then
#   . /etc/bashrc
#fi
bash_prompt_cmd() {
    RTN=$?
    smiley() {
        if [ $1 == 0 ] ; then
    echo ":)"
        else
    echo ":("
           fi
        }
    smileyc() {
        if [ $1 == 0 ] ; then
    echo $GREEN
    else
    echo $RED
           fi
        }
    if [ $(tput colors) -gt 0 ] ; then
    RED=$(tput setaf 1)
    GREEN=$(tput setaf 2)
    RST=$(tput op)
    fi
    smiley=$(smiley $RTN)
    smileyc=$(smileyc $RTN)
            local CY="\[\e[1;31m\]" # Each is 12 chars long
            local BL="\[\e[1;34m\]"
            local WH="\[\e[1;37m\]"
            local BR="\[\e[0;33m\]"
            local RE="\[\e[1;31m\]"
            local PROMPT="${CY}$"
            [ $UID -eq "0" ] && PROMPT="${RE}#"
            # Add the first part of the prompt: username,host, and time
            local PROMPT_PWD=""
            local PS1_T1="$BL.:[ $CY`whoami`@`hostname` $BL: $CY\t $BL:$CY "
            local ps_len=$(( ${#PS1_T1} - 12 * 6 + 6 + 4 )) #Len adjust for
colors, time and var
            local PS1_T2=" $BL]:.\n\[\$smileyc\]\$smiley\[$RST\] "
            local startpos=""
            PROMPT_PWD="${PWD/#$HOME/~}"
            local overflow_prefix="..."
            local pwdlen=${#PROMPT_PWD}
            local maxpwdlen=$(( COLUMNS - ps_len ))
            # Sometimes COLUMNS isn't initiliased, if it isn't, fall back on 80
            [ $maxpwdlen -lt 0 ] && maxpwdlen=$(( 80 - ps_len ))
            if [ $pwdlen -gt $maxpwdlen ] ; then
                    startpos=$(( $pwdlen - maxpwdlen + ${#overflow_prefix} ))
                   
PROMPT_PWD="${overflow_prefix}${PROMPT_PWD:$startpos:$maxpwdlen}"
            fi
            export PS1="${PS1_T1}${PROMPT_PWD}${PS1_T2}"
    smiley=$(smiley $RTN)
    smileyc=$(smileyc $RTN)
            local CY="\[\e[1;31m\]" # Each is 12 chars long
            local BL="\[\e[1;34m\]"
            local WH="\[\e[1;37m\]"
            local BR="\[\e[0;33m\]"
            local RE="\[\e[1;31m\]"
            local PROMPT="${CY}$"
            [ $UID -eq "0" ] && PROMPT="${RE}#"
            # Add the first part of the prompt: username,host, and time
            local PROMPT_PWD=""
            local PS1_T1="$BL.:[ $CY`whoami`@`hostname` $BL: $CY\t $BL:$CY "
            local ps_len=$(( ${#PS1_T1} - 12 * 6 + 6 + 4 ))
       #Len adjust for colors, time and var
            local PS1_T2=" $BL]:.\n\[\$smileyc\]\$smiley\[$RST\] "
            local startpos=""
            PROMPT_PWD="${PWD/#$HOME/~}"
            local overflow_prefix="..."
            local pwdlen=${#PROMPT_PWD}
            local maxpwdlen=$(( COLUMNS - ps_len ))
            # Sometimes COLUMNS isn't initiliased, if it isn't, fall back on 80
            [ $maxpwdlen -lt 0 ] && maxpwdlen=$(( 80 - ps_len ))
            if [ $pwdlen -gt $maxpwdlen ] ; then
                    startpos=$(( $pwdlen - maxpwdlen + ${#overflow_prefix} ))
                   
PROMPT_PWD="${overflow_prefix}${PROMPT_PWD:$startpos:$maxpwdlen}"
            fi
            export PS1="${PS1_T1}${PROMPT_PWD}${PS1_T2}"
    }
    PROMPT_COMMAND=bash_prompt_cmdHere's mine (for user dedanna):
Code: Select all
# .bashrc
# User specific aliases and functions
# Source global definitions
#if [ -f /etc/bashrc ]; then
   . /etc/bashrc
#fi
    bash_prompt_cmd() {
    RTN=$?
    smiley() {
        if [ $1 == 0 ] ; then
    echo ":)"
        else
    echo ":("
           fi
        }
    smileyc() {
        if [ $1 == 0 ] ; then
    echo $GREEN
    else
    echo $RED
           fi
        }
    if [ $(tput colors) -gt 0 ] ; then
    RED=$(tput setaf 1)
    GREEN=$(tput setaf 2)
    RST=$(tput op)
    fi
    smiley=$(smiley $RTN)
    smileyc=$(smileyc $RTN)
            local CY="\[\e[1;31m\]" # Each is 12 chars long
            local BL="\[\e[1;34m\]"
            local WH="\[\e[1;37m\]"
            local BR="\[\e[0;33m\]"
            local RE="\[\e[1;31m\]"
            local PROMPT="${CY}$"
            [ $UID -eq "0" ] && PROMPT="${RE}#"
            # Add the first part of the prompt: username,host, and time
            local PROMPT_PWD=""
            local PS1_T1="$BL.:[ $CY`whoami`@`hostname` $BL: $CY\t $BL:$CY "
            local ps_len=$(( ${#PS1_T1} - 12 * 6 + 6 + 4 )) #Len adjust for colors, time and var
            local PS1_T2=" $BL]:.\n\[\$smileyc\]\$smiley\[$RST\] "
            local startpos=""
            PROMPT_PWD="${PWD/#$HOME/~}"
            local overflow_prefix="..."
            local pwdlen=${#PROMPT_PWD}
            local maxpwdlen=$(( COLUMNS - ps_len ))
            # Sometimes COLUMNS isn't initiliased, if it isn't, fall back on 80
            [ $maxpwdlen -lt 0 ] && maxpwdlen=$(( 80 - ps_len ))
            if [ $pwdlen -gt $maxpwdlen ] ; then
                    startpos=$(( $pwdlen - maxpwdlen + ${#overflow_prefix} ))
                    PROMPT_PWD="${overflow_prefix}${PROMPT_PWD:$startpos:$maxpwdlen}"
            fi
            export PS1="${PS1_T1}${PROMPT_PWD}${PS1_T2}"
    smiley=$(smiley $RTN)
    smileyc=$(smileyc $RTN)
            local CY="\[\e[1;31m\]" # Each is 12 chars long
            local BL="\[\e[1;34m\]"
            local WH="\[\e[1;37m\]"
            local BR="\[\e[0;33m\]"
            local RE="\[\e[1;31m\]"
            local PROMPT="${CY}$"
            [ $UID -eq "0" ] && PROMPT="${RE}#"
            # Add the first part of the prompt: username,host, and time
            local PROMPT_PWD=""
            local PS1_T1="$BL.:[ $CY`whoami`@`hostname` $BL: $CY\t $BL:$CY "
            local ps_len=$(( ${#PS1_T1} - 12 * 6 + 6 + 4 ))
       #Len adjust for colors, time and var
            local PS1_T2=" $BL]:.\n\[\$smileyc\]\$smiley\[$RST\] "
            local startpos=""
            PROMPT_PWD="${PWD/#$HOME/~}"
            local overflow_prefix="..."
            local pwdlen=${#PROMPT_PWD}
            local maxpwdlen=$(( COLUMNS - ps_len ))
            # Sometimes COLUMNS isn't initiliased, if it isn't, fall back on 80
            [ $maxpwdlen -lt 0 ] && maxpwdlen=$(( 80 - ps_len ))
            if [ $pwdlen -gt $maxpwdlen ] ; then
                    startpos=$(( $pwdlen - maxpwdlen + ${#overflow_prefix} ))
                    PROMPT_PWD="${overflow_prefix}${PROMPT_PWD:$startpos:$maxpwdlen}"
            fi
            export PS1="${PS1_T1}${PROMPT_PWD}${PS1_T2}"
    }
    PROMPT_COMMAND=bash_prompt_cmdIf you notice, root's has the section with PATH=, ENV-, etc., dedanna's doesn't. I'm wondering if that section is supposed to be commented out to add your part of the script to it, or should I have it commented out (is it supposed to be there for all users)? At the same time, should I have it for my ~/.bashrc (changing USERNAME="root" to USERNAME="dedanna"}? Is it best to have that section there, or commented out, when your part of the script is added?
Thanks.
I'd rather be a free person who fears terrorists, than be a "safe" person who fears the government.
No gods, no masters.
"A druid is by nature anarchistic, that is, submits to no one."
http://uk.druidcollege.org/faqs.html
						No gods, no masters.
"A druid is by nature anarchistic, that is, submits to no one."
http://uk.druidcollege.org/faqs.html
- dedanna1029
 - Sound-Berserk
 - Posts: 8784
 - Joined: 14 Mar 2010, 20:29
 - Contact:
 
Re: Modifying the konsole prompt
I'm having definite bash and .bashrc issues since I went 64-bit. It wasn't a clean install, I only formatted / (root). It won't take the code for the cool prompt, and even has issues with just a vanilla .bashrc:
Things are running very slowly in /home/myuser desktop; when I click to load a program, it takes forever to load. Sometimes I get the bash prompt in terminal (bash 4.2 whatever prompt), other times I get the vanilla one. Some things don't load at all, like kopete, and the Firefox 22 tarball executable.
My question is, is there anything else that could be affecting .bashrc, or is there anything else it affects? Is ~/.bashrc different for 64-bit?
This is in XFCE. I haven't tried gnome or kde yet since I did the reinstall.
Thanks.
			
									
									Code: Select all
# .bashrc
# User specific aliases and functions
# Source global definitions
if [ -f /etc/bashrc ]; then
   . /etc/bashrc
fiThings are running very slowly in /home/myuser desktop; when I click to load a program, it takes forever to load. Sometimes I get the bash prompt in terminal (bash 4.2 whatever prompt), other times I get the vanilla one. Some things don't load at all, like kopete, and the Firefox 22 tarball executable.
My question is, is there anything else that could be affecting .bashrc, or is there anything else it affects? Is ~/.bashrc different for 64-bit?
This is in XFCE. I haven't tried gnome or kde yet since I did the reinstall.
Thanks.
I'd rather be a free person who fears terrorists, than be a "safe" person who fears the government.
No gods, no masters.
"A druid is by nature anarchistic, that is, submits to no one."
http://uk.druidcollege.org/faqs.html
						No gods, no masters.
"A druid is by nature anarchistic, that is, submits to no one."
http://uk.druidcollege.org/faqs.html