Quote:
Originally Posted by Leo Simon
Hi
I have multiple xterm sessions open at once. They have different numbers of columns. I want my editor (vi) to be able to distinguish between sessions with many and sessions with few columns. If I could set an environment variable when I open an xterm session, all would be fine, but am unable to do this. The following *should* work I believe,
"xterm -e "setenv LINELENGTH=178", but whenever I use the -e flag, the xterm session flashes on then off. Another alternative that would work is if I could read the Identify table that I can get from left-clicking at the top left corner of the session screen. Then I could parse the Geometry field. But I'm unable to call up the that table from within a shell.
Any help would be most appreciated!
Leo
|
That's to be expected. You are not opening a shell so it just runs that command and exits.
You need to run bash (or you could run vim or whatever directly if that's all you need, that way you don't waste memory on something you won't be using anyway).
So the suggestion above should work, but there's no need really to be that cryptic, just exporting the variable on the current shell will work the same.
Code:
$ export foo=bar
$ urxvtc #or xterm or whatever
#in the new term
$ echo $foo
bar
When a variable is marked for exportation, it's copied into the environment of all the new subshells that are opened from that one where you exported the variable.
PS: it really can be even simpler: