1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

termcap を入れる

Last updated at Posted at 2019-05-06

screen を使うと画面が乱れるので termcap を入れてみる

gpsmon とかを使うとこんな風に画面が乱れてしまう。
putty.png
読みにくいので termcap データベースを拾ってくる。
(terminfo はファイルが大量にできてしまうので、扱いやすい旧式の termcap にします)

termcap データベースを拾ってきて設置

NCURSES のプロジェクトページにかなり網羅した termcap, terminfo が転がっているのでそれをもらってくる。
termcap は "Development termcap source (gzip'd text via http)" と書いてあるところから。
wget して gzip で解凍。
解凍した tarmcap.src に putty-256color や screen.putty-256color があることを確認して $HOME の下に設置。

> wget https://invisible-island.net/datafiles/current/termcap.src.gz
> gzip -d termcap.src.gz
> grep -e "putty-256color" -e "screen.putty-256color" termcap.src
> mv termcap.src ~/.termcap

putty の設定 (おまけ)

putty でログインするときの端末タイプを putty-256color にしてログインしなおす。
image.png
せっかくなので 256 色表示を確認してみる。

> wget https://raw.githubusercontent.com/zhengkai/config/master/script/256colors2.pl
> perl ./256colors2.pl

image.png
綺麗に見えますね。

では screen に入り...$TERM は自動で正しく設定されるみたいですね。

> echo $TERM
putty-256color
> screen
> echo $TERM
screen.putty-256color

いよいよ gpsmon

さて、お楽しみの gpsmon

> gpsmon localhost:2947:/dev/ttyUSB0

...同じでした。screen に入らずに gpsmon を叩くと大丈夫なんですけども。
でも cgps とかの画面の乱れ方はましになったのでとりあえずこれで。

termcapファイルはいらなかった?

ちょっと見てみると既に terminfo で putty-256color や screen.putty-256color は存在していた模様。ひょっとして termcap ファイルは無駄でした?

> ls -l /usr/share/terminfo/?/*putty-256color
-rw-r--r-- 1 root root 2512 12月 28  2017 /usr/share/terminfo/p/putty-256color
-rw-r--r-- 1 root root 2552 12月 28  2017 /usr/share/terminfo/s/screen.putty-256color

$HOME/.termcap を mv して試してみたら動作は変わらないみたいですね。termcap ファイルは拾ってこなくてよかったかも。

256 color test

色を確認するのは bash 上なら以下のコマンドでも OK (https://wiki.archlinux.jp/r/1dm より)

color
$ (x=`tput op` y=`printf %76s`;for i in {0..256};do o=00$i;echo -e ${o:${#o}-3:3} `tput setaf $i;tput setab $i`${y// /=}$x;done)
# !/bin/bash

# hex test
for i in {0..15};do
	for j in {0..15};do
		color=`printf "0x%x%x" $i $j`
		tput setab $color
		printf " %03d " $color
	done;echo
done;echo

# system color
for i in {0..15};do
	tput setab $i
	printf " %02d " $i
done;echo

# full color
for i in {16..231};do
	tput setab $i
	printf " %03d " $i
	[ $(( ( $i - 15 ) % 6)) -eq 0 ] && echo
done

# gray tone
for i in {232..255};do
	tput setab $i
	printf " %03d " $i
done;echo
tput op

image.png

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?