Skip to content

Commit 1a17232

Browse files
committed
Merge branch 'config'
* 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
2 parents fad91fe + 7c75bdb commit 1a17232

File tree

4 files changed

+35
-22
lines changed

4 files changed

+35
-22
lines changed

CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGES
22
=======
33

4+
## 1.4.0 (2023-04-15)
5+
6+
* Use config file from `XDG_CONFIG_HOME` if available.
7+
* Respect `$EDITOR` config as default editor command.
8+
49
## 1.3.2 (2022-11-10)
510

611
* For a `dos` format file, open the diff buffer with also dos fileformat.

README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ View git diff in Vim tabs.
77
- `GitDiff`, `GitDiffInfo`, `GitDiffOff` commands for Vim.
88

99

10-
Install
11-
=======
10+
## Install
1211

1312
Install like general Vim plugins.
1413

1514

16-
## Install Zsh Helper Function
15+
### Install Zsh Helper Function
1716

1817
- With [zcomet][]
1918

@@ -39,8 +38,7 @@ Install like general Vim plugins.
3938
```
4039

4140

42-
Zsh Function Usage
43-
==================
41+
## Zsh Function Usage
4442

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

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

6664

67-
Zsh Function Configuration
68-
==========================
65+
## Zsh Function Configuration
6966

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

69+
- `$XDG_CONFIG_HOME/gitdiffall/config.rb`
70+
- `$XDG_CONFIG_HOME/gitdiffall-config.rb`
7271
- `~/gitdiffall/config.rb`
7372
- `~/gitdiffall-config.rb`
7473
- `{dir_contains_gitdiffall.rb}/gitdiffall/config.rb`
7574
- `{dir_contains_gitdiffall.rb}/gitdiffall-config.rb`
7675

7776
Supported config items:
7877

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

101100

102-
Tips
103-
====
101+
## Tips
104102

105103
In tmux copy mode, select some commit hash and press `>` to do gitdiffall in
106104
new tmux window, see [tmux-in.rb][] gist.

bin/gitdiffall.rb

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,30 @@
22

33
require 'optparse'
44
require 'pathname'
5-
Version = '1.3.2'
6-
7-
config_path = [
8-
'~/gitdiffall/config.rb',
9-
'~/gitdiffall-config.rb',
10-
(File.dirname(__FILE__) + '/gitdiffall/config.rb'),
11-
(File.dirname(__FILE__) + '/gitdiffall-config.rb')
12-
].find {|path|
5+
Version = '1.4.0'
6+
7+
8+
cfg_files = %w[
9+
gitdiffall/config.rb
10+
gitdiffall-config.rb
11+
]
12+
cfg_dirs = [
13+
ENV['XDG_CONFIG_HOME'],
14+
ENV['HOME'],
15+
File.dirname(__FILE__)
16+
].reject(&:nil?)
17+
cfg_paths = cfg_dirs.flat_map do |dir|
18+
cfg_files.map { |file| "#{dir}/#{file}" }
19+
end
20+
21+
cfg_path = cfg_paths.find do |path|
1322
File.exist?(File.expand_path(path))
14-
}
15-
require config_path if config_path
23+
end
24+
require cfg_path if cfg_path
25+
1626

1727
config = ({
18-
:editor_cmd => 'vim',
28+
:editor_cmd => ENV['EDITOR'] || 'vim',
1929
:max_files => 14,
2030
:min_hash_abbr => 5,
2131
:ignore_pattern => /\.(png|jpg)\Z/i

doc/gitdiffall.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
*gitdiffall.txt* View git diff in Vim tabs
22

3-
Version: 1.3.2
3+
Version: 1.4.0
44
Author: bootleq <[email protected]>
55
License: Public Domain
66
Repository: https://github.com/bootleq/vim-gitdiffall

0 commit comments

Comments
 (0)