arch-edit

arch-edit is a set of command-line utilities for convenient interactive editing of archive contents. The scripts allow you to unpack an archive into a temporary directory, make changes, roll them back, create a patch, or re-pack the archive.

Supported formats include: tar.gz, tgz, tar.bz2, tar.xz, tar.lzma, tar.7z, tar.Z, tar, 7z, zip, cpio.

Warning: All changes are made in temporary directories. Do not forget to use arch-edit-finish to clean up the cache after you are done.

How to Use

1. Start Editing: arch-edit

This is the first and main step. It unpacks the archive (or uses an existing cache) and opens a shell in the working directory.

Basic Example:

# Opens a shell in the directory with the unpacked archive contents
arch-edit myproject.tar.gz

Example with a Custom Work Directory:

# Uses /tmp/mywork as the working directory (it must be empty)
arch-edit myproject.tar.gz /tmp/mywork

Example with Command Execution:

# Unpack the archive, enter the work directory, and launch VSCode inside it
arch-edit myproject.tar.gz -c code .

Example with Disabling Recursive Search:

# If the archive structure is /a/b/c/d and each folder has only one subdirectory,
# the script will open a shell in /a/b/c/d. This flag will leave you in /a.
arch-edit --one-level deep_structure.tar.gz

If you specify a work directory and do not use the -c key, arch-edit will simply unpack the archive into your specified directory. In all other cases, arch-edit will enter the first directory whose content is not another single subdirectory (this behavior is disabled by -l) and run the command specified after -c. If no command is specified, it will launch the current shell.

Inside the working directory, you can edit, delete, or add files.

2. Update Archive: arch-repack

After you have made changes in the working directory, use this command to pack the working directory back into the original archive.

# Will prompt for confirmation before updating the archive
arch-repack myproject.tar.gz

# Will update without asking (useful for scripts)
arch-edit --yes myproject.tar.gz   # unpacking and editing
arch-repack --yes myproject.tar.gz # updating without confirmation

3. Revert Changes: arch-revert

Use this if you want to revert the working directory contents back to the state of the original archive.

# Reverts the working directory contents to the original archive state
arch-revert myproject.tar.gz

4. Create a Patch: arch-mkpatch

Allows you to see the difference between what was in the archive and the working copy.

# Prints the diff to the screen
arch-mkpatch myproject.tar.gz

# You can redirect the output to a file:
arch-mkpatch myproject.tar.gz > changes.patch

5. Finish Work: arch-edit-finish

Deletes temporary files (cache) created for this archive. Use it when you are done.

# Deletes temporary data for a specific archive
arch-edit-finish myproject.tar.gz

# Deletes temporary data for ALL archives (use with caution!)
arch-edit-finish-all

Key Options

Available options can be used with any of the commands (where applicable).

Key Description
-y, --yes Automatically answer “Yes” to all confirmations (e.g., when updating).
-n, --no-color Disable colored output.
-c, --command <CMD> Execute <CMD> instead of launching a shell. All arguments after this key are passed to the command.
-l, --one-level Do not follow directories that contain only one subdirectory.
-v, --version Show program version.
-h, --help Show help for the current command.

Full Workflow Example

  1. Unpacking and Editing:
    arch-edit project_v1.tar.gz
    # Inside the shell:
    nano README.md   # make edits
    exit             # exit the shell
    
  2. Checking Changes (Creating a Patch):
    arch-mkpatch project_v1.tar.gz | head -n 20 # view first 20 lines of diff
    
  3. Updating Archive:
    arch-repack --yes project_v1.tar.gz # update without confirmation
    
  4. Cleaning Cache: ```bash arch-edit-finish project_v1.tar.gz # delete temporary files

Requirements

The following utilities must be installed for the scripts to work: