1

Being somewhat green with OpenVMS, but still trying to "get stuff done", I'd like to make things a little easier in respect of setting terminal height and width.

Presently I can SSH to an OpenVMS-8.4-based server (from a pane within my Tmux session), but, unlike on Linux, the DCL command shell does not automatically pick up my terminal size.

That is, after SSH-ing in, and issuing SHOW TERM, I get:

Terminal: _FTA31:     Device_Type: VT200_Series  Owner: <elided>

Input:    9600     LFfill:  0      Width:  80      Parity: None
Output:   9600     CRfill:  0      Page:   24

Terminal Characteristics:
    Interactive        Echo               Type_ahead         No Escape
    Hostsync           TTsync             Lowercase          Tab
    Wrap               Scope              No Remote          Eightbit
    Broadcast          No Readsync        No Form            Fulldup
    No Modem           No Local_echo      No Autobaud        No Hangup
    No Brdcstmbx       No DMA             No Altypeahd       Set_speed
    No Commsync        Line Editing       Overstrike editing No Fallback
    No Dialup          Secure server      No Disconnect      No Pasthru
    No Syspassword     No SIXEL Graphics  No Soft Characters No Printer Port
    Numeric Keypad     ANSI_CRT           No Regis           No Block_mode
    Advanced_video     Edit_mode          DEC_CRT            DEC_CRT2
    No DEC_CRT3        No DEC_CRT4        No DEC_CRT5        No Ansi_Color
    VMS Style Input    <CTRL-H> Backspace

The important bits above are Width: 80 and Page: 24. This despite the fact that issuing a Tmux :display "H: #{pane_height}, W: #{pane_width}" shows the following:

 H: 51, W: 92

The terminal characteristics then don't get updated automatically, and that may not be surprising given that the terminal seems to be being interpreted as "VT200_Series". In any case, I've noticed that Tmux is fairly flexible in the sorts of ways it can interact with the terminal, in particular, there's a facility to be able to display a host of terminal attributes by means of the display-message command; as indicated above, one can "get at" the width and height by means of something like:

 :display-message -p "Width: #{pane_width}, Height: #{pane_height}"

The -p indicates that the result should be output to stdout (Tmux clears the display and shows the result).

Also, it's possible to set the data in a buffer explicitly by means of the Tmux command set-buffer, like so:

 :set-buffer "Mary had a little lamb..."

And paste the result to a pane, as if it had been entered interactively, using the paste-buffer Tmux command.

What I'd like to do then is something along these lines:

 :setb "SET TERM/PAGE=#{pane_height}/WIDTH=#{pane_width}";\
  pasteb;\
  send Enter

Of course, the SET TERM/ ... bit explicitly sets the terminal height and width respectively in OpenVMS.

Sadly, though, it looks like the data parameter of the set-buffer command does not undergo "special variable" replacement.

Being somewhat new to both OpenVMS and Tmux, I need some guidance as to how I can do what I need to do here. An alternative, I guess is just to always use a terminal of a certain size and hard-code the size in my LOGIN.COM script, but I would like "first prize" which is the ability to set that dynamically (if I could get the idea above to work, I would, of course use a bind-key setting to be able to invoke it quickly).

Eric Smith
  • 249
  • 1
  • 4
  • 9

1 Answers1

1

You can use Tmux's run-shell command - as per the man page:

run-shell -b [-t target-pane] shell-command

... shell-command is expanded using the rules specified in the
FORMATS section ...

The FORMATS section describes how strings can be formatted through substitution operations like "#{pane_width}".

So, with run-shell one can call a shell script, passing it any piece of information relating to the Tmux session, client, window or pane. Tmux also allows one to issue commands to the server, directed at a pane from the command-line. The necessary shell script to emit the DCL command to set the terminal width and height becomes:

#!/usr/bin/env sh

# We're assuming the pane identifier is passed as the first
# argument.
#
PANE=$1

# It's possible to "fetch" information by invoking the
# Tmux display-message command (short form: display) and 
# passing it the pane identifier with the target (-t) option.
#
WIDTH=$( tmux display -t $PANE -p "#{pane_width}" )
HEIGHT=$( tmux display -t $PANE -p "#{pane_height}" )

#
# Construct the DCL command to set terminal width and
# height explicitly.
#
CMD="SET TERM/PAGE=$HEIGHT/WIDTH=$WIDTH"

#
# Set the buffer to contain the DCL command string.
#
tmux setb "$CMD"

#
# Paste the buffer contents to the relevant pane.
#
tmux pasteb -t $PANE

#
# Press "Enter" in the relevant pane to execute the DCL command.
#
tmux send -t $PANE Enter

What remains then is to set up a bound key which will invoke run-shell, calling the above script and passing it the "current" pane identifier as the one and only argument:

bind-key C-r run-shell "~/bin/resizevms.sh #{pane_id}"

Put that in your ~/.tmux.conf and after you've logged in, a quick C-b C-r will set things up for you.

Eric Smith
  • 249
  • 1
  • 4
  • 9