Skip to content

Commit 14512cf

Browse files
committed
+git-dsf
new file: .editorconfig new file: .github/dependabot.yml new file: .gitignore new file: .gitmodules new file: bin/diff-so-fancy new file: bin/git-dsf new file: diff-so-fancy new file: docs/README.md new file: zsh-diff-so-fancy.plugin.zsh
0 parents  commit 14512cf

File tree

9 files changed

+142
-0
lines changed

9 files changed

+142
-0
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Note: VIM users should use alternate marks [[[ and ]]] as the original ones can confuse nested substitutions, e.g.: ${${${VAR}}}
2+
# # Space or Tabs? https://stackoverflow.com/questions/35649847/objective-reasons-for-using-spaces-instead-of-tabs-for-indentation
3+
4+
root = true
5+
6+
[*]
7+
indent_style = space
8+
indent_size = 2
9+
charset = utf-8
10+
end_of_line = lf
11+
trim_trailing_whitespace = true
12+
insert_final_newline = true
13+
14+
[**.{md,rst}]
15+
trim_trailing_whitespace = false

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "gitsubmodule"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"

.gitignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
!Build/
2+
.last_cover_stats
3+
/META.yml
4+
/META.json
5+
/MYMETA.*
6+
*.o
7+
*.pm.tdy
8+
*.bs
9+
10+
# A popular plugin manager's files
11+
._zi
12+
._zinit
13+
._zplugin
14+
.zi_lastupd
15+
.zinit_lastupd
16+
.zplugin_lstupd
17+
18+
# Devel::Cover
19+
cover_db/
20+
21+
# Devel::NYTProf
22+
nytprof.out
23+
24+
# Dizt::Zilla
25+
/.build/
26+
27+
# Module::Build
28+
_build/
29+
Build
30+
Build.bat
31+
32+
# Module::Install
33+
inc/
34+
35+
# ExtUitls::MakeMaker
36+
/blib/
37+
/_eumm/
38+
/*.gz
39+
/Makefile
40+
/Makefile.old
41+
/MANIFEST.bak
42+
/pm_to_blib
43+
/*.zip

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "diff-so-fancy"]
2+
path = diff-so-fancy
3+
url = https://github.com/so-fancy/diff-so-fancy

bin/diff-so-fancy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../diff-so-fancy/diff-so-fancy

bin/git-dsf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env sh
2+
3+
# Git will search $PATH for this file, when invoked by "git dsf ...".
4+
5+
f() {
6+
[ -z "$GIT_PREFIX" ] || \
7+
cd "$GIT_PREFIX" && \
8+
git diff --color "$@" | diff-so-fancy | less --tabs=4 -iRFX
9+
}
10+
f "$@"

diff-so-fancy

Submodule diff-so-fancy added at c3205c8

docs/README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<h1> ZI + diff-so-fancy</h1>
2+
3+
# Introduction
4+
5+
The project [so-fancy/diff-so-fancy](https://github.com/so-fancy/diff-so-fancy) integration with ZI.
6+
7+
With this [ZI](https://github.com/z-shell/zi) plugin, you simply add two lines to `.zshrc`:
8+
9+
```zsh
10+
zi ice as"program" pick"bin/git-dsf"
11+
zi light z-shell/zsh-diff-so-fancy
12+
```
13+
14+
This will install `diff-so-fancy` on every account where you use Zshell, and automatically
15+
equip `git` with subcommand `dsf`. No need to use system package manager and to configure
16+
`git`. Of course, if you have the following standard line in your `.gitconfig`, it will
17+
still work normally:
18+
19+
```
20+
[core]
21+
pager = diff-so-fancy | less -FXRi
22+
```
23+
24+
(because this plugin adds `diff-so-fancy` to `$PATH`).
25+
26+
Think about Puppet or Chef, i.e. about declarative approach to system configuration.
27+
In this case `.zshrc` is like a declarative setup guarding you will have `diff-so-fancy`
28+
on your accounts.
29+
30+
# A Few Details
31+
32+
[so-fancy/diff-so-fancy](https://github.com/so-fancy/diff-so-fancy) is cloned from
33+
Github as submodule. The plugin has `bin/git-dsf` script which adds subcommand `dsf`
34+
to git. That's basically everything needed: convenient way of installing (single Zsh
35+
plugin manager invocation), updating (Zsh plugin managers can easily update) and
36+
integrating with `git`.
37+
38+
# Other plugin managers
39+
40+
```zsh
41+
# Zplug
42+
zplug "z-shell/zsh-diff-so-fancy", as:command, use:"bin/"
43+
44+
# Zgen
45+
zgen load z-shell/zsh-diff-so-fancy
46+
```
47+
48+
Without `as"program"`-like functionality the `.plugin.zsh` file picks up setup
49+
and simulates adding a command to system, so `Zgen` and other can work.

zsh-diff-so-fancy.plugin.zsh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Use as"command" (or as"program") feature of your plugin manager (like Zplug
2+
# or ZI), this file will be then ignored. If no such feature is available
3+
# in your plugin manager, load this plugin normally, this file will then set
4+
# up $PATH for "git dsf" to work. This file can be also plainly sourced.
5+
6+
# See following web page for explanation of the line "ZERO=...":
7+
# https://github.com/z-shell/zi/wiki/Zsh-Plugin-Standard
8+
9+
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
10+
local _pth="${0:h}/bin"
11+
12+
if [[ -z "${path[(r)$_pth]}" ]]; then
13+
path+=( "$_pth" )
14+
fi

0 commit comments

Comments
 (0)