Skip to content

Commit

Permalink
Functions: don't display osascript call (#14)
Browse files Browse the repository at this point in the history
* Functions: don't display osascript call

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: 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: Add missing return in bind key func

Co-authored-by: Rodrigo Bermúdez Schettino <[email protected]>
  • Loading branch information
Frederic R and rodrigobdz authored Jul 4, 2021
1 parent ff20201 commit 25d968e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions functions/__fish_apple_touchbar_bind_key.fish
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ 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"
else
bind --key f$fn_number $fn_command
if string match --quiet -- "*osascript*" "$fn_command"
bind $vimbind --key f$fn_number "eval ($fn_command)"
return
end

bind $vimbind --key f$fn_number "commandline --replace '$fn_command'; commandline --function execute"
return
end

bind --key f$fn_number $fn_command
end

0 comments on commit 25d968e

Please sign in to comment.