From c31b73b6fd34788e376d8681223cbbc162bc0a5b Mon Sep 17 00:00:00 2001 From: Frederic R Date: Sat, 3 Jul 2021 21:41:58 +0100 Subject: [PATCH 1/3] Functions: don't display osascript call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit useful with something like: __fish_apple_touchbar_bind_key 7 '╂ split' 'osascript -e "tell application \"System Events\" to key code 2 using command down"' '-s' --- functions/__fish_apple_touchbar_bind_key.fish | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/functions/__fish_apple_touchbar_bind_key.fish b/functions/__fish_apple_touchbar_bind_key.fish index 4ba21cb..3d13697 100644 --- a/functions/__fish_apple_touchbar_bind_key.fish +++ b/functions/__fish_apple_touchbar_bind_key.fish @@ -6,7 +6,11 @@ function __fish_apple_touchbar_bind_key --argument-names fn_number fn_text fn_co end if [ "$bind_option" = "-s" ] - bind $vimbind --key f$fn_number "commandline --replace '$fn_command'; commandline --function execute" + if string match -q -- "*osascript*" "$fn_command" + bind $vimbind --key f$fn_number "eval ($fn_command)" + else + bind $vimbind --key f$fn_number "commandline --replace '$fn_command'; commandline --function execute" + end else bind --key f$fn_number $fn_command end From a77a33f5fdfc01e280716f9f4787b050a462ac8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Berm=C3=BAdez=20Schettino?= Date: Sun, 4 Jul 2021 20:08:03 +0200 Subject: [PATCH 2/3] Functions: Use guard clauses and long-format opts Use --quiet instead of - q to improve readability. Refactor nested if-else statements using guard clauses to reduce code complexity. --- functions/__fish_apple_touchbar_bind_key.fish | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/functions/__fish_apple_touchbar_bind_key.fish b/functions/__fish_apple_touchbar_bind_key.fish index 3d13697..9260e8f 100644 --- a/functions/__fish_apple_touchbar_bind_key.fish +++ b/functions/__fish_apple_touchbar_bind_key.fish @@ -6,12 +6,13 @@ function __fish_apple_touchbar_bind_key --argument-names fn_number fn_text fn_co end if [ "$bind_option" = "-s" ] - if string match -q -- "*osascript*" "$fn_command" + if string match --quiet -- "*osascript*" "$fn_command" bind $vimbind --key f$fn_number "eval ($fn_command)" - else - bind $vimbind --key f$fn_number "commandline --replace '$fn_command'; commandline --function execute" + return end - else - bind --key f$fn_number $fn_command + + bind $vimbind --key f$fn_number "commandline --replace '$fn_command'; commandline --function execute" end + + bind --key f$fn_number $fn_command end From f66d940859c2949c815f39c13f6042a0363f8caf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Berm=C3=BAdez=20Schettino?= Date: Sun, 4 Jul 2021 20:11:11 +0200 Subject: [PATCH 3/3] Functions: Add missing return in bind key func --- functions/__fish_apple_touchbar_bind_key.fish | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/__fish_apple_touchbar_bind_key.fish b/functions/__fish_apple_touchbar_bind_key.fish index 9260e8f..af4852a 100644 --- a/functions/__fish_apple_touchbar_bind_key.fish +++ b/functions/__fish_apple_touchbar_bind_key.fish @@ -12,6 +12,7 @@ function __fish_apple_touchbar_bind_key --argument-names fn_number fn_text fn_co end bind $vimbind --key f$fn_number "commandline --replace '$fn_command'; commandline --function execute" + return end bind --key f$fn_number $fn_command