Skip to content

Commit

Permalink
🎉 Output delta diff results to file (#1)
Browse files Browse the repository at this point in the history
* Add deltabae.sh
* Add example.
* Wrote shebang.
  • Loading branch information
koemigg authored Jun 23, 2023
1 parent e6a5b1b commit 52bdd01
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 0 deletions.
2 changes: 2 additions & 0 deletions deltabae.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/zsh
mkdir -p ./tmp && delta ./a.txt ./b.txt --side-by-side --syntax-theme="Nord" --zero-style="#333" | ansifilter --html --encoding "utf-8" > ./tmp/diff.html
18 changes: 18 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Example Usage

This directory contains examples of how to use the deltabae.sh script in the parent directory.

## Files

- `a.txt`, `b.txt`: Text files to be compared.
- `diff.html` (to be generated): This file will be generated after running the script. It contains the side-by-side diff of `a.txt` and `b.txt` with syntax highlighting.

<!-- TODO: Change to accept arguments -->

## Steps to Run the Example

1. Navigate to the parent directory: `cd ..`
2. Run the deltabae.sh script: `bash deltabae.sh`
3. Open the generated `diff.html` file in a web browser to view the output.

The `diff.html` file should show the differences between `a.txt` and `b.txt` in a side-by-side format with syntax highlighting.
3 changes: 3 additions & 0 deletions example/a.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
hoge
fuga
piyo
3 changes: 3 additions & 0 deletions example/b.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
hoge
fugafuga
hogera
35 changes: 35 additions & 0 deletions example/tmp/diff.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
pre {
font-family:Courier New;
font-size:10pt;
}

.af_line {
color: gray;
text-decoration: none;
}

</style>
<title>Source file</title>
</head>
<body>
<pre>
<span style="color:#0000ee;">Δ ./a.txt ⟶ ./b.txt</span>
<span style="color:#0000ee;">────────────────────────────────────────────────────────────────────────────────</span>

<span style="color:#0000ee;">─────</span><span style="color:#0000ee;"></span>
<span style="color:#0000ee;"></span> <span style="color:#0000ee;">1</span>: <span style="color:#0000ee;"></span>
<span style="color:#0000ee;">─────</span><span style="color:#0000ee;"></span>
<span style="color:#0000ee;"></span><span style="color:#444444;"> 1 </span><span style="color:#0000ee;"></span><span style="color:#000000;">hoge</span> <span style="color:#0000ee;"></span><span style="color:#444444;"> 1 </span><span style="color:#0000ee;"></span><span style="color:#000000;">hoge</span>
<span style="color:#0000ee;"></span><span style="color:#870000;"> 2 </span><span style="color:#0000ee;"></span><span style="color:#dadada;background-color:#5f0000;">fuga</span><span style="background-color:#5f0000;"> </span><span style="color:#0000ee;"></span><span style="color:#008700;"> </span><span style="color:#0000ee;"></span>
<span style="color:#0000ee;"></span><span style="color:#870000;"> 3 </span><span style="color:#0000ee;"></span><span style="color:#dadada;background-color:#5f0000;">piyo</span><span style="background-color:#5f0000;"> </span><span style="color:#0000ee;"></span><span style="color:#008700;"> </span><span style="color:#0000ee;"></span>
<span style="color:#0000ee;"></span><span style="color:#870000;"> </span><span style="color:#0000ee;"></span> <span style="color:#0000ee;"></span><span style="color:#008700;"> 2 </span><span style="color:#0000ee;"></span><span style="color:#dadada;background-color:#1c1c1c;">fugafuga</span><span style="background-color:#1c1c1c;"> </span>
<span style="color:#0000ee;"></span><span style="color:#870000;"> </span><span style="color:#0000ee;"></span> <span style="color:#0000ee;"></span><span style="color:#008700;"> 3 </span><span style="color:#0000ee;"></span><span style="color:#dadada;background-color:#1c1c1c;">hogera</span><span style="background-color:#1c1c1c;"> </span>
</pre>
</body>
</html>
<!--HTML generated by ansifilter 2.20, http://www.andre-simon.de/-->

0 comments on commit 52bdd01

Please sign in to comment.