From b2f35a7b98455b2bb8c7c3b11db6aa587e1d28bf Mon Sep 17 00:00:00 2001 From: Jonathan Batchelor Date: Fri, 5 Nov 2021 23:40:38 +0000 Subject: refactor(osx): Rename osx plugin to macos (#10341) Apple changed the name of their operating system from OS X to macOS a number of years ago. This was overdue! As per issue #10311 * refactor(osx): rename `osx` plugin to `macos` * refactor(macos): Add symbolic link from old `osx` plugin name. --- plugins/macos/macos.plugin.zsh | 269 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 269 insertions(+) create mode 100644 plugins/macos/macos.plugin.zsh (limited to 'plugins/macos/macos.plugin.zsh') diff --git a/plugins/macos/macos.plugin.zsh b/plugins/macos/macos.plugin.zsh new file mode 100644 index 000000000..4bcbbaead --- /dev/null +++ b/plugins/macos/macos.plugin.zsh @@ -0,0 +1,269 @@ +# Check if 'osx' is still in the plugins list and prompt to change to 'macos' +if [[ -n "${plugins[(r)osx]}" ]]; then + print ${(%):-"%F{yellow}The \`osx\` plugin is deprecated and has been renamed to \`macos\`."} + print ${(%):-"Please update your .zshrc to use the \`%Bmacos%b\` plugin instead.%f"} +fi + +# Open the current directory in a Finder window +alias ofd='open_command $PWD' + +# Show/hide hidden files in the Finder +alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder" +alias hidefiles="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder" + +# Bluetooth restart +function btrestart() { + sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport + sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport +} + +function _omz_macos_get_frontmost_app() { + osascript 2>/dev/null < 0 )) && command="${command}; $*" + + local the_app=$(_omz_macos_get_frontmost_app) + + if [[ "$the_app" == 'Terminal' ]]; then + # Discarding stdout to quash "tab N of window id XXX" output + osascript >/dev/null </dev/null <&2 + return 1 + fi +} + +function vsplit_tab() { + local command="cd \\\"$PWD\\\"; clear" + (( $# > 0 )) && command="${command}; $*" + + local the_app=$(_omz_macos_get_frontmost_app) + + if [[ "$the_app" == 'iTerm' ]]; then + osascript </dev/null <&2 + return 1 + fi +} + +function split_tab() { + local command="cd \\\"$PWD\\\"; clear" + (( $# > 0 )) && command="${command}; $*" + + local the_app=$(_omz_macos_get_frontmost_app) + + if [[ "$the_app" == 'iTerm' ]]; then + osascript 2>/dev/null </dev/null <&2 + return 1 + fi +} + +function pfd() { + osascript 2>/dev/null </dev/null </dev/null < 0 )) && qlmanage -p $* &>/dev/null & +} + +function man-preview() { + # Don't let Preview.app steal focus if the man page doesn't exist + man -w "$@" &>/dev/null && man -t "$@" | open -f -a Preview || man "$@" +} +compdef _man man-preview + +function vncviewer() { + open vnc://$@ +} + +# Remove .DS_Store files recursively in a directory, default . +function rmdsstore() { + find "${@:-.}" -type f -name .DS_Store -delete +} + +# Erases purgeable disk space with 0s on the selected disk +function freespace(){ + if [[ -z "$1" ]]; then + echo "Usage: $0 " + echo "Example: $0 /dev/disk1s1" + echo + echo "Possible disks:" + df -h | awk 'NR == 1 || /^\/dev\/disk/' + return 1 + fi + + echo "Cleaning purgeable files from disk: $1 ...." + diskutil secureErase freespace 0 $1 +} + +_freespace() { + local -a disks + disks=("${(@f)"$(df | awk '/^\/dev\/disk/{ printf $1 ":"; for (i=9; i<=NF; i++) printf $i FS; print "" }')"}") + _describe disks disks +} + +compdef _freespace freespace + +# Music / iTunes control function +source "${0:h:A}/music" + +# Spotify control function +source "${0:h:A}/spotify" -- cgit v1.2.3-70-g09d2