From 61b144d809f8f8258cfd74a4bb3c6c8b66bac0b1 Mon Sep 17 00:00:00 2001 From: Benjamin Bock Date: Mon, 1 Sep 2025 20:47:54 +0200 Subject: feat(magic-enter plugin): Add support for jj to magic-enter plugin (#13241) --- plugins/magic-enter/magic-enter.plugin.zsh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'plugins/magic-enter') diff --git a/plugins/magic-enter/magic-enter.plugin.zsh b/plugins/magic-enter/magic-enter.plugin.zsh index 55b893535..c3175b70b 100644 --- a/plugins/magic-enter/magic-enter.plugin.zsh +++ b/plugins/magic-enter/magic-enter.plugin.zsh @@ -1,5 +1,6 @@ # Default commands : ${MAGIC_ENTER_GIT_COMMAND:="git status -u ."} # run when in a git repository +: ${MAGIC_ENTER_JJ_COMMAND:="jj st --no-pager ."} # run when in a jj repository : ${MAGIC_ENTER_OTHER_COMMAND:="ls -lh ."} # run anywhere else magic-enter() { @@ -9,7 +10,9 @@ magic-enter() { return fi - if command git rev-parse --is-inside-work-tree &>/dev/null; then + if command jj st &>/dev/null; then # needs to be before git to handle colocated repositories + BUFFER="$MAGIC_ENTER_JJ_COMMAND" + elif command git rev-parse --is-inside-work-tree &>/dev/null; then BUFFER="$MAGIC_ENTER_GIT_COMMAND" else BUFFER="$MAGIC_ENTER_OTHER_COMMAND" -- cgit v1.2.3-70-g09d2 From 9ad0ce6482858bd56d828fae9e19a4f32b6d3c3a Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Sat, 6 Sep 2025 12:19:49 +0800 Subject: fix(magic-enter): avoid unexpected console output Closes #13290 --- plugins/magic-enter/magic-enter.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/magic-enter') diff --git a/plugins/magic-enter/magic-enter.plugin.zsh b/plugins/magic-enter/magic-enter.plugin.zsh index c3175b70b..cfb15b60e 100644 --- a/plugins/magic-enter/magic-enter.plugin.zsh +++ b/plugins/magic-enter/magic-enter.plugin.zsh @@ -10,9 +10,9 @@ magic-enter() { return fi - if command jj st &>/dev/null; then # needs to be before git to handle colocated repositories + if command jj st >/dev/null 2>&1; then # needs to be before git to handle colocated repositories BUFFER="$MAGIC_ENTER_JJ_COMMAND" - elif command git rev-parse --is-inside-work-tree &>/dev/null; then + elif command git rev-parse --is-inside-work-tree >/dev/null 2>&1; then BUFFER="$MAGIC_ENTER_GIT_COMMAND" else BUFFER="$MAGIC_ENTER_OTHER_COMMAND" -- cgit v1.2.3-70-g09d2 From 9e23925b8581d22033f07f1983587412d3761494 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Wed, 10 Sep 2025 09:30:04 +0800 Subject: fix(magic-enter): check for cmd existance before executing Closes #13294 --- plugins/magic-enter/magic-enter.plugin.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'plugins/magic-enter') diff --git a/plugins/magic-enter/magic-enter.plugin.zsh b/plugins/magic-enter/magic-enter.plugin.zsh index cfb15b60e..722d747f3 100644 --- a/plugins/magic-enter/magic-enter.plugin.zsh +++ b/plugins/magic-enter/magic-enter.plugin.zsh @@ -10,9 +10,10 @@ magic-enter() { return fi - if command jj st >/dev/null 2>&1; then # needs to be before git to handle colocated repositories + # needs to be before git to handle colocated repositories + if (( $+commands[jj] )) && command jj st >/dev/null 2>&1; then BUFFER="$MAGIC_ENTER_JJ_COMMAND" - elif command git rev-parse --is-inside-work-tree >/dev/null 2>&1; then + elif (( $+commands[git] )) && command git rev-parse --is-inside-work-tree >/dev/null 2>&1; then BUFFER="$MAGIC_ENTER_GIT_COMMAND" else BUFFER="$MAGIC_ENTER_OTHER_COMMAND" -- cgit v1.2.3-70-g09d2