|
OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below. |
|
Thread Tools | Display Modes |
|
|||
xterm-256color and setaf question
Hello! I need help to figure out how tput setaf works on xterm-256color!
If TERM=xterm, then tput setaf 1 works and changes foreground color to red, but it only supports 8 colors. If TERM=xterm-256color, then tput setaf 1 fails with error Code:
tput: not enough arguments (3) for capability `setaf' Thank you! |
|
|||
Code:
tput bold cup 5 22 setaf 1 smso;print MENU;tput sgr0 |
|
||||
Raw ANSI escape codes also work:
Code:
printf '\033[38;5;196mBah Humbug!\033[0m\n'
__________________
Are you infected with Wetiko? |
|
|||
Thank you, indeed xterm-256color requires 3 arguments for setaf: tput setaf 1 1 1. Still I would like to know the meaning of those 3 arguments.
Here is my little Christmas ksh script: Code:
#!/bin/ksh tput clear tempterm=$TERM TERM=xterm-256color num=22 set -A chararray M e r r y ' ' C h r i s t m a s \! for i in $(jot 16 34 104) do tput bold smso cup 5 $(( num++ )) setaf $i 1 1 printf "${chararray[num-23]}" tput sgr0 done print TERM=$tempterm Code:
printf '\e[48;5;%dm ' $(jot 256 0); printf '\e[0m \n' |
|
||||
Nice script!
The weird thing about those extra setaf arguments is that although they seem to be required, they get ignored: This works for me: Code:
tput bold cup 5 22 setaf 1 Bah, Humbug;print Merry Christmas;tput sgr0 Code:
tput bold cup 5 22 setaf 1 rm /bsd;print Merry Christmas;tput sgr0 Kids, don't try this at home! Some arguments to the rm(1) command will get through and depending on the target there will be tears. I may not have looked hard enough, but the setaf thingie seems underdocumented in OpenBSD. Strange. |
|
|||
Hello!
I've found the answer: setaf if bugged in the version of ncurses OpenBSD using. Setaf behavior is fixed in the latest version of ncurses. With TERM=xterm, I set this nice looking prompt in my .kshrc Code:
PS1='\[$(tput smso setaf 3)\]\W\[$(tput rmso op)\]:\!:\[$(tput setaf 1)\]\$\[$(tput op)\] ' Last edited by sabrina; 30th December 2020 at 05:37 AM. Reason: fixed PS1 string |
|
||||
Please consider reporting the bug.
|
|
|||
Hello!
I have sent the bug report. |
|
|||
Hello!
I received answers from mailing list. Short summary: OpenBSD uses version of ncurses from 11 years ago, modified with local changes. OpenBSD's tput is not from ncurses, it validates the number of arguments separately and that doesn't match what's actually needed by ncurses. Workaround: use anything for the 2nd and 3rd parameters, both the OpenBSD and ncurses tput commands ignore these. e.g. tput setaf 1 1 1. |
Tags |
xterm tput setaf 256color |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
OpenBSD xterm(1) now UTF-8 by default | J65nko | News | 1 | 10th March 2016 07:22 PM |
Getting console messages in xterm? | spiderpig | OpenBSD General | 1 | 30th August 2015 12:17 AM |
xterm is not a login shell except on blackbox | daemonfowl | NetBSD General | 6 | 1st August 2012 03:59 AM |
is there a way to cut and paste text from xterm ? | daemonfowl | OpenBSD General | 6 | 30th January 2012 08:03 PM |
xterm End key | graudeejs | General software and network | 1 | 24th August 2008 04:55 PM |