Bash command line on z/OS

As a new hire in IBM Systems, it’s a constant process learning all of the tricks and tips for z/OS that have accumulated over its long history. When I first started a few months ago, one of the biggest problems I ran into was not having a feature that is near and dear to every developer’s heart: terminal autocomplete.
After an initial search, I saw that autocomplete existed, but the documentation I found was way out of my wheelhouse. It was mostly targeted towards z/OS system administrators.
Luckily, there was a better solution.
Bash for z/OS
Autocomplete and history is a bash shell thing, so you’ll need to stop using your usual Bourne shell to get this functionally.
The easiest solution I found was Bash for z/OS, which can be downloaded for free with a Rocket community account.
The installation is fairly simple. Create a community account, download the product, and untar it!
Setting my Default Shell: The Journey
For some reason, switching my shell wasn’t an extremely easy task.
Usually, you can swap the default shell you’re using by putting the exec command in your ~/.profile file. However, per usual, I’m the edge case. Doing so would completely break my terminal:
kalebs-mbp:~ kalebporter@ibm.com$ {redacted, sshing to a system}
??????@?????~a???a??????a???a??????????@?????~??????????@????~???????????@????m????~a???a???a????a??K?m????@?@`?@a???a???????a???a??????K??@?^@????@@@K@a???a???????a???a??????K??????????@????m????~a???a???a????a??K?m????????@????
Translation: “Why are you doing this to me???” — Computer
Luckily, Rosaland Radcliffe was able to help me. She identified that this looked like ASCII to EBCDIC, and we eventually found the workaround. All that’s needed is an additional line in the profile file: export _BPXK_AUTOCVT=ON
Full Solution
Here are the complete steps:
- Install Bash for z/OS
- Create a .profile in your home directory. (touch ~/.profile)
- Add the following line to your .profile to switch your default shell: exec {bash location} (e.g exec /var/rocket/bin/bash)
- Add the following line to your .profile to enable ASCII support: export _BPXK_AUTOCVT=ON (some people don’t have this issue, use it if you need it)
- Start a new sesion and enjoy your modern terminal on z/OS!
Alternatively, if you would like to avoid using a .profile file, you can use tsocmd. Keep in mind you may lack permissions needed, and may need to contact your system administrator to do this.
tsocmd “ALTUSER {user} OMVS(Program({bash_location}))”
Notes
- If you don’t specify which shell for your *.sh scripts to use, you’ll run into syntax issues because you’re using a different shell.
- Have a backup terminal session open while configuring this, just so you can undo your changes. In my case, when updating my OMVS settings (which resulted in my terminal breaking), I couldn’t get back in.