diff --git a/modules/osx/README.md b/modules/osx/README.md index d8eff0ff..beee632e 100644 --- a/modules/osx/README.md +++ b/modules/osx/README.md @@ -23,6 +23,8 @@ Functions - `osx-rm-dir-metadata` deletes .DS\_Store, \_\_MACOSX cruft. - `osx-ls-download-history` displays the Mac OS X download history. - `osx-rm-download-history` deletes the Mac OS X download history. + - `wherefrom` sets the Mac OS X download location for a file. + - `settings` changes the terminal settings for the current window. Authors ------- diff --git a/modules/osx/functions/_settings b/modules/osx/functions/_settings new file mode 100644 index 00000000..97b1f1e5 --- /dev/null +++ b/modules/osx/functions/_settings @@ -0,0 +1,10 @@ +#compdef settings + +_known_settings=$(osascript 2>/dev/null </dev/null <&2 </dev/null </dev/null < 0 )) && command="${command}; $*" -the_app=$( +local the_app=$( osascript 2>/dev/null <&2 < [file ...] +EOF +return 1 +fi + +url=$1 +shift + +while (( $# > 0 )); do + if [[ -f "$1" ]]; then + # A json plist containing the Downloaded from URL + local plist='["'"$url"'"]' + + # Convert to a hexdump representation of a binary plist + # In xxd set the max column count to avoid line breaks + local binplist=`echo -n "$plist" | plutil -convert binary1 -o - - | xxd -p -c 256` + + xattr -wx 'com.apple.metadata:kMDItemWhereFroms' "$binplist" "$1" + + else + print "$0: cannot read: $1" >&2 + success=1 + fi + shift +done