Skip to content

Commit

Permalink
Merge branch 'config'
Browse files Browse the repository at this point in the history
* config:
  Adjust README headings to avoid duplicate H1
  Version 1.4.0
  Take config file from XDG_CONFIG_HOME if has set
  Default `editor_cmd` to $EDITOR if available
  • Loading branch information
bootleq committed Apr 15, 2023
2 parents fad91fe + 7c75bdb commit 1a17232
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 22 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGES
=======

## 1.4.0 (2023-04-15)

* Use config file from `XDG_CONFIG_HOME` if available.
* Respect `$EDITOR` config as default editor command.

## 1.3.2 (2022-11-10)

* For a `dos` format file, open the diff buffer with also dos fileformat.
Expand Down
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ View git diff in Vim tabs.
- `GitDiff`, `GitDiffInfo`, `GitDiffOff` commands for Vim.


Install
=======
## Install

Install like general Vim plugins.


## Install Zsh Helper Function
### Install Zsh Helper Function

- With [zcomet][]

Expand All @@ -39,8 +38,7 @@ Install like general Vim plugins.
```


Zsh Function Usage
==================
## Zsh Function Usage

In zsh, use `gitdiffall` to open git diff in Vim tabs, examples:

Expand All @@ -64,19 +62,20 @@ For convenience, some special notations are available:
During merge conflicts, `gitdiffall` will open a 3-way diff in Vim.


Zsh Function Configuration
==========================
## Zsh Function Configuration

gitdiffall.rb takes configure file from one of the following:

- `$XDG_CONFIG_HOME/gitdiffall/config.rb`
- `$XDG_CONFIG_HOME/gitdiffall-config.rb`
- `~/gitdiffall/config.rb`
- `~/gitdiffall-config.rb`
- `{dir_contains_gitdiffall.rb}/gitdiffall/config.rb`
- `{dir_contains_gitdiffall.rb}/gitdiffall-config.rb`

Supported config items:

- `editor_cmd` (default: "vim")
- `editor_cmd` (default: respect `$EDITOR`, or "vim")
Command to execute Vim.
- `max_files` (default: 14)
Wait for confirmation before open such many files.
Expand All @@ -99,8 +98,7 @@ CONFIG = {
```


Tips
====
## Tips

In tmux copy mode, select some commit hash and press `>` to do gitdiffall in
new tmux window, see [tmux-in.rb][] gist.
Expand Down
32 changes: 21 additions & 11 deletions bin/gitdiffall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,30 @@

require 'optparse'
require 'pathname'
Version = '1.3.2'

config_path = [
'~/gitdiffall/config.rb',
'~/gitdiffall-config.rb',
(File.dirname(__FILE__) + '/gitdiffall/config.rb'),
(File.dirname(__FILE__) + '/gitdiffall-config.rb')
].find {|path|
Version = '1.4.0'


cfg_files = %w[
gitdiffall/config.rb
gitdiffall-config.rb
]
cfg_dirs = [
ENV['XDG_CONFIG_HOME'],
ENV['HOME'],
File.dirname(__FILE__)
].reject(&:nil?)
cfg_paths = cfg_dirs.flat_map do |dir|
cfg_files.map { |file| "#{dir}/#{file}" }
end

cfg_path = cfg_paths.find do |path|
File.exist?(File.expand_path(path))
}
require config_path if config_path
end
require cfg_path if cfg_path


config = ({
:editor_cmd => 'vim',
:editor_cmd => ENV['EDITOR'] || 'vim',
:max_files => 14,
:min_hash_abbr => 5,
:ignore_pattern => /\.(png|jpg)\Z/i
Expand Down
2 changes: 1 addition & 1 deletion doc/gitdiffall.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
*gitdiffall.txt* View git diff in Vim tabs

Version: 1.3.2
Version: 1.4.0
Author: bootleq <[email protected]>
License: Public Domain
Repository: https://github.com/bootleq/vim-gitdiffall
Expand Down

0 comments on commit 1a17232

Please sign in to comment.