Tiny Core Linux

General TC => General TC Talk => Topic started by: AlejandroPadrino on August 11, 2017, 06:14:27 PM

Title: TinyCore 8.0 console prompt
Post by: AlejandroPadrino on August 11, 2017, 06:14:27 PM
Hello, testing TC8 I can't put my own console prompt completly.  Ash console recognizes colors but, in difference with my old TC4, does not recognize date, day of week and time with seconds.  How put these values in $PS1?

Thank you.
Title: Re: TinyCore 8.0 console prompt
Post by: curaga on August 12, 2017, 01:12:03 AM
Could be you used bash previously? The busybox config option for that is still enabled.
Title: Re: TinyCore 8.0 console prompt
Post by: AlejandroPadrino on August 12, 2017, 06:19:47 AM
I used that prompt in mint & ubuntu bash from $PS1 created in TinyCore 4.1.  Well, can load bash console, but ... Why can't show date, week day and seconds in new TinyCore 8.0?
Title: Re: TinyCore 8.0 console prompt
Post by: Misalf on August 12, 2017, 06:26:54 AM
Busybox Ash doesn't support as much features as Bash.
Anyway, I have a fancy prompt. ;)
/home/tc/.ashrc
Code: [Select]
case $- in *i*) ### Interactive shell.
        SHELLSHORT="${SHELL##*/}"
        [ "$0" == "$SHELLSHORT" ] && echo -e "\n\033[1;30m  $0  ::  $(cat /etc/issue) $(cat /usr/share/doc/tc/release.txt)  ::  Kernel $(uname -r)\033[0m\n"

        [ -n "$SSH_CONNECTION" ] && { SEPRT_REMOTE="*" ; REMOTE="$(echo "$SSH_CONNECTION" | awk "{print \$3}")" ; }

    TTYNUM="$(tty | sed "s/.*[tty|pts/]\(.*\)/\1/")"

        case "$TERM" in
                xterm*|rxvt*)
                        [ "$TERM" == "rxvt-unicode" ] && { export LC_CTYPE="de_DE.UTF-8" ; printf "\33]701;$LC_CTYPE\007" ; }  ### URxvt Stuff
                        PS1='\[\033[01;04;30m\]$(date +%H:%M:%S)\[\033[0;33m\]$([ "$?" -eq 0 ] && echo " " || echo "!")\[\033[0;3$([ "`id -u`" -eq 0 ] && echo "1m\]" || echo "2m\]\u\[\033[0;1;30m\]@\[\033[0;33m\]")\H\[\033[1;30m\]${SEPRT_REMOTE}\[\033[0;35m\]\[\033[4m\]${REMOTE}\[\033[0;1;30m\][${TTYNUM}$([ "$(jobs | wc -l)" -gt 0 ] && echo "j$(jobs | wc -l)")]:\[\033[0;3$([ "`pwd -P`" == "$PWD" ] && echo "4m\]" || echo "6m\]")$(case "$PWD" in "$HOME") echo "~/"  ;; "/") echo "/" ;; "$(pwd -P)") echo "$PWD/" ;; *) echo "$PWD@\[\033[0m\] -> \[\033[0;34m\]$(pwd -P)/" ;; esac)\[\033[0;3$([ "`id -u`" -eq 0 ] && echo "1" || echo "2")m\]\$\[\033[0m\] '
                        PS1='\[\033]0;$([ "$?" -eq 0 ] || echo "!")${SEPRT_REMOTE}$0: $(case "$PWD" in "$HOME") echo "~/"  ;; "/") echo "/" ;; *) echo "${PWD}/" | sed "s:/.*/.*/\(.*/\)\(.*/\):../\1\2:" ;; esac)\$\007\]'$PS1
                ;;
                *)
                        PS1='\[\033[01;30m\][$(date +%H:%M:%S)]\[\033[00;33m\]$([ "$?" -eq 0 ] && echo " " || echo "!")\[\033[00;3$([ "`id -u`" -eq 0 ] && echo "1m\]" || echo "2m\]\u\[\033[0;1;30m\]@\[\033[00;33m\]")\h\[\033[1;30m\]${SEPRT_REMOTE}\[\033[0;35m\]${REMOTE}\[\033[0;1;30m\][${TTYNUM}$([ "$(jobs | wc -l)" -gt 0 ] && echo "j$(jobs | wc -l)")]:\[\033[00;34m\]$(case "$PWD" in "$HOME") echo "~/"  ;; "/") echo "/" ;; *) echo "$PWD/" ;; esac)\[\033[00;3$([ "`id -u`" -eq 0 ] && echo "1" || echo "2")m\]\$\[\033[0m '
                ;;
        esac
        export PS1
    ;;
esac

Code: [Select]
  sh  ::  Core Linux 7.2  ::  Kernel 4.2.9-tinycore

15:28:05 tc@box[0]:~/$
Title: Re: TinyCore 8.0 console prompt
Post by: polikuo on August 12, 2017, 08:49:09 AM
In short, modify ~/.ashrc instead of ~/.bashrc
Code: [Select]
# default $PS1
export PS1="\u@\h:\w\$"
Title: Re: TinyCore 8.0 console prompt
Post by: AlejandroPadrino on August 12, 2017, 11:20:10 AM
Hello Misalf,

I showed your console prompt, it's nice.  But trying to modify my prompt adding desired codes it does not run.  Console prompt I want to put is next:

PS1='\n\033[01;31m(\033[01;33m\($date +'%A %F %T:%S')\033[01;31m)\033[01;35m:\033[01;31m(\033[01;36m\w\033[01;31m)\033[00m\n\033[01;31m[\033[01;32m\u\033[01;35m:\033[01;34m\$\033[01;31m]\033[01;33m>\033[01;37m· '

Where, after showing your prompt, variables are ...

%A - Week day.
%F - Full date, year begining.
%T - Time in 24h format.
%S - Seconds.

I tested all %A-%Z variables, but I can't load these variables if your prompt was not loaded before.  Don't know what I'm doing wrong.  Can you modify my prompt right?
Title: Re: TinyCore 8.0 console prompt
Post by: AlejandroPadrino on August 12, 2017, 09:24:31 PM
At this moment found a temporary solve.  Coming back to "older" colour codes like ${RED} and related, and lower case variables run right using this colour codes.  But at end shows me an ^A symbol that I can't remove (symbol ^ is on upper side of A).  I don't know how to remove that symbol.  :-(
Title: Re: TinyCore 8.0 console prompt
Post by: Misalf on August 13, 2017, 03:42:35 AM
Fixed it
Code: [Select]
PS1='\n\033[01;31m(\033[01;33m$(date +"%A %F %T:%S")\033[01;31m)\033[01;35m:\033[01;31m(\033[01;36m\w\033[01;31m)\033[00m\n\033[01;31m[\033[01;32m\u\033[01;35m:\033[01;34m\$\033[01;31m]\033[01;33m>\033[01;37m· '
But newlines in the prompt have always been troublesome for me.
Title: Re: TinyCore 8.0 console prompt
Post by: AlejandroPadrino on August 14, 2017, 05:05:36 AM
Thank you, I will try it.  :-)
Title: Re: TinyCore 8.0 console prompt
Post by: AlejandroPadrino on August 14, 2017, 12:38:21 PM
Appears to be a sinply change, but it runs.  Thank you.  :-)

finally the running prompts are:

export PS1='\n\033[01;31m(\033[01;33m\$(date '+%a %d %b %G %T')\033[01;31m)\033[01;35m:\033[01;31m(\033[01;36m\w\033[01;31m)\033[00m\n\033[01;31m[\033[01;32m\u\033[01;35m:\033[01;34m\$\033[01;31m]\033[01;33m>\033[01;37m· '

and

export PS1='${RED}(${YELLOW}$(date "+%a %d %b %G %T")${RED})${MAGENTA}:${RED}(${CYAN}\w${RED})${BLACK}\n${RED}[${GREEN}\u${MAGENTA}:${BLUE}\$${RED}]${YELLOW}>${BLACK}${WHITE}· '

... but any of both shows a undesired  at the end of $PS1.  :-(

Is there any solve for this error?
Title: Re: TinyCore 8.0 console prompt
Post by: Misalf on August 14, 2017, 01:04:54 PM
I guess it's due to the middle dot (·) at the end of your prompt. I'd suggest to remove it as well as the newlines (\n) as those things make navigating your command history and editing your command difficult.
If you can't live without it, it may help to configure your locale settings (see getlocale.tcz and its .info file) and/or try Bash.
Title: Re: TinyCore 8.0 console prompt
Post by: AlejandroPadrino on August 22, 2017, 09:18:09 AM
Hello Misalf,

I don't think can be middle dot (·).  This $PS1 value works fine in Mint & Ubuntu Linux.  I tried same after downloading Bash console.  It shows  too.  :-(
Title: Re: TinyCore 8.0 console prompt
Post by: Misalf on August 22, 2017, 03:21:58 PM
If it's just about cosmetics, I think it's best to omit things that don't have a definite purpose.