You are not logged in.

#1 2012-11-19 22:28:32

rix
Member
Registered: 2012-07-25
Posts: 238

[SOLVED] Bash prompt issues

Hi everyone and sorry for couldn't find a more descriptives title.
Two issues here. smile

First.
I'm looking for a way, even if it's possible, for to have Bash prompt on two rows.
I mean not just the $PS1 but everything in the prompt.
I try to be more clear with an example:

this/is/my/hypothetical/prompt/in/a/very/long/path : and this will be a very long, long, long command! What a long command man. I'm impressed how long is it :D and I don't know what  to write anymore.

Watch at what happened in the above example. At the moment we reached the edge of the text area, text continues under the previous row, in a new one. In my Bash prompt, in the same situation, it'd continue on the same row, again, from left to right, covering the oldest row.
How can I make it on more rows?

Second.
Random in the Bash prompt, even if I run clear, piece of the previous inserted command remains, but in such cases it won't be consider as command from Bash.
Example:

/path/where/im/in : long command in the prompt which leaves its trace
[...]
/path/where/im/in : clear
/path/where/im/in : long command[b]new command[/b]
                            ^^^^^^^^^
                            [i]This part shouldn't be there but it don't disappears.[/i]

.bashrc

#!/bin/bash
[[ $- != *i* ]] && return
complete -cf sudo
[ -f /etc/bash_completion ] && ! shopt -oq posix && . /etc/bash_completion
[ -f ~/.bash/include ] && . ~/.bash/include
[ -e "$HOME"/.dircolors ] && eval $(dircolors -b "$HOME"/.dircolors)

include

#!/bin/bash
[ -f ~/.bash/alias ] && . ~/.bash/alias
[ -f ~/.bash/color ] && . ~/.bash/color
[ -f ~/.bash/export ] && . ~/.bash/export
[ -f ~/.bash/function ] && . ~/.bash/function
[ -f ~/.bash/shopt ] && . ~/.bash/shopt
[ -f ~/.bash/stty ] && . ~/.bash/stty
[ -f ~/.bash/set ] && . ~/.bash/set

export

export PS1="$bbk:$end$ncy \w\n$end$bbk: $end"
# export PS1="$bbk┌─$end$ncy \w\n$end$bbk└─ $end"
# export PS1="$ncy\w : $end"
export HISTCONTROL="ignoreboth"
export HISTSIZE="100"
export HISTFILESIZE="500"
export EDITOR="$(which vim)"
export PAGER="$(which less)"
export VISUAL="$(which vim)"
export BROWSER="$(which elinks):$(which firefox)"
export PATH="${PATH}:/bin:/sbin:/usr/bin:/usr/local/bin:/usr/local/share: \
${HOME}"
export DWM="$HOME/.dwm"
export SH="$HOME/.bash"
export SH_UTIL="$HOME/.scr/sh/util"
export SH_DMN="$HOME/.scr/sh/dmn"
export TM="$HOME/.tmux"
export TMS="$HOME/.tmux/scr"
export GM="$HOME/.gm"
export DL="$HOME/c.dl"
export DL_B="$HOME/c.dl/.builds"
export SMS="$HOME/c.sms"
export GREP_OPTIONS="--color=auto -i"
export LS_OPTIONS="--color=auto --group-directories-first"

function

extract() {
    [ -f "${1}" ] && \
	    case "${1}" in
		    *.tar.bz2) tar          xvjf    "${1}";;
      	    *.tar.gz)  tar          xvzf    "${1}";;
      	    *.tar.xz)  tar          xvJf    "${1}";;
      	    *.bz2)     bunzip2      v       "${1}";;
      	   	*.rar)     unrar        e       "${1}";;
      	    *.gz)      gunzip       d       "${1}";;
      	    *.tar)     tar          xvf     "${1}";;
      	    *.tbz2)    tar          xvjf    "${1}";;
      	    *.tgz)     tar          xvzf    "${1}";;
      	    *.zip)     unzip                "${1}";;
      	    *.Z)       uncompress           "${1}";;
      	    *.xz)      unxz         dfc     "${1}";;
      	    *)         echo "WR: ${1} is not a recognized file format.";;
      	esac || \
		echo "ER: ${1} is not a valid file."
}
myps() { 
    ps "$@" -u "$USER" -o pid,%cpu,%mem,bsdtime,command ; 
}
pstree() { 
    myps f | awk '!/awk/ && $0~var' var=${1:-".*"} ; 
}
nf () {
    ls -al "${1}" | wc -l ;
}
mktar() { 
    tar cvf "${1%%/}.tar" "${1%%/}/"; 
}
mktgz() { 
    tar cvzf "${1%%/}.tar.gz" "${1%%/}/"; 
}
mktbz() { 
    tar cvjf "${1%%/}.tar.bz2" "${1%%/}/"; 
}
mkzip() { 
   zip -9 -y -r -q "${1%%/}.zip" "${1%%/}/"; 
}
mkpzip() { 
   zip --encrypt "$1.zip" "$1"; 
}

set

#!/bin/bash
set -o ignoreeof
set -o notify

shopt

shopt -s cdspell
shopt -s dirspell
shopt -s cmdhist
shopt -s no_empty_cmd_completion
shopt -s histappend

stty

stty ixany
stty ixoff -ixon
stty stop undef
stty start undef
stty iutf8

Happens even in Urxvt(v. 9.15), Xterm(286) and Tmux(1.7).
I still don't know in tty but I think it does.

Also everyting is up to date.

Hoping it's clear I thank you in advance.

Last edited by rix (2012-11-20 11:16:55)

Offline

#2 2012-11-19 23:17:24

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] Bash prompt issues

Your prompt is broken - presumably because you haven't correctly escaped some of the variables in it.

You have also posted everything but the relevant functions that would help diagnose the issue, ie., where
"export PS1="$bbk:$end$ncy \w\n$end$bbk: $end" is defined.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2012-11-20 09:41:02

rix
Member
Registered: 2012-07-25
Posts: 238

Re: [SOLVED] Bash prompt issues

It's defined in color

nc="\e[0m"
nbk="\e[0;30m"
nre="\e[0;31m"
ngr="\e[0;32m"
nye="\e[0;33m"
nbl="\e[0;34m"
nma="\e[0;35m"
ncy="\e[0;36m"
nwh="\e[0;37m"
bbk="\e[1;30m"
bre="\e[1;31m"
bgr="\e[1;32m"
bye="\e[1;33m"
bbl="\e[1;34m"
bma="\e[1;35m"
bcy="\e[1;36m"
bwh="\e[1;37m"
end="\e[m"

man() {
    env \
        LESS_TERMCAP_mb=$(printf "\e[0;32m") \
        LESS_TERMCAP_md=$(printf "\e[0;32m") \
        LESS_TERMCAP_me=$(printf "\e[0m") \
        LESS_TERMCAP_se=$(printf "\e[0m") \
        LESS_TERMCAP_so=$(printf "\e[1;31m") \
        LESS_TERMCAP_ue=$(printf "\e[0m") \
        LESS_TERMCAP_us=$(printf "\e[1;33m") \
    man "${@}"
}
# if [ "$TERM" = "linux" ]; then
    # echo -en "\e]P0222222" # Black.
    # echo -en "\e]P8222222" # Darkgrey.
    # echo -en "\e]P1803232" # Darkred.
    # echo -en "\e]P9982b2b" # Red.
    # echo -en "\e]P25b762f" # Darkgreen.
    # echo -en "\e]PA89b83f" # Green.
    # echo -en "\e]P3aa9943" # Brown.
    # echo -en "\e]PBefef60" # Yellow.
    # echo -en "\e]P4324c80" # Darkblue.
    # echo -en "\e]PC2b4f98" # Blue.
    # echo -en "\e]P5706c9a" # Darkmagenta.
    # echo -en "\e]PD826ab1" # Magenta.
    # echo -en "\e]P692b19e" # Darkcyan.
    # echo -en "\e]PEa1cdcd" # Cyan.
    # echo -en "\e]P7ffffff" # Lightgrey.
    # echo -en "\e]PFdedede" # White.
    # clear # For background artifacting.
# fi
if [ "$TERM" = "linux" ]; then
    echo -en "\e]P0000000" # Black.
    echo -en "\e]P9ff0000" # Red.
    echo -en "\e]PA00ff00" # Green.
    echo -en "\e]PBffff00" # Yellow.
    echo -en "\e]PC2b4f98" # Blue.
    echo -en "\e]PDff00ff" # Magenta.
    echo -en "\e]PE00ffff" # Cyan.
    echo -en "\e]PFffffff" # White.
    clear
fi

----
Edit:
forget everything. I've isolated the cause.
For both issue it's the color file fault.

I've to figure out how to resolve now.


---
Edit:
solved.
This

end="\e[m"

should be instead

end="\[\e[m\]"

Thanks. smile

Last edited by rix (2012-11-20 11:16:17)

Offline

Board footer

Powered by FluxBB