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-finishto clean up the cache after you are done.
arch-editThis 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.
arch-repackAfter 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
arch-revertUse 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
arch-mkpatchAllows 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
arch-edit-finishDeletes 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
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. |
arch-edit project_v1.tar.gz
# Inside the shell:
nano README.md # make edits
exit # exit the shell
arch-mkpatch project_v1.tar.gz | head -n 20 # view first 20 lines of diff
arch-repack --yes project_v1.tar.gz # update without confirmation
The following utilities must be installed for the scripts to work:
tarunzip / zipcpiodiffbash)tput)
```