I like tabs to be displayed narrower than 8 spaces. Sometimes I cat or print files to stdout on a console. I thought setting terminal tab width would be pretty straightforward but I must be going about it the wrong way. I'm running SuSE 9.1 on an Athlon.
man tabs looked promising. However, although the documentation appears to have been installed by default, the command wasn't. I looked at stty, setterm, and tput. setterm's -regtabs option looked right. However, setterm -regtabs 4 has no effect, despite the fact that there is no error message and the return code indicates no error. Maybe tput will help tput it 8 tput it 4 8 except nothing happens.
Any suggestions on how to set the tab width? Ideally, I would like this to be command-based instead of termcap-based so it can easily be user-specific and machine independent. Thanks a lot! -Robert Dick-
Robert wrote regarding '[SLE] Setting console tab width' on Sat, Sep 11 at 14:48:
I like tabs to be displayed narrower than 8 spaces. Sometimes I cat or print files to stdout on a console. I thought setting terminal tab width would be pretty straightforward but I must be going about it the wrong way. I'm running SuSE 9.1 on an Athlon.
man tabs looked promising. However, although the documentation appears to have been installed by default, the command wasn't. I looked at stty, setterm, and tput. setterm's -regtabs option looked right. However, setterm -regtabs 4 has no effect, despite the fact that there is no error message and the return code indicates no error. Maybe tput will help tput it 8 tput it 4 8 except nothing happens.
Any suggestions on how to set the tab width? Ideally, I would like this to be command-based instead of termcap-based so it can easily be user-specific and machine independent.
It appears that you're having problems on a per-program basis. As a test, I used echo's '-e' option to print a tab char. Here's what I get: dsauer@danny-pc:~> setterm -regtabs 8 dsauer@danny-pc:~> echo -e 'moo\tmoo\nm\tmoo' moo moo m moo dsauer@danny-pc:~> setterm -regtabs 4 dsauer@danny-pc:~> echo -e 'moo\tmoo\nm\tmoo' moo moo m moo That's on a 9.1 workstation, but it works the same on a 7.1 system, so I'd expect it to work for you. It's limited to the terminal's output, though, and won't neccesarily work inside other programs that handle the terminal directly. So, if you fire up vim or even less, it won't work as well. It'll work through "more", though. You probably need to set your tabstops per application if you want something other than the huge 8 spaces commonly used. --Danny
dsauer@danny-pc:~> setterm -regtabs 4 dsauer@danny-pc:~> echo -e 'moo\tmoo\nm\tmoo' moo moo m moo
Thanks a lot for the help! Your result surprised me. I went back and checked it on console. 'setterm -regtabs' does work on linux virtual terminals. It doesn't normally work in KDE's konsole, xterm, or rxvt. However, it works for those terminals if I first 'setenv TERM linux' instead of leaving it set to 'xterm'. Is there a different way of setting displayed tab width for the 'xterm' terminal type? Google has been less helpful than usual on this.
That's on a 9.1 workstation, but it works the same on a 7.1 system, so I'd expect it to work for you. It's limited to the terminal's output, though, and won't neccesarily work inside other programs that handle the terminal directly. So, if you fire up vim or even less, it won't work as well. It'll work through "more", though. You probably need to set your tabstops per application if you want something other than the huge 8 spaces commonly used.
I set it in the configuration files for those editors. My main problems are direct output, cat, and tee. It looks like I need to find a way to set tab width for 'xterm's. I guess I could also tell my terminals that they are 'linux' terminals. However, I'm afraid that might have side effects. Thanks again, -Robert Dick-
Robert wrote regarding 'Re: [SLE] Setting console tab width' on Mon, Sep 13 at 13:36:
dsauer@danny-pc:~> setterm -regtabs 4 dsauer@danny-pc:~> echo -e 'moo\tmoo\nm\tmoo' moo moo m moo
Thanks a lot for the help!
Your result surprised me. I went back and checked it on console. 'setterm -regtabs' does work on linux virtual terminals. It doesn't normally work in KDE's konsole, xterm, or rxvt. However, it works for those terminals if I first 'setenv TERM linux' instead of leaving it set to 'xterm'. Is there a different way of setting displayed tab width for the 'xterm' terminal type? Google has been less helpful than usual on this.
Well, I looked at /etc/termcap and noticed that there's a line that says it#8 somewhere for most terminals. I'm willing to bet that you could change that file with, say, perl: perl -pi.bak -e's/it#8/it#4/' /etc/termcap you'll have /etc/termcap.bak as a backup if this screws things up... I dunno if that'll help or not, but it's possible. :)
That's on a 9.1 workstation, but it works the same on a 7.1 system, so I'd expect it to work for you. It's limited to the terminal's output, though, and won't neccesarily work inside other programs that handle the terminal directly. So, if you fire up vim or even less, it won't work as well. It'll work through "more", though. You probably need to set your tabstops per application if you want something other than the huge 8 spaces commonly used.
I set it in the configuration files for those editors. My main problems are direct output, cat, and tee. It looks like I need to find a way to set tab width for 'xterm's. I guess I could also tell my terminals that they are 'linux' terminals. However, I'm afraid that might have side effects.
I've been setting my terminal string to linux for a while now, and it works fine for most everything but a few older programs that don't get that "linux" is a color terminal. They just default to something like vt100 or similar. --Danny
Well, I looked at /etc/termcap and noticed that there's a line that says it#8 somewhere for most terminals. I'm willing to bet that you could change that file with, say, perl: perl -pi.bak -e's/it#8/it#4/' /etc/termcap you'll have /etc/termcap.bak as a backup if this screws things up...
I dunno if that'll help or not, but it's possible. :)
'printenv TERM' says 'xterm'. However, when I change /etc/termcap as follows xterm|xterm terminal emulator (X Window System):\ :am:km:mi:ms:xn:\ :co#80:it#4:li#24:\ 'echo "a\tb"' still gives eight spaces for the tab instead of four. I think it's ignored in favor of terminfo. Anyway, changing system configuration files isn't ideal. This should be specific to a user (.profile or .cshrc), not specific to a machine.
I've been setting my terminal string to linux for a while now, and it works fine for most everything but a few older programs that don't get that "linux" is a color terminal. They just default to something like vt100 or similar.
I guess I can just use 'setenv TERM linux'. I had assumed I ended up with a default of 'xterm' for a reason. Thanks, -Robert Dick-
participants (2)
-
Danny Sauer
-
Robert Dick