diff options
Diffstat (limited to 'plugins/osx/osx.plugin.zsh')
-rw-r--r-- | plugins/osx/osx.plugin.zsh | 74 |
1 files changed, 67 insertions, 7 deletions
diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index a1516dcce..a1c73a184 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -1,9 +1,5 @@ -# ------------------------------------------------------------------------------ -# FILE: osx.plugin.zsh -# DESCRIPTION: oh-my-zsh plugin file. -# AUTHOR: Sorin Ionescu (sorin.ionescu@gmail.com) -# VERSION: 1.1.0 -# ------------------------------------------------------------------------------ +# Open the current directory in a Finder window +alias ofd='open_command $PWD' function _omz_osx_get_frontmost_app() { local the_app=$( @@ -46,6 +42,16 @@ EOF end tell EOF + elif [[ "$the_app" == 'iTerm2' ]]; then + osascript <<EOF + tell application "iTerm2" + tell current window + create tab with default profile + tell current session to write text "${command}" + end tell + end tell +EOF + else echo "tab: unsupported terminal app: $the_app" false @@ -73,6 +79,19 @@ function vsplit_tab() { end tell EOF + elif [[ "$the_app" == 'iTerm2' ]]; then + osascript <<EOF + tell application "iTerm2" + tell current session of first window + set newSession to (split vertically with same profile) + tell newSession + write text "${command}" + select + end tell + end tell + end tell +EOF + else echo "$0: unsupported terminal app: $the_app" >&2 false @@ -100,6 +119,19 @@ function split_tab() { end tell EOF + elif [[ "$the_app" == 'iTerm2' ]]; then + osascript <<EOF + tell application "iTerm2" + tell current session of first window + set newSession to (split horizontally with same profile) + tell newSession + write text "${command}" + select + end tell + end tell + end tell +EOF + else echo "$0: unsupported terminal app: $the_app" >&2 false @@ -143,6 +175,7 @@ function quick-look() { function man-preview() { man -t "$@" | open -f -a Preview } +compdef _man man-preview function vncviewer() { open vnc://$@ @@ -151,6 +184,7 @@ function vncviewer() { # iTunes control function function itunes() { local opt=$1 + local playlist=$2 shift case "$opt" in launch|play|pause|stop|rewind|resume|quit) @@ -167,6 +201,19 @@ function itunes() { vol) opt="set sound volume to $1" #$1 Due to the shift ;; + playlist) + # Inspired by: https://gist.github.com/nakajijapan/ac8b45371064ae98ea7f +if [[ ! -z "$playlist" ]]; then + osascript -e 'tell application "iTunes"' -e "set new_playlist to \"$playlist\" as string" -e "play playlist new_playlist" -e "end tell" 2>/dev/null; + if [[ $? -eq 0 ]]; then + opt="play" + else + opt="stop" + fi + else + opt="set allPlaylists to (get name of every playlist)" + fi + ;; playing|status) local state=`osascript -e 'tell application "iTunes" to player state as string'` if [[ "$state" = "playing" ]]; then @@ -194,7 +241,7 @@ function itunes() { case "$state" in on|off) - # Inspired by: http://stackoverflow.com/a/14675583 + # Inspired by: https://stackoverflow.com/a/14675583 osascript 1>/dev/null 2>&1 <<-EOF tell application "System Events" to perform action "AXPress" of (menu item "${state}" of menu "Shuffle" of menu item "Shuffle" of menu "Controls" of menu bar item "Controls" of menu bar 1 of application process "iTunes" ) EOF @@ -217,6 +264,7 @@ EOF echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer." echo "\tvol\tSet the volume, takes an argument from 0 to 100" echo "\tplaying|status\tShow what song is currently playing in iTunes." + echo "\tplaylist [playlist name]\t Play specific playlist" echo "\thelp\tshow this message and exit" return 0 ;; @@ -227,3 +275,15 @@ EOF esac osascript -e "tell application \"iTunes\" to $opt" } + +# Spotify control function +source ${ZSH}/plugins/osx/spotify + +# 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" + +# Remove .DS_Store files recursively in a directory, default . +function rmdsstore() { + find "${@:-.}" -type f -name .DS_Store -delete +} |