An open API service indexing awesome lists of open source software.

https://github.com/chmouel/consult-vc-modified-files

List git modified files in a project with vc
https://github.com/chmouel/consult-vc-modified-files

consult emacs emacs-lisp emacs-mode git

Last synced: 4 months ago
JSON representation

List git modified files in a project with vc

Awesome Lists containing this project

README

          

[![MELPA](https://stable.melpa.org/packages/consult-vc-modified-files-badge.svg)](https://stable.melpa.org/#/consult-vc-modified-files)

# ๐Ÿ” consult-vc-modified-files

`consult-vc-modified-files` provides a easy way to list Git-tracked files that have been modified, newly added, or are part of the HEAD commit in a project.

It integrates with Emacs' built-in [vc](https://www.gnu.org/software/emacs/manual/html_node/emacs/Version-Control.html) and
[diff-mode](https://github.com/emacs-mirror/emacs/blob/master/lisp/vc/diff-mode.el) libraries,
as well as the [consult](https://github.com/minad/consult) package for navigation.

## โœจ Features

- ๐Ÿ“„ View **locally modified** files in the current Git project
- ๐Ÿ“ฆ List files from the HEAD commit
- ๐Ÿ†• List newly added (untracked) files separately
- ๐Ÿ“‹ Show files **staged for commit** in the Git staging area
- ๏ฟฝ๏ธ Select and explore files from **any past commit** with diff previews
- ๏ฟฝ๐Ÿ› ๏ธ Customize sources for specific use cases
- ๐Ÿงญ Navigate the open files with `consult`
- ๐Ÿ‘๏ธ Preview the diff or the commit for the current selection
- ๐Ÿ”„ Smart preview window management (no more duplicate preview windows!)
- ๐Ÿ” Show the commit message of the modified files in HEAD
- ๐Ÿงต Narrow to the right type of files with the `consult-narrow-key` (`>` by
default):
- `h` for modified in HEAD
- `a` added (untracked) files
- `l` modified locally
- `c` staged for commit.

> [!CAUTION]
> This only works with Git repositories and no other version control systems.

## ๐Ÿ“ธ Screenshot

![screenshot-consult-vc-modified-files](https://github.com/user-attachments/assets/6de35d17-4598-4727-a7b2-07dde993f002)

### Preview with git show the HEAD files and git diff the modified files

### Browse modified files of a commit with `consult-vc-log-select-files`

## ๐Ÿ“ฅ Installation

### Using `use-package` and [MELPA](https://melpa.org/)

```elisp
(use-package consult-vc-modified-files
:bind
;; choose any other key bindings you prefer
(("C-x v /" . consult-vc-modified-files)
("C-x v ." . consult-vc-log-select-files)))
```

## ๐Ÿš€ Usage

### Browsing Modified Files

Call the interactive function `consult-vc-modified-files`, or use a key binding
like `C-x v /` (if configured with the configuration above).

When invoked, the command show a prompt for selecting files based on customizable sources:

- ๐Ÿ”„ **Modified locally**: Lists locally modified or untracked files
- ๐Ÿ†• **Added files**: Lists new untracked files
- ๐Ÿ“‹ **Staged for commit**: Lists files added to the Git staging area
- ๐Ÿ“ฆ **Modified in HEAD**: Lists files modified in the HEAD commit

### Browsing Files from a Specific Commit

Call the interactive function `consult-vc-log-select-files` to:

1. Select a commit from the repository history
2. Choose a file that was modified in that commit
3. See a live diff preview of the changes made to that file in the commit

This is useful for reviewing changes from past commits without having to use a separate git tool.

You can customize the available sources using the
`consult-vc-modified-files-sources` variable.

## ๐Ÿ”ฎ Preview Features

- ๐Ÿ“Š **Live diff preview**: See the changes in each file as you navigate through options
- ๐Ÿง  **Commit diff preview**: View exact changes made to files in any historical commit
- ๐ŸŒˆ **Syntax highlighting**: Previews use diff-mode

## โš™๏ธ Customization

### Configure Sources

You can customize which file categories appear in the selection when using
`consult-vc-modified-files` by setting the `consult-vc-modified-files-sources`
variable. This allows you to control exactly which types of files are presented
in the interface.

For example, if you want to show all modified files *except* those modified in
branch heads:

```elisp
(setq consult-vc-modified-files-sources
'(consult-vc-modified-files-source-modified-files
consult-vc-modified-files-source-added-files
consult-vc-modified-files-source-staged-files))
```

This configuration includes:

- Modified files (tracked files with changes)
- Added files (new untracked files)
- Staged files (changes ready for commit)

But it excludes files modified in branch heads.

### Display Git Commit Messages when showing the HEAD files

You can control whether to show commit message descriptions for files modified
in HEAD with the `consult-vc-modified-files-show-description` customization
option:

```elisp
(setq consult-vc-modified-files-show-description t) ;; Show descriptions (default is nil)
```

When enabled, this option displays the commit message next to each file modified
in the HEAD commit, providing more context about the changes.

- When `t`: Shows commit message descriptions for HEAD files
- When `nil`: Shows only the filenames without descriptions

### Customize Faces

Adjust the appearance of listed files by customizing:

- ๐ŸŽจ `consult-vc-modified-files-face`: For locally modified files
- ๐ŸŽญ `consult-vc-modified-head-files-face`: For files modified in HEAD
- ๐Ÿšฉ `consult-vc-modified-files-added-face`: For new (untracked) files
- ๐Ÿ“‹ `consult-vc-modified-files-staged-face`: For files staged for commit

## ๐Ÿ‘ฅ Authors

### Chmouel Boudjnah

- ๐Ÿ˜ **Fediverse**: [@chmouel@chmouel.com](https://fosstodon.org/@chmouel) (preferred)
- ๐Ÿฆ **Twitter**: [@chmouel](https://twitter.com/chmouel)
- ๐Ÿ“ **Blog**: [https://blog.chmouel.com](https://blog.chmouel.com)

## ๐Ÿ“ƒ License

This project is licensed under the [GPL-3.0](./LICENSE).