Tiny Core Linux
General TC => General TC Talk => Topic started by: AlejandroPadrino on July 03, 2011, 12:36:49 PM
-
Hello, I want to use my own prompt for Linux into TinyCore 3.7.1 console. I use this in Ubuntu ...
export PS1="\[$(tput bold; tput setaf 1)($(tput bold; tput setaf 3)\d \t$(tput bold; tput setaf 1))$(tput bold; tput setaf 5):$(tput bold; tput setaf 1)[$(tput bold; tput setaf 2)\u$(tput bold; tput setaf 5):$(tput bold; tput setaf 6)\w$(tput bold; tput setaf 1)]$(tput bold; tput setaf 5)\$$(tput bold; tput setaf 3)>$(tput bold; tput setaf 7)ยท "
I can't make it in TinyCore because there is no tput & setaf commands. Using escape sequences does not run. Can change colors, but codes \d and \t (and next codes I supposed) do not run.
Can you help me?
-
As far as I can tell you've got two main reasons here why TC in it's "base" configuration will differ from Ubuntu:
(1) The 'tput' command is not included in the Core initrd, but would be available via the 'ncurses-utils.tcz' extension, and
(2) the prompting escape codes '\d' and '\t' are not supported by the default shell (i.e. BusyBox 'ash', which at least supports '\u', '\w', and '\$'). The missing ones would become available if you'd change your shell with the help of the 'bash.tcz' extension.
So installation of two extensions (plus a change of your default shell in '/etc/passwd') would allow you to use the 'PS1' setting from Ubuntu in an unchanged fashion.
EDIT: I've now come up with a way to express '\d' and '\t' even in 'ash': by replacing \d \t with $(date "+%a %b %d %T") the requirement to install 'bash' is gone. Furthermore I've used in my testing just some of the colors which are already defined in '/etc/init.d/tc-functions' so with
export PS1='${RED}(${YELLOW}$(date "+%a %b %d %T")${RED}):[${GREEN}\u${RED}:${GREEN}\w${RED}]\$${NORMAL}>- '
I managed to produce a prompt not too dissimilar to the original version. So I don't see a problem to also "ditch" the requirement for the 'ncurses-utils.tcz' extension.
IMHO the whole prompt looks pretty "sick", but as we know "Beauty is in the eye of the beholder" ...
-
Wow, showing that prompt must be really slow with all those calls to tput. I remember how I could feel the difference of even one date call on a P3.
// Just random comments, maro you have some great and in-depth advice there.
-
Since 1990 with my old and loved D.O.S. environment, I always use prompt colors. You can use attached file, if like, to save prompt string into .bashrc and .profile home files.
Thank you very much.