You have certainly noticed the recent efforts to enhance the user experience on z/OS, and especially on z/OS Unix Systems Services (USS). With the recent announcement of IBM Open Enterprise Foundation, some popular open-source tools are available at no cost and packaged together in an SMP/E installable format. Some of these tools, like Git and curl, are fundamental to support DevOps and automation mechanisms required by open-source based CI/CD pipelines.
This a great start to provide users and developers a good experience with their working environment on z/OS Unix Systems Services, but this is not enough! Thanks to the z/OS Open Tools project, we now have dozens (even hundreds) of open-source tools available on the z/OS platform, that were ported to execute natively. Amongst these tools, we can find very convenient utilities that facilitate the life of developers and administrators: Vim, less (both are also part of the IBM Open Enterprise Foundation), groovy, prometheus, grafana, sed, grep... The list is long, but we'll focus on tmux and ViM today, as these tools are widely used in Linux's world to speed up user's productivity.
Setting up the z/OS Unix Systems Services terminal
Let's start by tweaking with the environment itself. Typically, you would connect to USS through SSH to get access to a terminal and the command-line interface provided by the shell environment. Each terminal has its own characteristics and some specific capabilities, which are described in the terminfo database. These information are used by shell applications to correctly display their character-based interface. This is often used by full-screen applications like Vim, but other applications, like Bash, can benefit from these information as well.
Switching to a different terminal definition
z/OS is shipped with existing terminal definitions, but depending on how you connect to the system, some capabilities may be disabled. The default terminal is xterm, which can display 256 colors with bash but not with all applications (like tmux that we will use later). The terminal definition xterm-256color should be used instead. To check the capabilities of your current terminal on z/OS, you can use the infocmp command.
To switch to a different terminal definition, it's as easy as exporting the TERM environment variable with the xterm-256color value:
export TERM=xterm-256color
Adding a new terminal definition
The following steps are only necessary if the xterm-256color terminal doesn't fulfill your requirements. Thankfully, additional terminal definitions can be added to the USS environment, as described on this page, but an important step is missing about the "extraction" of the terminal information from a Linux system. After identifying the terminal definition you want to use from your Linux system, you can issue the following commands on your Linux system to extract the definition from the terminfo database to a flat file (I've chosen putty-256color in the following example):
infocmp putty-256color > putty-256color.ti
You should now have a file called putty-256color.ti, that contains the terminal definition you're interested in.
On z/OS, it is advised to store these definitions in a specific folder, typically called terminfo. The putty-256color.ti file must be transferred to USS as a text file, this can be achieved with an scp command, that you will need to adapt:
scp putty-256color.ti MDALBIN@zos:/u/mdalbin/terminfo
As described in the mentioned IBM documentation, you need to export the TERMINFO environment variable to point to the location where you put the definition file:
export TERMINFO=/u/mdalbin/terminfo
And use the tic command to build the database entry:
tic /u/mdalbin/terminfo/putty-256color.ti
Once done, export the TERM variable to putty-256color, which is the terminal definition name:
export TERM=putty-256color
Using the 256 colors
Whether you chose to use xterm-256color or not, you can test the colors that are now available using this simple loop in your shell:
for COLOR in {1..255}; do echo -en "\e[38;5;${COLOR}m${COLOR} "; done; echo;
Tada! These colors can now be used in your terminal.
To have this configuration preserved, you would need to add the TERM variable environment added to your .profile:
export TERM=xterm-256color
You could also benefit from these colors in your bash prompt, also known as the PS1 variable. Exporting the PS1 variable with the following value will display a slightly more friendly prompt (you can choose your own colors)!
export PS1="\e[38;5;160m\${LOGNAME}\e[38;5;255m - [\e[38;5;115m\\w\e[38;5;255m]\n\e[38;5;210m->\e[38;5;7m "
Also, if you are using PuTTY (as I do) to connect to USS, you should check that the 256-colour terminals are allowed (the second checkbox in the following screenshot):
Using tmux on USS
As mentioned on its project webpage, tmux is a terminal multiplexer, where you can have multiple sessions, in which you can have multiple tabs, in which you can have multiple panels. Each panel is a shell environment on its own, and the panels are running distinctively. One big advantage of tmux is that you can detach from a session, when you leave your desk at the end of the day, and re-attach to the same session the day after without losing the context of the commands that were entered. It is also very convenient for long-running commands that can execute in the background while you're away.
Installing tmux using the zopen Package Manager is fairly straightforward through the zopen command:
Beware that the ncurses package needs to be installed too, if it's not already installed.
tmux has a lot of capabilities and works with a configuration file called .tmux.conf, located in the HOME directory of each user. In this file, you can define the design of your tmux display (colors, location of information), the key bindings and the behavior of tmux in response to events like the bell ringing or the mouse. The following .tmux.conf file is given as an example, and adds some interesting features: to navigate between windows in a session, you can F10 and F11 (just like in ISPF!), mouse is enabled (making it easier to navigate between panes and windows, and providing easily accessible scrolling capabilities). You still need to get familiar with other typical tmux commands to attach to and detach from sessions, create new windows and split the window into panes. Additional binding may be required if some key combinations are difficult to remember. This page provides all the necessary information to customize the behavior of tmux, and lots of examples can be found by browsing through the web.
# enable mouse
set -g mouse on
# switch panes using Alt-arrow without prefix
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
bind-key -n F10 previous-window
bind-key -n F11 next-window
# DESIGN TWEAKS
# don't do anything when a 'bell' rings
set -g visual-activity off
set -g visual-bell off
set -g visual-silence off
setw -g monitor-activity off
set -g bell-action none
# clock mode
setw -g clock-mode-colour colour117
# copy mode
setw -g mode-style 'fg=colour1 bg=colour18 bold'
# pane borders
set -g pane-border-style 'fg=colour236'
set -g pane-active-border-style 'fg=colour27'
# statusbar
set -g status-position bottom
set -g status-justify left
set -g status-style 'fg=colour117 bg=color17'
set -g status-left ''
set -g status-right '%Y-%m-%d %H:%M '
set -g status-right-length 50
set -g status-left-length 10
setw -g window-status-current-style 'fg=colour255 bg=colour27 bold'
setw -g window-status-current-format ' #I #W #F '
setw -g window-status-style 'fg=colour242 dim'
setw -g window-status-format ' #I #W #F '
setw -g window-status-bell-style 'fg=colour2 bg=colour1 bold'
setw -g window-active-style 'bg=color234'
# messages
set -g message-style 'fg=colour2 bg=colour0 bold'
If not automatically picked up, you can enable this tmux configuration by entering the following command:
tmux source-file .tmux.conf
Again, color schema can be changed according to your likes!
I've been experiencing a display issue using PuTTY, that was not correctly displaying the panel borders when windows are split. Changing the following setting (Remote character set to "Use font encoding") helped solve the situation:
Before the change:
After the change:
Using ViM
The vi utility comes by default with z/OS, and is useful to edit text on USS, but this version is fairly basic and can be considered as outdated. Luckily, its successor ViM is available through the z/OS Open Tools project, and can be installed with zopen install vim command. Once installed, it is advised to make the vi command an alias to vim. The following line can be added to your .profile:
ViM provides new features compared to vi, like the capacity to use color schemes. The configuration can be set in the .vimrc file in the HOME directory. Here is an example of such a file:
set nocompatible
colo darkblue
syntax on
set tabstop =2
set softtabstop =2
set shiftwidth =2
set expandtab
In ViM, you can test the color scheme by entering :colo followed by a color scheme name. The available color schemes can be found by entering :colo (followed by a space) and by pressing Ctrl+d:
The following picture shows a tmux window split vertically with two ViM panels, using different color schemes:
Of course, ViM doesn't replace a fully-fledged IDE, like IBM Developer for z/OS or VSCode, but still provides editing capabilities that can help for quick actions on files.
This short blog post highlights some of the utilities that can be helpful in daily operations for developers and system administrators. The z/OS Open Tools project proposes a lot more utilities you can try, and you can potentially participate by porting your favorite Unix utility to Unix System Services! Let me know in the comments which utilities you're using that you would like to see ported to z/OS, if not already existing.