From 98a828351180f096a9a14e22b41cbeab850c1b2a Mon Sep 17 00:00:00 2001 From: Felix Sonntag Date: Fri, 16 Jan 2015 14:37:18 +0100 Subject: [PATCH 1/3] added osx plugin --- plugins/README.markdown | 1 + plugins/osx/OSX-README.markdown | 17 ++++++ plugins/osx/osx.load | 104 ++++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 plugins/osx/OSX-README.markdown create mode 100644 plugins/osx/osx.load diff --git a/plugins/README.markdown b/plugins/README.markdown index b815c98..ba89093 100644 --- a/plugins/README.markdown +++ b/plugins/README.markdown @@ -22,6 +22,7 @@ * __node__ – Adds locally installed NodeJS `npm` binary executable modules to the path. * __percol__ – Browse your fish history with [percol](https://github.com/mooz/percol). * __peco__ – Browse your fish history with [peco](https://github.com/peco/peco). +* __osx__ - Integration with Finder and iTunes. * __php__ – Manage phphttp server. * __plenv__ – [plenv](https://github.com/tokuhirom/plenv) Perl binary manager integration. * __pyenv__ – [Simple Python Version Management](https://github.com/yyuu/pyenv) integration. diff --git a/plugins/osx/OSX-README.markdown b/plugins/osx/OSX-README.markdown new file mode 100644 index 0000000..172661e --- /dev/null +++ b/plugins/osx/OSX-README.markdown @@ -0,0 +1,17 @@ +osx +--- + +**Maintainer:** [cykeb](https://github.com/CYKEB) + +Inspired by the oh-my-zsh plugin by [sorin-ionescu](https://github.com/sorin-ionescu) +https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/osx/osx.plugin.zsh + +- `tab` - open the current directory in a new tab +- `pfd` - return the path of the frontmost Finder window +- `pfs` - return the current Finder selection +- `cdf` - cd to the current Finder directory +- `pushdf` - pushd to the current Finder directory +- `ql` - Quick Look a specified file +- `manp` - open a specified man page in Preview +- `trash` - move a specified file to the Trash +- `itunes` - play, pause etc. iTunes diff --git a/plugins/osx/osx.load b/plugins/osx/osx.load new file mode 100644 index 0000000..79b9292 --- /dev/null +++ b/plugins/osx/osx.load @@ -0,0 +1,104 @@ +# ------------------------------------------------------------------------------ +# FILE: osx.fish +# DESCRIPTION: oh-my-fish plugin file. +# AUTHOR: Felix Sonntag +# VERSION: 1.0 +# COMMENT: Inspired by the oh-my-zsh plugin by Sorin Ionescu (sorin.ionescu@gmail.com) +# https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/osx/osx.plugin.zsh +# ------------------------------------------------------------------------------ + + +function tab + osascript 2>/dev/null -e ' + tell application "System Events" + tell process "Terminal" to keystroke "t" using command down + end tell' +end + +function pfd + osascript 2>/dev/null -e ' + tell application "Finder" + return POSIX path of (target of window 1 as alias) + end tell' +end + +function cdf + cd (pfd) +end + +function pushdf + pushd (pfd) +end + +function ql + if count $argv > 0 + qlmanage >/dev/null ^/dev/null -p Applications/ & + end +end + +function manp + man -t $argv | open -f -a Preview +end + +function trash + set -l trash_dir "$HOME/.Trash" + for item in $argv + if test -e $item + set -l item_name (basename $item) + if test -e "$trash_dir/$item_name" + set -l currentTime (date "+%H.%M.%S") + mv -f "$item" "$trash_dir/$item_name $currentTime" + else + mv -f "$item" "$trash_dir/" + end + end + end +end + +function pfs + osascript 2>/dev/null -e ' + set output to "" + tell application "Finder" to set the_selection to selection + set item_count to count the_selection + repeat with item_index from 1 to count the_selection + if item_index is less than item_count then set the_delimiter to "\n" + if item_index is item_count then set the_delimiter to "" + set output to output & ((item item_index of the_selection as alias)\'s POSIX path) & the_delimiter + end repeat' +end + + +function itunes + set -l opt $argv[1] + switch $opt + case launch play pause stop rewind resume quit + ;; + case mute + set opt "set mute to true" + ;; + case unmute + set opt "set mute to false" + ;; + case next previous + set opt "$opt track" + ;; + case vol volume + set opt "set sound volume to $argv[2]" + ;; + case "" -h --help + return 0 + ;; + case '*' + echo "Usage: itunes