title: Convert bash function to fish's
body: <p>Can someone help me convert this bash function to fish? It would also be nice if you could explain what these do like <code>"${@%%.app}”</code>, <code>'s/ /.*/g’</code>, <code>"$@\”</code> etc.</p>
  
  <pre><code>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 = "" ]] &amp;&amp; echo "$1 not found, I quit" &amp;&amp; return
      # Otherwise, find the bundleid using spotlight metadata
      bundleid=$(mdls -name kMDItemCFBundleIdentifier -r "$location")
      # return the result or an error message
      [[ -z $bundleid || $bundleid = "" ]] &amp;&amp; echo "Error getting bundle ID for \"$@\"" || echo "$location: $bundleid”
  }
  </code></pre>
  
  <p>Thanks very much in advance.</p>