Tmux on AIX

Hi, I'm going to build tmux from source on AIX 7.1. Reasons:

  • Terminal multiplexers are a must :slight_smile:
  • tmux is to GNU screen (part of Toolbox) what vim is to the default AIX vi.
  • The later versions of tmux are considerably nicer than older versions.
  • Also, looks like IBM compiled screen without 256 colour support!

I'll post updates once I manage to build and run it successfully. If there is any interest I can provide detailed instructions, maybe even an installp package.

Yes, please post all your steps so others who might be interested can have the benefit of your knowledge.

Thanks.

Thanks! I have successfully compiled tmux on my AIX 7.1 machine :). Here's a run down of what needs to be done:

  1. Download latest tmux source code from github:
git clone https://github.com/tmux/tmux.git

git is available from the AIX Toolbox. The best way to install is to set up yum. I can help if you get into trouble here.

  1. Download the dependency libevent:
wget https://github.com/libevent/libevent/releases/download/release-2.1.11-stable/libevent-2.1.11-stable.tar.gz
  1. Patch libevent code using the following diff (using patch command or by hand):
diff libevent/libevent-2.1.11-stable/include/event2/event-config.h.original libevent/libevent-2.1.11-stable/include/event2/event-config.h
524c524
< #define _LARGE_FILES 1
---
> //#define _LARGE_FILES 1
  1. Compile libevent:
./configure CFLAGS="-g0" CXXFLAGS="-g0" --prefix=/home/users/software
make
make install

Note that my version of AIX has an issue with the as assembler which requires the CFLAGS="-g0" CXXFLAGS="-g0" flags. If your OS is fully up to date at the latest TL then it should not be necessary (please test first without the flags, and if it works I'd appreciate a post with the oslevel -s output).

  1. Install (using yum) the following tmux dependencies: automake, pkg-config, bison (for yacc). Then add /usr/linux/bin to PATH . To test your path run
which yacc
  1. Patch tmux code using the following diffs:
diff --git a/tmux.h b/tmux.h
index 41a09351..df5ba6cc 100644
--- a/tmux.h
+++ b/tmux.h
@@ -2666,4 +2666,9 @@ struct window_pane *spawn_pane(struct spawn_context *, char **);
 /* regsub.c */
 char           *regsub(const char *, const char *, const char *, int);

+/* define missing symbols */
+#define FNM_CASEFOLD  0x10  /* Case insensitive search. */
+#define REG_STARTEND (1 << 2)
+#define _PATH_DEFPATH "/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:/usr/linux/bin"
+
  #endif /* TMUX_H */
diff --git a/tty.c b/tty.c
index 1658fb74..2068c459 100644
--- a/tty.c
+++ b/tty.c
@@ -744,11 +744,11 @@ tty_window_offset1(struct tty *tty, u_int *ox, u_int *oy, u_int *sx, u_int *sy)
        struct client           *c = tty->client;
        struct window           *w = c->session->curw->window;
        struct window_pane      *wp = w->active;
-       u_int                    cx, cy, lines;
+       u_int                    cx, cy, newlines;

-       lines = status_line_size(c);
+       newlines = status_line_size(c);

-       if (tty->sx >= w->sx && tty->sy - lines >= w->sy) {
+       if (tty->sx >= w->sx && tty->sy - newlines >= w->sy) {
                *ox = 0;
                *oy = 0;
                *sx = w->sx;
@@ -759,7 +759,7 @@ tty_window_offset1(struct tty *tty, u_int *ox, u_int *oy, u_int *sx, u_int *sy)
        }

        *sx = tty->sx;
-       *sy = tty->sy - lines;
+       *sy = tty->sy - newlines;

        if (c->pan_window == w) {
                if (*sx >= w->sx)
@@ -910,18 +910,18 @@ static int
 tty_is_visible(struct tty *tty, const struct tty_ctx *ctx, u_int px, u_int py,
     u_int nx, u_int ny)
 {
-       u_int   xoff = ctx->xoff + px, yoff = ctx->yoff + py, lines;
+       u_int   xoff = ctx->xoff + px, yoff = ctx->yoff + py, newlines;

        if (!ctx->bigger)
                return (1);

        if (status_at_line(tty->client) == 0)
-               lines = status_line_size(tty->client);
+               newlines = status_line_size(tty->client);
        else
-               lines = 0;
+               newlines = 0;

        if (xoff + nx <= ctx->ox || xoff >= ctx->ox + ctx->sx ||
-           yoff + ny <= ctx->oy || yoff >= lines + ctx->oy + ctx->sy)
+           yoff + ny <= ctx->oy || yoff >= newlines + ctx->oy + ctx->sy)
                return (0);
        return (1);
  }

In the above we are simple renaming the variable lines to newlines to avoid a conflict.

  1. Build tmux:
./configure CFLAGS="-g0" CXXFLAGS="-g0" --prefix=/home/users/software LDFLAGS=-L/home/users/software/lib CPPFLAGS=-I/home/users/software/include/
make
make install

Once again, please test first without the CFLAGS="-g0" CXXFLAGS="-g0" flags.

  1. tmux requires the UTF-8 locale. You can install it from the AIX install DVD 1 using:
installp -acgYd /cdmnt bos.loc.utf.EN_US

Assuming you have mounted the DVD on /cdmnt. Next set the locale in your shell:

export LANG=EN_US.UTF-8
export LC_ALL=EN_US.UTF-8

Check using the locale command.

The install is now complete. Please read the next post for information about how to use 256 colours.

3 Likes

Ok, tmux is now installed and running! Let's make it beautiful :slight_smile:

  1. Set terminal to 256 colour mode by setting TERM in your shell:
export TERM=xterm-256color
  1. The IBM supplied terminfo settings for xterm-256color (use infocmp xterm-256color to view it) are missing the the entries for the setab and setaf features, which tell the terminal how to set background and foreground colours, respectively. Run man terminfo and search for setb , setf . Running tmux info inside a tmux session will show the missing entries. This is fixed by the following code in .tmux.conf:
# Supply missing terminal features: set foreground/background colours.
 set-option -s terminal-overrides[0] "xterm-256*:setab=\e[4%p1%dm:setaf=\e[3%p1%dm"

Now you should have 256 colours. I am attaching my .tmux.conf as an example.

# Supply missing terminal features: set foreground/background colours.
set-option -s terminal-overrides[0] "xterm-256*:setab=\e[4%p1%dm:setaf=\e[3%p1%dm"

# Enable mouse
set-option -g mouse on

# Remap window navigation to vim
unbind-key j
bind-key j select-pane -D
unbind-key k
bind-key k select-pane -U
unbind-key h
bind-key h select-pane -L
unbind-key l
bind-key l select-pane -R

unbind-key C-v
bind-key C-v last-window

# Access clipboard
# move x clipboard into tmux paste buffer
unbind-key C-p
bind-key C-p run "tmux set-buffer \"$(xclip -o -selection clipboard)\"; tmux paste-buffer"
# move tmux copy buffer into x clipboard
unbind-key C-y
bind-key C-y run "tmux save-buffer - | xclip -i -selection clipboard > /dev/null"

# Set 256 colour terminal
#set -g default-terminal "screen-256color"

# Status bar colour
set -g status-bg colour28
set -g status-fg colour255

# Activity
setw -g monitor-activity on
set -g visual-activity off
# Highlight active window
setw -g window-status-current-style bg=colour19

# Additional mouse setup
bind-key -n MouseDown3Status new-window -a -t=
bind-key -n MouseDrag1Status swap-window -t=

# Intelligent scrolling
bind -n WheelUpPane if-shell -Ft= '#{?pane_in_mode,1,#{mouse_any_flag}}' \
        'send -Mt=' 'if-shell -Ft= "#{alternate_on}" \
        "send -t= Up" "copy-mode -et=\; send -Mt="'
bind -n WheelDownPane if-shell -Ft = '#{?pane_in_mode,1,#{mouse_any_flag}}' \
        'send -Mt=' 'if-shell -Ft= "#{alternate_on}" \
        "send -t= Down" "send -Mt="'

# For emacs
setw -g xterm-keys on

# History for Ctrl-B :
set -g history-file ~/.tmux_history
3 Likes

FYI, I talked with the tmux developer, Nicholas, and intend to support tmux development on AIX since he does not have access to an AIX box. Right now there is no official support for AIX and I hope to improve on that :slight_smile:

I'm currently working on fixing a couple of small issues.

1 Like
Moderator comments were removed during original forum migration.

FWIW, I use tmux on Linux and have various problems with the buffer; so I only use it when absolutely necessary. I actually have better luck with nohup because I don't lose logging and error information due to issues with the tmux buffer.

Maybe there is some config parameter on tmux I need to set? But have been too busy to look into it.....

1 Like

Thanks for the feedback. I moved and lost access to my AIX boxes for a while, but hoping to bring them back online in a few days. I intend to build the latest tmux git and do some testing. Will post back soon with updates.

BTW the IBM supplied screen utility is quite stable. It's not as nice as tmux but works well.

1 Like

Right, the classic screen works good enough and supports all *nix platforms.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.