gpt4 book ai didi

bash - 将 bash 函数转换为 fish 函数

转载 作者:行者123 更新时间:2023-11-29 08:50:47 25 4
gpt4 key购买 nike

<分区>

有人可以帮我把这个 bash 函数转换成 fish 吗?如果你能解释一下它们的作用就好了 "${@%%.app}”, 's//.*/g', “$@\”

bid() {
local shortname location

# combine all args as regex
# (and remove ".app" from the end if it exists due to autocomplete)
shortname=$(echo "${@%%.app}"|sed 's/ /.*/g')
# if the file is a full match in apps folder, roll with it
if [ -d "/Applications/$shortname.app" ]; then
location="/Applications/$shortname.app"
else # otherwise, start searching
location=$(mdfind -onlyin /Applications -onlyin ~/Applications -onlyin /Developer/Applications 'kMDItemKind==Application'|awk -F '/' -v re="$shortname" 'tolower($NF) ~ re {print $0}'|head -n1)
fi
# No results? Die.
[[ -z $location || $location = "" ]] && echo "$1 not found, I quit" && return
# Otherwise, find the bundleid using spotlight metadata
bundleid=$(mdls -name kMDItemCFBundleIdentifier -r "$location")
# return the result or an error message
[[ -z $bundleid || $bundleid = "" ]] && echo "Error getting bundle ID for \"$@\"" || echo "$location: $bundleid”
}

非常感谢。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com