Skip to content

moulti diff

moulti diff loads diff files into Moulti. Specifically, it creates:

  • a step widget to show metadata (e.g. Git commit description)
  • one divider widget per altered file
  • one step per chunk

Important: moulti diff only supports the unified diff format.

                         git show 3ec3b2fba526ead2fa3f3d7c91924f39a0733749                           ▼ Header commit 3ec3b2fba526ead2fa3f3d7c91924f39a0733749 Author:     David Woodhouse <dwmw2@shinybook.infradead.org> AuthorDate: 2005-05-17 12:08:48 +0100 Commit:     David Woodhouse <dwmw2@shinybook.infradead.org> CommitDate: 2005-05-17 12:08:48 +0100     AUDIT: Capture sys_socketcall arguments and sockaddrs     Signed-off-by: David Woodhouse <dwmw2@infradead.org> ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔                                      include/linux/audit.h                                       ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▼  @@ 69,8 69,9 @@+2-1 #defineAUDIT_FS_WATCH        1301    /* Filesystem watch event */ #defineAUDIT_PATH        1302    /* Filname path information */ #defineAUDIT_IPC        1303    /* IPC record */ -#define AUDIT_SOCKET        1304    /* Socket record */ +#defineAUDIT_SOCKETCALL    1304    /* sys_socketcall arguments */ #defineAUDIT_CONFIG_CHANGE    1305    /* Audit system configuration change */ +#defineAUDIT_SOCKADDR        1306    /* sockaddr copied as syscall arg */ #defineAUDIT_AVC        1400    /* SE Linux avc denial or grant */ #defineAUDIT_SELINUX_ERR    1401    /* Internal SE Linux Errors */ ▼  @@ 235,6 236,8 @@+2-0extern int audit_get_stamp(struct audit_context *ctx, externintaudit_set_loginuid(struct task_struct * task uid_tloginuid); externuid_taudit_get_loginuid(struct audit_context * ctx ); externintaudit_ipc_perms(unsignedlongqbytes uid_tuidgid_tgidmode_t mode ); +externintaudit_socketcall(intnargs unsignedlong*args);▆▆ +externintaudit_sockaddr(intlen void*addr); externvoidaudit_signal_info(intsig struct  task_struct *t);  l  Lock scroll  s  Save  z  Console   x   Expand all  o  Collapse all  d  Light  h   Help   q  Quit 

How to use it?

moulti diff reads diff data then acts upon an existing Moulti instance to display them:

Terminal #1: TUI

# Launch a Moulti instance:
moulti init

Terminal #2: CLI

#  Example 1: load a diff file:
moulti diff parse /path/to/example.diff

# Example #2: get diff data from an external command through a pipe:
diff -u /etc/passwd /etc/passwd- | moulti diff parse /dev/stdin

#  Example #3: the same without a pipe:
moulti diff run -- diff -u /etc/passwd /etc/passwd-

That two-terminal process can be abridged into a single command by combining moulti diff and moulti run:

# View a diff file:
moulti run -- moulti diff parse /path/to/examples.diff

# View diff data from an external command:
moulti run -- moulti diff run -- diff -u /etc/passwd /etc/passwd-

Git

The ancestral wisdom from the previous section can be applied to Git:

# View the latest Git commit:
moulti run -- moulti diff run -- git -C /path/to/git/working/directory show

In practice, Git users can simply create a shell alias:

# Creating the alias itself:
alias moulti-git='moulti run -- moulti diff run -- git'

# Using it:
moulti-git show
moulti-git diff
moulti-git diff --cached

Encoding

By default, moulti diff reads diff data as UTF-8 text; this encoding can be changed by setting the environment variable MOULTI_DIFF_ENCODING, e.g. export MOULTI_DIFF_ENCODING=iso-8859-1.

Title

By default, moulti diff changes the title of the Moulti instance:

  • moulti diff parse <filename> sets the filename as title
  • moulti diff run <command> sets the command as title

Set the environment variable MOULTI_DIFF_NO_TITLE to any value to prevent that.

Delta integration

By default, moulti diff tries to pass diff data to delta, specifically delta --color-only. This provides:

  • language-specific syntax highlighting (e.g. C, Python, etc.);
  • within-line difference highlighting.

If this fails (e.g. because delta is not available on the system), Moulti resorts to simpler colors: red for removed lines, green for added lines.

If that attempt to run delta --color-only somehow proves undesirable, set the environment variable MOULTI_DIFF_NO_DELTA to any value to prevent it.

Generated widgets

By default, moulti diff acts like a blackbox: it reads diff data, connects to the adequate Moulti instance, adds dividers and steps, then exits. That makes it hard (albeit not impossible) to determine the number and ids of dividers and steps added by moulti diff.

If the environment variable MOULTI_DIFF_VERBOSE is set to any non-empty value, moulti diff outputs the type and id of each generated widget to stdout. Example:

$ MOULTI_DIFF_VERBOSE=y moulti diff run -- git show
step diff_352404_1
divider diff_352404_2
step diff_352404_3

That makes it possible to perform simple update/delete operations on these widgets.

What next?

Assembling a command like moulti run -- moulti diff run -- git show may seem complex but that complexity is quickly buried under a shell alias, function, or script. And the exact same story happened with moulti manpage.