-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
📺 Add zsh completions #514
base: main
Are you sure you want to change the base?
Conversation
'1:name:__mas_list_available' \ | ||
&& ret=0 | ||
;; | ||
open) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern never matches because of a previous pattern on line 17.
@@ -0,0 +1,165 @@ | |||
#! /usr/bin/env zsh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ShellCheck only supports sh/bash/dash/ksh scripts. Sorry!
Let me know if any of these reviews are an actual concern as most aren't applicable. |
} | ||
|
||
__mas_search_names() { | ||
[[ -z "$words[-1]" ]] && return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Argument to -z is always false due to literal strings.
} | ||
|
||
__mas_search_ids() { | ||
[[ -z "$words[-1]" ]] && return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Argument to -z is always false due to literal strings.
c6db308
to
63d0fe8
Compare
|
||
case "$state" in | ||
args) | ||
case $words[1] in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use braces when expanding arrays, e.g. ${array[idx]} (or ${var}[.. to quiet).
@@ -0,0 +1,166 @@ | |||
#compdef mas | |||
# shellcheck shell=zsh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shell type is unknown. Use e.g. sh or bash.
__mas_strip_price "$1" | sed -nEe 's/^[[:space:]]*([0-9\-]+)[[:space:]]*(.*)/\1:\2/pg' | ||
} | ||
|
||
__mas_strip_price() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__mas_strip_price
seems to strip version, not price.
If that's correct, should it be renamed __mas_strip_version
?
} | ||
|
||
__mas_strip_price() { | ||
echo "$1" | sed -nEe 's/[[:space:]]+\(.*\).*$//pg' | sed 's/:/\\:/g' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you amenable to replacing sed
usages here & elsewhere with native zsh expansions? It should be faster and also remove the external sed
dependency.
The following should work here:
printf $'%s\n' "${${(*@F)${(f)1}%% ##\([^(]##}//:/\\:}"
If you're OK with that, I can write the zsh for the other functions, too, if you want.
'installedNames:apps:__mas_list_installed_names' | ||
} | ||
|
||
__mas_search_ids() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the purpose of this to allow you to type part of an app name (instead of an app ID) as the argument, have mas search
search for matching app names, then allow you to autocomplete from the app name to the app ID?
If so, it's not working for me. Is it working for you? If so, what version of zsh are you using? How was it installed? What version of macOS? etc.
#222 has been open for over 5 years now (🥳 congrats). About time someone took care of it, especially as it's the default shell.
Closes #222
Please let me know of any questions/suggestions you might have.