From 9a46eb53ba9ac6d3388d172e545044fe9812ec41 Mon Sep 17 00:00:00 2001
From: Danny Ben Shitrit <db@dannyben.com>
Date: Tue, 14 May 2024 09:01:13 +0000
Subject: [PATCH 01/11] - Add support for clean multiline commands (auto-joined
 with &&)

---
 op                                            | 85 +++++++++++++------
 op.conf                                       | 34 +++++---
 test/execute_spec.sh                          |  7 +-
 test/fixtures/empty-dir/approvals/op_help     |  2 +-
 test/fixtures/empty-dir/approvals/op_version  |  2 +-
 test/fixtures/multiline/approvals/op          |  2 +-
 .../multiline/approvals/{op_who => op_concat} |  0
 test/fixtures/multiline/approvals/op_multi    |  3 +
 .../approvals/{op_w_who => op_w_concat}       |  0
 test/fixtures/multiline/approvals/op_w_multi  |  1 +
 test/fixtures/multiline/op.conf               | 18 +++-
 test/what_spec.sh                             |  7 +-
 12 files changed, 117 insertions(+), 44 deletions(-)
 rename test/fixtures/multiline/approvals/{op_who => op_concat} (100%)
 create mode 100644 test/fixtures/multiline/approvals/op_multi
 rename test/fixtures/multiline/approvals/{op_w_who => op_w_concat} (100%)
 create mode 100644 test/fixtures/multiline/approvals/op_w_multi

diff --git a/op b/op
index b4c1319..d7891e6 100755
--- a/op
+++ b/op
@@ -47,10 +47,14 @@ opcode_context() {
     fi
   }
 
+  abort() {
+    echo "$1" >&2
+    exit "${2:-1}"
+  }
+
   need_config() {
     if [[ ! -f $CONFIG_FILE ]]; then
-      echo "Cannot find config file ($CONFIG_FILE)"
-      exit 1
+      abort "Cannot find config file ($CONFIG_FILE)"
     fi
   }
 
@@ -63,28 +67,63 @@ opcode_context() {
       exit 1
     fi
 
-    exact="^${CODE}:[[:space:]]*(.+)$"
-    fuzzy="^${CODE}[^\:]*:[[:space:]]*(.+)$"
+    COMMAND=$(get_command_from_file "exact")
+    if [[ -z $COMMAND ]]; then
+      COMMAND=$(get_command_from_file "fuzzy")
+    fi
+  }
 
-    # shellcheck disable=SC2162
-    while IFS= read line || [ -n "$line" ]; do
-      if [[ $line =~ $exact ]]; then
-        COMMAND="${BASH_REMATCH[1]}"
-        break
-      fi
-    done <"$CONFIG_FILE"
+  get_command_from_file() {
+    local pattern
 
-    if [[ -n "$COMMAND" ]]; then
-      return
+    if [[ $1 == "fuzzy" ]]; then
+      pattern="^${CODE}[^:]*:[[:space:]]*(.*)$"
+    else
+      pattern="^${CODE}:[[:space:]]*(.*)$"
     fi
 
-    # shellcheck disable=SC2162
-    while IFS= read line || [ -n "$line" ]; do
-      if [[ $line =~ $fuzzy ]]; then
-        COMMAND="${BASH_REMATCH[1]}"
-        break
+    local command=""
+    local collect_command=false
+    local temp_line=""
+
+    while IFS= read -r line || [[ -n $line ]]; do
+      if [[ -n "$temp_line" ]]; then
+        trimmed_line=${line#"${line%%[![:space:]]*}"}
+        temp_line="${temp_line%\\}$trimmed_line"
+        if [[ "$line" =~ \\$ ]]; then
+          continue
+        else
+          line="$temp_line"
+          temp_line=""
+        fi
+      fi
+
+      if [[ "$line" =~ \\$ ]]; then
+        trimmed_line=${line#"${line%%[![:space:]]*}"}
+        temp_line="${temp_line%\\}$trimmed_line"
+        continue
+      fi
+
+      if $collect_command; then
+        if [[ -z "${line}" || ! "${line}" =~ ^[[:space:]]+ ]]; then
+          break
+        fi
+
+        trimmed_line="${line#"${line%%[![:space:]]*}"}"
+        command="${command:+$command && }$trimmed_line"
+      else
+        if [[ $line =~ $pattern ]]; then
+          command="${BASH_REMATCH[1]}"
+          if [[ -n $command ]]; then
+            break
+          fi
+
+          collect_command=true
+        fi
       fi
     done <"$CONFIG_FILE"
+
+    echo "$command"
   }
 
   run_command() {
@@ -97,8 +136,7 @@ opcode_context() {
         eval "$COMMAND" "$@"
       fi
     else
-      echo "Code not found: $CODE"
-      exit 1
+      abort "Code not found: $CODE"
     fi
   }
 
@@ -135,7 +173,7 @@ opcode_context() {
 
   list_codes() {
     need_config
-    regex="^([^#:]+):"
+    regex="^([a-zA-Z0-9_-]+):"
     break_regex="^[[:space:]]*private[[:space:]]*$"
 
     # shellcheck disable=SC2162
@@ -199,8 +237,7 @@ opcode_context() {
         # shellcheck disable=SC2086
         echo $COMMAND
       else
-        echo "Code not found: $CODE"
-        exit 1
+        abort "Code not found: $CODE"
       fi
 
     fi
@@ -270,7 +307,7 @@ opcode_context() {
   bold() { printf "\e[1m%b\e[0m\n" "$*"; }
 
   opcode_initialize() {
-    VERSION="0.6.5"
+    VERSION="0.7.0"
     LONG_USAGE=false
     set_config_file
     set -e
diff --git a/op.conf b/op.conf
index d01f63d..60444d3 100644
--- a/op.conf
+++ b/op.conf
@@ -1,16 +1,25 @@
-test: op approvals && op shellcheck && op shfmt
+test:
+  op approvals
+  op shellcheck
+  op shfmt
 #? Run all tests
 
 approvals: test/approve
 #? Run approval tests
 
-shellcheck: shellcheck op setup && green "PASS: shellcheck"
+shellcheck:
+  shellcheck op setup
+  green "PASS: shellcheck"
 #? Run approval tests
 
-shfmt: shfmt -ci -i 2 -d op setup && green "PASS: shfmt"
+shfmt:
+  shfmt -ci -i 2 -d op setup
+  green "PASS: shfmt"
 #? Run shfmt tests
 
-spell: codespell && green "PASS: codespell"
+spell:
+  codespell
+  green "PASS: codespell"
 #? Run spell checker
 
 man-show: op man | man -l
@@ -19,18 +28,19 @@ man-show: op man | man -l
 man-save: op man > doc/op.1
 #? Convert the markdown man page to man
 
-version: \
-  sed -i "s/$(op --version)/$1/g" op README.md doc/op.md && \
-  op man-save && \
-  git commit -am "version bump $1" && \
+version:
+  [[ -n $1 ]] || abort 'Usage: op version NEW_VERSION'
+  sed -i "s/$(op --version)/$1/g" op README.md doc/op.md
+  op man-save
+  git commit -am "version bump $1"
   git tag v$1
 #? Update version, regenerate and tag
-#? usage: op version NEW_VERSION
+#? Usage: op version NEW_VERSION
 
 private
 
-man: \
-  export DATE=$(date "+%B %Y") && \
-  export VERSION=$(op --version) && \
+man:
+  export DATE=$(date "+%B %Y")
+  export VERSION=$(op --version)
   envsubst <doc/op.md |pandoc -f markdown-smart -s --to man 
 #? Generate man to stdout after substituting template vars
diff --git a/test/execute_spec.sh b/test/execute_spec.sh
index f829675..fbb0527 100755
--- a/test/execute_spec.sh
+++ b/test/execute_spec.sh
@@ -56,7 +56,12 @@ describe "op <command>"
 
   context "with multiline config"
     cd ./fixtures/multiline
-    approve "op who"
+    approve "op multi"
+    cd ../../
+
+  context "with concatenated config"
+    cd ./fixtures/multiline
+    approve "op concat"
     cd ../../
 
   context "with a private command"
diff --git a/test/fixtures/empty-dir/approvals/op_help b/test/fixtures/empty-dir/approvals/op_help
index 0597e0a..6de3d07 100644
--- a/test/fixtures/empty-dir/approvals/op_help
+++ b/test/fixtures/empty-dir/approvals/op_help
@@ -1,4 +1,4 @@
-opcode 0.6.5 - local command shortcuts
+opcode 0.7.0 - local command shortcuts
 
 Usage:
   op CODE [ARGS]
diff --git a/test/fixtures/empty-dir/approvals/op_version b/test/fixtures/empty-dir/approvals/op_version
index ef5e445..faef31a 100644
--- a/test/fixtures/empty-dir/approvals/op_version
+++ b/test/fixtures/empty-dir/approvals/op_version
@@ -1 +1 @@
-0.6.5
+0.7.0
diff --git a/test/fixtures/multiline/approvals/op b/test/fixtures/multiline/approvals/op
index 475224e..a551ead 100644
--- a/test/fixtures/multiline/approvals/op
+++ b/test/fixtures/multiline/approvals/op
@@ -1 +1 @@
-why   who   what   
+one   multi   concat   advanced-multi   two   
diff --git a/test/fixtures/multiline/approvals/op_who b/test/fixtures/multiline/approvals/op_concat
similarity index 100%
rename from test/fixtures/multiline/approvals/op_who
rename to test/fixtures/multiline/approvals/op_concat
diff --git a/test/fixtures/multiline/approvals/op_multi b/test/fixtures/multiline/approvals/op_multi
new file mode 100644
index 0000000..4cb29ea
--- /dev/null
+++ b/test/fixtures/multiline/approvals/op_multi
@@ -0,0 +1,3 @@
+one
+two
+three
diff --git a/test/fixtures/multiline/approvals/op_w_who b/test/fixtures/multiline/approvals/op_w_concat
similarity index 100%
rename from test/fixtures/multiline/approvals/op_w_who
rename to test/fixtures/multiline/approvals/op_w_concat
diff --git a/test/fixtures/multiline/approvals/op_w_multi b/test/fixtures/multiline/approvals/op_w_multi
new file mode 100644
index 0000000..afaf0a0
--- /dev/null
+++ b/test/fixtures/multiline/approvals/op_w_multi
@@ -0,0 +1 @@
+echo one && echo two && echo three
diff --git a/test/fixtures/multiline/op.conf b/test/fixtures/multiline/op.conf
index 68be4f3..cb6259c 100644
--- a/test/fixtures/multiline/op.conf
+++ b/test/fixtures/multiline/op.conf
@@ -1,8 +1,20 @@
-why: echo why
+one: echo one
 
-who: echo who \
+# these lines will be joined with &&
+multi:
+  echo one
+  echo two
+  echo three
+
+# these lines will be joined without any glue
+concat: echo who \
   ordered \
   this \
   pizza
 
-what: echo what
\ No newline at end of file
+# this will abort unless it gets an argument
+advanced-multi:
+  [[ -n $1 ]] || abort 'Please provide an argument'
+  echo "$1"
+
+two: echo two
\ No newline at end of file
diff --git a/test/what_spec.sh b/test/what_spec.sh
index b4db687..3d5c2d6 100755
--- a/test/what_spec.sh
+++ b/test/what_spec.sh
@@ -24,7 +24,12 @@ describe "op --what"
 
   context "with a command that was defined as multiple lines"
     cd ./fixtures/multiline
-    approve "op -w who"
+    approve "op -w multi"
+    cd ../../
+
+  context "with a command that was defined as concatenated line"
+    cd ./fixtures/multiline
+    approve "op -w concat"
     cd ../../
 
   context "with a code that does not exist"

From 7f5e19bb14c94af1b32114ec57c392047b0f8c94 Mon Sep 17 00:00:00 2001
From: Danny Ben Shitrit <db@dannyben.com>
Date: Tue, 14 May 2024 09:15:14 +0000
Subject: [PATCH 02/11] update multiline docs

---
 doc/op.1  | 36 +++++++++++++++++++++++++++++++-----
 doc/op.md | 34 ++++++++++++++++++++++++++++++----
 2 files changed, 61 insertions(+), 9 deletions(-)

diff --git a/doc/op.1 b/doc/op.1
index 15ccaf9..4a0b40f 100644
--- a/doc/op.1
+++ b/doc/op.1
@@ -1,6 +1,6 @@
 .\" Automatically generated by Pandoc 3.1.9
 .\"
-.TH "op" "1" "March 2024" "Version 0.6.5" "local command shortcuts"
+.TH "op" "1" "May 2024" "Version 0.7.0" "local command shortcuts"
 .SH NAME
 \f[B]op\f[R] - local command shortcuts
 .SH SYNOPSIS
@@ -137,12 +137,38 @@ clean: rm tmp/*
 build: docker build
 .EE
 .SS Multiline Commands
-You may split your command to multiple lines by ending the line with a
-backslash, and indenting the subsequent lines by at least one space:
+In order to specify multiple commands for a single code, provide the
+commands indented with one or more spaces immediately under the command
+code:
 .IP
 .EX
-up: docker-compose build && \[rs]
-    docker-compose up web
+up:
+  docker compose build
+  docker compose up web
+.EE
+.PP
+Note that these commands will be joined together with \f[B]&&\f[R] - so
+the above will be converted to:
+.IP
+.EX
+docker compose build && docker compose up web
+.EE
+.SS Concatenated Lines
+In case you wish to split your command to multiple lines without joining
+the lines with \f[B]&&\f[R], you can add escape the newline by using
+\f[B]\[rs]\f[R] (backslash):
+.IP
+.EX
+concat: echo who \[rs]
+  ordered \[rs]
+  this \[rs]
+  pizza
+.EE
+.PP
+Using this syntax will generate this command:
+.IP
+.EX
+echo who ordered this pizza
 .EE
 .SH PARTIAL COMMAND MATCHING
 When running a command, opcode will first try to find an exact match.
diff --git a/doc/op.md b/doc/op.md
index 75da6ba..6f440f9 100644
--- a/doc/op.md
+++ b/doc/op.md
@@ -158,12 +158,38 @@ build: docker build
 
 ## Multiline Commands
 
-You may split your command to multiple lines by ending the line with a
-backslash, and indenting the subsequent lines by at least one space:
+In order to specify multiple commands for a single code, provide the commands
+indented with one or more spaces immediately under the command code:
 
 ```shell
-up: docker-compose build && \
-    docker-compose up web
+up:
+  docker compose build
+  docker compose up web
+```
+
+Note that these commands will be joined together with **&&** - so the above 
+will be converted to:
+
+```shell
+docker compose build && docker compose up web
+```
+
+## Concatenated Lines
+
+In case you wish to split your command to multiple lines without joining the 
+lines with **&&**, you can add escape the newline by using **\\** (backslash):
+
+```shell
+concat: echo who \
+  ordered \
+  this \
+  pizza
+```
+
+Using this syntax will generate this command:
+
+```shell
+echo who ordered this pizza
 ```
 
 

From c8b3205b15da7a2631bc53014d05ddd3cd5760e0 Mon Sep 17 00:00:00 2001
From: Danny Ben Shitrit <db@dannyben.com>
Date: Tue, 14 May 2024 09:30:02 +0000
Subject: [PATCH 03/11] fix usage comments with multiline

---
 README.md                                    | 34 +++++++++++++++++---
 doc/op.1                                     |  2 +-
 op                                           |  4 +--
 test/fixtures/empty-dir/approvals/op_help    |  2 +-
 test/fixtures/empty-dir/approvals/op_version |  2 +-
 test/fixtures/multiline/approvals/op_        | 13 ++++++++
 test/fixtures/multiline/approvals/op_multi   |  4 +--
 test/fixtures/multiline/approvals/op_w_multi |  2 +-
 test/fixtures/multiline/op.conf              | 10 +++---
 test/usage_comments_spec.sh                  |  5 +++
 10 files changed, 61 insertions(+), 17 deletions(-)
 create mode 100644 test/fixtures/multiline/approvals/op_

diff --git a/README.md b/README.md
index a7e710b..3193a61 100644
--- a/README.md
+++ b/README.md
@@ -158,12 +158,38 @@ pull
 
 ## Multiline Commands
 
-You may split your command to multiple lines by ending the line with a
-backslash, and indenting the subsequent lines by at least one space:
+In order to specify multiple commands for a single code, provide the commands
+indented with one or more spaces immediately under the command code:
 
 ```shell
-up: docker-compose build && \
-    docker-compose up web
+up:
+  docker compose build
+  docker compose up web
+```
+
+Note that these commands will be joined together with `&&` - so the above 
+will be converted to:
+
+```shell
+docker compose build && docker compose up web
+```
+
+## Concatenated Lines
+
+In case you wish to split your command to multiple lines without joining the 
+lines with `&&`, you can add escape the newline by using `\` (backslash):
+
+```shell
+concat: echo who \
+  ordered \
+  this \
+  pizza
+```
+
+Using this syntax will generate this command:
+
+```shell
+echo who ordered this pizza
 ```
 
 ## Private Commands
diff --git a/doc/op.1 b/doc/op.1
index 4a0b40f..6f1b22a 100644
--- a/doc/op.1
+++ b/doc/op.1
@@ -1,6 +1,6 @@
 .\" Automatically generated by Pandoc 3.1.9
 .\"
-.TH "op" "1" "May 2024" "Version 0.7.0" "local command shortcuts"
+.TH "op" "1" "May 2024" "Version 1.0.0" "local command shortcuts"
 .SH NAME
 \f[B]op\f[R] - local command shortcuts
 .SH SYNOPSIS
diff --git a/op b/op
index d7891e6..b87a9d3 100755
--- a/op
+++ b/op
@@ -189,7 +189,7 @@ opcode_context() {
 
   list_codes_extended() {
     need_config
-    regex="^([^#:]+):"
+    regex="^([a-zA-Z0-9_-]+):"
     comment_regex="^#\? ?(.*)"
     break_regex="^[[:space:]]*private[[:space:]]*$"
 
@@ -307,7 +307,7 @@ opcode_context() {
   bold() { printf "\e[1m%b\e[0m\n" "$*"; }
 
   opcode_initialize() {
-    VERSION="0.7.0"
+    VERSION="1.0.0"
     LONG_USAGE=false
     set_config_file
     set -e
diff --git a/test/fixtures/empty-dir/approvals/op_help b/test/fixtures/empty-dir/approvals/op_help
index 6de3d07..dafb8f4 100644
--- a/test/fixtures/empty-dir/approvals/op_help
+++ b/test/fixtures/empty-dir/approvals/op_help
@@ -1,4 +1,4 @@
-opcode 0.7.0 - local command shortcuts
+opcode 1.0.0 - local command shortcuts
 
 Usage:
   op CODE [ARGS]
diff --git a/test/fixtures/empty-dir/approvals/op_version b/test/fixtures/empty-dir/approvals/op_version
index faef31a..3eefcb9 100644
--- a/test/fixtures/empty-dir/approvals/op_version
+++ b/test/fixtures/empty-dir/approvals/op_version
@@ -1 +1 @@
-0.7.0
+1.0.0
diff --git a/test/fixtures/multiline/approvals/op_ b/test/fixtures/multiline/approvals/op_
new file mode 100644
index 0000000..d391df1
--- /dev/null
+++ b/test/fixtures/multiline/approvals/op_
@@ -0,0 +1,13 @@
+
+[32mone[0m
+
+[32mmulti[0m
+  these lines will be joined with &&
+
+[32mconcat[0m
+  these lines will be joined without any glue
+
+[32madvanced-multi[0m
+  this will abort unless it gets an argument
+
+[32mtwo[0m
diff --git a/test/fixtures/multiline/approvals/op_multi b/test/fixtures/multiline/approvals/op_multi
index 4cb29ea..ac3b4f5 100644
--- a/test/fixtures/multiline/approvals/op_multi
+++ b/test/fixtures/multiline/approvals/op_multi
@@ -1,3 +1,3 @@
-one
-two
+one : two
 three
+four
diff --git a/test/fixtures/multiline/approvals/op_w_multi b/test/fixtures/multiline/approvals/op_w_multi
index afaf0a0..793d015 100644
--- a/test/fixtures/multiline/approvals/op_w_multi
+++ b/test/fixtures/multiline/approvals/op_w_multi
@@ -1 +1 @@
-echo one && echo two && echo three
+echo one : two && echo three && echo four
diff --git a/test/fixtures/multiline/op.conf b/test/fixtures/multiline/op.conf
index cb6259c..f961ea1 100644
--- a/test/fixtures/multiline/op.conf
+++ b/test/fixtures/multiline/op.conf
@@ -1,20 +1,20 @@
 one: echo one
 
-# these lines will be joined with &&
 multi:
-  echo one
-  echo two
+  echo one : two
   echo three
+  echo four
+#? these lines will be joined with &&
 
-# these lines will be joined without any glue
 concat: echo who \
   ordered \
   this \
   pizza
+#? these lines will be joined without any glue
 
-# this will abort unless it gets an argument
 advanced-multi:
   [[ -n $1 ]] || abort 'Please provide an argument'
   echo "$1"
+#? this will abort unless it gets an argument
 
 two: echo two
\ No newline at end of file
diff --git a/test/usage_comments_spec.sh b/test/usage_comments_spec.sh
index 2c2f3b0..4c98188 100755
--- a/test/usage_comments_spec.sh
+++ b/test/usage_comments_spec.sh
@@ -21,3 +21,8 @@ describe "op ?"
     cd ./fixtures/one-char
     approve "op ?"
     cd ../../
+
+  context "with multiline commands"
+    cd ./fixtures/multiline
+    approve "op ?"
+    cd ../../

From c1c1a6ffa64a8500fc76a25c53340889837edc3d Mon Sep 17 00:00:00 2001
From: Danny Ben Shitrit <db@dannyben.com>
Date: Tue, 14 May 2024 09:36:37 +0000
Subject: [PATCH 04/11] version bump 1.0.0

---
 README.md | 2 +-
 op.conf   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 3193a61..2f729a3 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
 
 # Opcode - Local Command Shortcuts
 
-![Version](https://img.shields.io/badge/version-0.6.5-blue.svg)
+![Version](https://img.shields.io/badge/version-1.0.0-blue.svg)
 ![Test](https://github.com/DannyBen/opcode/workflows/Test/badge.svg)
 
 </div>
diff --git a/op.conf b/op.conf
index 60444d3..a1f9350 100644
--- a/op.conf
+++ b/op.conf
@@ -30,7 +30,7 @@ man-save: op man > doc/op.1
 
 version:
   [[ -n $1 ]] || abort 'Usage: op version NEW_VERSION'
-  sed -i "s/$(op --version)/$1/g" op README.md doc/op.md
+  sed -i "s/$(op --version)/$1/g" op README.md
   op man-save
   git commit -am "version bump $1"
   git tag v$1

From fd959fea31c4d5e0018da0841bd940244bceaf42 Mon Sep 17 00:00:00 2001
From: Danny Ben Shitrit <db@dannyben.com>
Date: Tue, 14 May 2024 09:37:17 +0000
Subject: [PATCH 05/11] changelog

---
 CHANGELOG.md | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2f49a11..ff0052e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,12 @@
-Change Log
+Changelog
 ========================================
 
+v1.0.0 - 2024-05-14
+----------------------------------------
+
+- Add support for clean multiline commands (auto-joined with &&)
+
+
 v0.6.5 - 2024-03-08
 ----------------------------------------
 

From 76f03f3bd9ce9d24069b247c6692ac6970fe6d4f Mon Sep 17 00:00:00 2001
From: Danny Ben Shitrit <db@dannyben.com>
Date: Tue, 14 May 2024 10:05:54 +0000
Subject: [PATCH 06/11] add links to changelog

---
 .envrc.example |  5 +++++
 CHANGELOG.md   | 32 ++++++++++++++++++++------------
 2 files changed, 25 insertions(+), 12 deletions(-)
 create mode 100644 .envrc.example

diff --git a/.envrc.example b/.envrc.example
new file mode 100644
index 0000000..a11fff1
--- /dev/null
+++ b/.envrc.example
@@ -0,0 +1,5 @@
+PATH_add .
+
+# for git-changelog (https://github.com/dannyben/git-changelog)
+export CHANGELOG_COMMIT_URL=https://github.com/DannyBen/opcode/commit/%h
+export CHANGELOG_COMPARE_URL=https://github.com/dannyben/opcode/compare/%s
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ff0052e..fde2ba6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,52 +4,60 @@ Changelog
 v1.0.0 - 2024-05-14
 ----------------------------------------
 
-- Add support for clean multiline commands (auto-joined with &&)
+- Add support for clean multiline commands (auto-joined with &&) [`9a46eb5`](https://github.com/DannyBen/opcode/commit/9a46eb5)
+- Compare [`v0.6.5..v1.0.0`](https://github.com/dannyben/opcode/compare/v0.6.5..v1.0.0)
 
 
 v0.6.5 - 2024-03-08
 ----------------------------------------
 
-- Add color functions for use in op.conf
+- Add color functions for use in op.conf [`926708c`](https://github.com/DannyBen/opcode/commit/926708c)
+- Compare [`v0.6.4..v0.6.5`](https://github.com/dannyben/opcode/compare/v0.6.4..v0.6.5)
 
 
 v0.6.4 - 2023-03-12
 ----------------------------------------
 
-- Fix inability to use a one character command
-- Normalize with shfmt and shellcheck
+- Fix inability to use a one character command [`07b777f`](https://github.com/DannyBen/opcode/commit/07b777f)
+- Normalize with shfmt and shellcheck [`73bbd07`](https://github.com/DannyBen/opcode/commit/73bbd07)
+- Compare [`v0.6.3..v0.6.4`](https://github.com/dannyben/opcode/compare/v0.6.3..v0.6.4)
 
 
 v0.6.3 - 2022-11-10
 ----------------------------------------
 
-- Add private commands
+- Add private commands [`bf40d7b`](https://github.com/DannyBen/opcode/commit/bf40d7b)
+- Compare [`v0.6.2..v0.6.3`](https://github.com/dannyben/opcode/compare/v0.6.2..v0.6.3)
 
 
 v0.6.2 - 2022-11-05
 ----------------------------------------
 
-- Enable bash completions for 'op -w' as well
-- Allow running 'op -w' without code to see all codes and commands
+- Enable bash completions for 'op -w' as well [`16e0aac`](https://github.com/DannyBen/opcode/commit/16e0aac)
+- Allow running 'op -w' without code to see all codes and commands [`0e6c3fd`](https://github.com/DannyBen/opcode/commit/0e6c3fd)
+- Compare [`v0.6.1..v0.6.2`](https://github.com/dannyben/opcode/compare/v0.6.1..v0.6.2)
 
 
 v0.6.1 - 2022-11-04
 ----------------------------------------
 
-- Prefer exact match over partial match commands
+- Prefer exact match over partial match commands [`b04877d`](https://github.com/DannyBen/opcode/commit/b04877d)
+- Compare [`v0.6.0..v0.6.1`](https://github.com/dannyben/opcode/compare/v0.6.0..v0.6.1)
 
 
 v0.6.0 - 2021-05-04
 ----------------------------------------
 
-- Remove bashcompinit from zsh autocompletion
-- Change autocomplete installation
+- Remove bashcompinit from zsh autocompletion [`c478257`](https://github.com/DannyBen/opcode/commit/c478257)
+- Change autocomplete installation [`f1a104d`](https://github.com/DannyBen/opcode/commit/f1a104d)
+- Compare [`v0.5.2..v0.6.0`](https://github.com/dannyben/opcode/compare/v0.5.2..v0.6.0)
 
 
 v0.5.2 - 2020-10-26
 ----------------------------------------
 
-- Change setup script to be non-interactive (for CI)
-- Update setup script to avoid installing autocomplete if there is no ~/.bashrc
+- Change setup script to be non-interactive (for CI) [`aa3b16f`](https://github.com/DannyBen/opcode/commit/aa3b16f)
+- Update setup script to avoid installing autocomplete if there is no ~/.bashrc [`e395bbc`](https://github.com/DannyBen/opcode/commit/e395bbc)
+- Compare [`v0.5.1..v0.5.2`](https://github.com/dannyben/opcode/compare/v0.5.1..v0.5.2)
 
 

From 31adf0ed84f1419bbab01a5db7a440fe52535b04 Mon Sep 17 00:00:00 2001
From: Danny Ben Shitrit <db@dannyben.com>
Date: Tue, 14 May 2024 10:08:14 +0000
Subject: [PATCH 07/11] fix mac setup test

---
 .github/workflows/test.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index c896489..4b39373 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -49,8 +49,8 @@ jobs:
     steps:
     - name: Checkout code
       uses: actions/checkout@v4
-    - name: Upgrade the outdated bash
-      run: brew install bash
+    - name: Upgrade the outdated bash and install completions
+      run: brew install bash bash-completion
     - name: Run setup
       run: ./setup
     - name: Test setup artifacts

From cbf943184f95f72c8d2fcf5adefac63a0d4b8e8c Mon Sep 17 00:00:00 2001
From: Danny Ben Shitrit <db@dannyben.com>
Date: Tue, 14 May 2024 10:15:43 +0000
Subject: [PATCH 08/11] debug

---
 .github/workflows/test.yml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 4b39373..bb65b89 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -53,6 +53,10 @@ jobs:
       run: brew install bash bash-completion
     - name: Run setup
       run: ./setup
+
+    - name: Setup tmate session
+      uses: mxschmitt/action-tmate@v2
+
     - name: Test setup artifacts
       run: test/setup_artifacts
     - name: Run uninstall

From 7ecdabaddb80a1eada3f7671c798f09fa2076d7c Mon Sep 17 00:00:00 2001
From: Danny Ben Shitrit <db@dannyben.com>
Date: Tue, 14 May 2024 10:20:10 +0000
Subject: [PATCH 09/11] - Fix completions setup for mac

---
 .github/workflows/test.yml | 4 ----
 setup                      | 2 ++
 test/setup_artifacts       | 2 ++
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index bb65b89..4b39373 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -53,10 +53,6 @@ jobs:
       run: brew install bash bash-completion
     - name: Run setup
       run: ./setup
-
-    - name: Setup tmate session
-      uses: mxschmitt/action-tmate@v2
-
     - name: Test setup artifacts
       run: test/setup_artifacts
     - name: Run uninstall
diff --git a/setup b/setup
index 3bd07cd..2d105c6 100755
--- a/setup
+++ b/setup
@@ -54,6 +54,8 @@ install_completions() {
     compdir="/usr/share/bash-completion/completions"
   elif [[ -d "/usr/local/etc/bash_completion.d" ]]; then
     compdir="/usr/local/etc/bash_completion.d"
+  elif command -v brew &> /dev/null; then
+    compdir="$(brew --prefix)/etc/bash_completion.d"
   else
     compdir=''
   fi
diff --git a/test/setup_artifacts b/test/setup_artifacts
index 3751e82..dbf0609 100755
--- a/test/setup_artifacts
+++ b/test/setup_artifacts
@@ -14,6 +14,8 @@ get_comp_dir() {
     echo "/usr/share/bash-completion/completions"
   elif [[ -d "/usr/local/etc/bash_completion.d" ]]; then
     echo "/usr/local/etc/bash_completion.d"
+  elif command -v brew &> /dev/null; then
+    echo "$(brew --prefix)/etc/bash_completion.d"
   else
     echo ''
   fi

From 6448c460429bcada55e6e1f09a25af20e4d57ddc Mon Sep 17 00:00:00 2001
From: Danny Ben Shitrit <db@dannyben.com>
Date: Tue, 14 May 2024 10:22:46 +0000
Subject: [PATCH 10/11] ensure mac bash_completion.d exists

---
 setup                | 2 +-
 test/setup_artifacts | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/setup b/setup
index 2d105c6..6c999af 100755
--- a/setup
+++ b/setup
@@ -54,7 +54,7 @@ install_completions() {
     compdir="/usr/share/bash-completion/completions"
   elif [[ -d "/usr/local/etc/bash_completion.d" ]]; then
     compdir="/usr/local/etc/bash_completion.d"
-  elif command -v brew &> /dev/null; then
+  elif command -v brew &> /dev/null && [[ -d "$(brew --prefix)/etc/bash_completion.d" ]]; then
     compdir="$(brew --prefix)/etc/bash_completion.d"
   else
     compdir=''
diff --git a/test/setup_artifacts b/test/setup_artifacts
index dbf0609..a1adbae 100755
--- a/test/setup_artifacts
+++ b/test/setup_artifacts
@@ -14,7 +14,7 @@ get_comp_dir() {
     echo "/usr/share/bash-completion/completions"
   elif [[ -d "/usr/local/etc/bash_completion.d" ]]; then
     echo "/usr/local/etc/bash_completion.d"
-  elif command -v brew &> /dev/null; then
+  elif command -v brew &> /dev/null && [[ -d "$(brew --prefix)/etc/bash_completion.d" ]]; then
     echo "$(brew --prefix)/etc/bash_completion.d"
   else
     echo ''

From d8607489cfdc41c5d0e809f19c6681d360023fea Mon Sep 17 00:00:00 2001
From: Danny Ben Shitrit <db@dannyben.com>
Date: Tue, 14 May 2024 10:24:20 +0000
Subject: [PATCH 11/11] changelog

---
 CHANGELOG.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index fde2ba6..ab08aa4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@ v1.0.0 - 2024-05-14
 ----------------------------------------
 
 - Add support for clean multiline commands (auto-joined with &&) [`9a46eb5`](https://github.com/DannyBen/opcode/commit/9a46eb5)
+- Fix completions setup for mac [`7ecdaba`](https://github.com/DannyBen/opcode/commit/7ecdaba)
 - Compare [`v0.6.5..v1.0.0`](https://github.com/dannyben/opcode/compare/v0.6.5..v1.0.0)
 
 
