I would like to "BOLD" print the hostname in the following statement:
export PS1=$USER"@"$(hostname -s):'$PWD>'
Is there a special character I can put before and after the variable to make it bold or blinking?
Thanks.
I would like to "BOLD" print the hostname in the following statement:
export PS1=$USER"@"$(hostname -s):'$PWD>'
Is there a special character I can put before and after the variable to make it bold or blinking?
Thanks.
export PS1='\u@\033[1m`hostname`\033[0m:\w> '
or
export PS1='\u@\033[1m\h\033[0m:\w> '
//Jadu
That's pretty much the copy+paste answer, but it's in bash syntax, which may or may not work for you.
In general, ANSI codes starting with esc [ and ending with m after some numbers work well, but they're not portable to all terminals. A (slightly) more portable solution would be to use tput
PS1=$USER"@"$(tput bold)$(hostname -s)$(tput sgr0):'$PWD>'
See the tput manual page for more information.
Perhaps you will find that the codes output by tput are exactly equivalent to the hard-coded escape codes given above. In theory, tput should be portable to terminals which do not speak ANSI, but I don't know of a real-world situation where this would make an enormous difference.
(The code \033 is octal for the escape character.)
tput method worked for me, thank you all for your generous input.