Skip to content

Fix Q_… variables support #11

@1978ajot

Description

@1978ajot

q conflicts with https://github.com/harelba/q
Changing the Q_{SET,RUN,UNSET} variables works only partially. There is still a messages that says q is already a command in your \$PATH! : when invoking Q_SET command. Here's my patch:

From 6c0845fbbff8430934d0c488e0ffce4fb8cb40d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andrzej=20Jagie=C5=82o?= <[email protected]>
Date: Sat, 26 Aug 2023 18:06:05 +0200
Subject: [PATCH 1/1] fix: replace hardcoded `q` with `${Q_RUN}`

---
 q.plugin.zsh | 6 +++---
 q.sh         | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/q.plugin.zsh b/q.plugin.zsh
index 195f0c8..af24f5e 100644
--- a/q.plugin.zsh
+++ b/q.plugin.zsh
@@ -55,8 +55,8 @@ q-accept-line() {
         fi
 
         # Check if trying to set to an existing command
-        if type "q${MATCH:1}" > /dev/null; then
-            echo "\nSorry, \"q${MATCH:1}\" is already a commamessagesnd in your \$PATH! :("
+        if type "${Q_RUN}${MATCH:1}" > /dev/null; then
+            echo "\nSorry, \"${Q_RUN}${MATCH:1}\" is already a command in your \$PATH! :("
             BUFFER=""
             zle .accept-line
             return
@@ -68,7 +68,7 @@ q-accept-line() {
 
         # If called without register, show help
         if [[ $REG == "" ]]; then
-            echo "\nq - registers for zsh"
+            echo "\n${Q_RUN} - registers for zsh"
             cat << EOF
 Usage:
     ${Q_RUN}[register] [args]
diff --git a/q.sh b/q.sh
index 918871c..5e5e47b 100644
--- a/q.sh
+++ b/q.sh
@@ -54,8 +54,8 @@ preexec_invoke_exec () {
         fi
 
         # Check if trying to set to an existing command
-        if type "q${BASH_REMATCH:1}" > /dev/null 2>&1; then
-            echo "Sorry, \"q${MATCH:1}\" is already a command in your \$PATH! :("
+        if type "${Q_RUN}${BASH_REMATCH:1}" > /dev/null 2>&1; then
+            echo "Sorry, \"${Q_RUN}${MATCH:1}\" is already a command in your \$PATH! :("
             BUFFER=""
             return 1
         fi
@@ -66,7 +66,7 @@ preexec_invoke_exec () {
 
         # If called without register, show help
         if [[ $REG == "" ]]; then
-            echo "q - registers for zsh"
+            echo "${Q_RUN} - registers for zsh"
             cat << EOF
 Usage:
     $Q_RUN[register] [args]
-- 
2.34.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions