WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: TinyCore 8.0 console prompt  (Read 3444 times)

Offline AlejandroPadrino

  • Full Member
  • ***
  • Posts: 143
TinyCore 8.0 console prompt
« on: August 11, 2017, 09: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.
« Last Edit: August 11, 2017, 09:40:05 PM by AlejandroPadrino »

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11047
Re: TinyCore 8.0 console prompt
« Reply #1 on: August 12, 2017, 04:12:03 AM »
Could be you used bash previously? The busybox config option for that is still enabled.
The only barriers that can stop you are the ones you create yourself.

Offline AlejandroPadrino

  • Full Member
  • ***
  • Posts: 143
Re: TinyCore 8.0 console prompt
« Reply #2 on: August 12, 2017, 09: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?

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: TinyCore 8.0 console prompt
« Reply #3 on: August 12, 2017, 09: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]:~/$
« Last Edit: August 12, 2017, 09:28:40 AM by Misalf »
Download a copy and keep it handy: Core book ;)

Offline polikuo

  • Hero Member
  • *****
  • Posts: 740
Re: TinyCore 8.0 console prompt
« Reply #4 on: August 12, 2017, 11:49:09 AM »
In short, modify ~/.ashrc instead of ~/.bashrc
Code: [Select]
# default $PS1
export PS1="\u@\h:\w\$"

Offline AlejandroPadrino

  • Full Member
  • ***
  • Posts: 143
Re: TinyCore 8.0 console prompt
« Reply #5 on: August 12, 2017, 02:20:10 PM »
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?
« Last Edit: August 12, 2017, 02:27:58 PM by AlejandroPadrino »

Offline AlejandroPadrino

  • Full Member
  • ***
  • Posts: 143
Re: TinyCore 8.0 console prompt
« Reply #6 on: August 13, 2017, 12:24:31 AM »
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.  :-(

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: TinyCore 8.0 console prompt
« Reply #7 on: August 13, 2017, 06: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.
Download a copy and keep it handy: Core book ;)

Offline AlejandroPadrino

  • Full Member
  • ***
  • Posts: 143
Re: TinyCore 8.0 console prompt
« Reply #8 on: August 14, 2017, 08:05:36 AM »
Thank you, I will try it.  :-)

Offline AlejandroPadrino

  • Full Member
  • ***
  • Posts: 143
Re: TinyCore 8.0 console prompt
« Reply #9 on: August 14, 2017, 03: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?

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: TinyCore 8.0 console prompt
« Reply #10 on: August 14, 2017, 04: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.
Download a copy and keep it handy: Core book ;)

Offline AlejandroPadrino

  • Full Member
  • ***
  • Posts: 143
Re: TinyCore 8.0 console prompt
« Reply #11 on: August 22, 2017, 12:18:09 PM »
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.  :-(

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: TinyCore 8.0 console prompt
« Reply #12 on: August 22, 2017, 06:21:58 PM »
If it's just about cosmetics, I think it's best to omit things that don't have a definite purpose.
Download a copy and keep it handy: Core book ;)