added osx plugin

This commit is contained in:
Felix Sonntag 2015-01-16 14:37:18 +01:00
parent 80ed2cf0f0
commit 98a8283511
3 changed files with 122 additions and 0 deletions

View File

@ -22,6 +22,7 @@
* __node__ Adds locally installed NodeJS `npm` binary executable modules to the path. * __node__ Adds locally installed NodeJS `npm` binary executable modules to the path.
* __percol__ Browse your fish history with [percol](https://github.com/mooz/percol). * __percol__ Browse your fish history with [percol](https://github.com/mooz/percol).
* __peco__ Browse your fish history with [peco](https://github.com/peco/peco). * __peco__ Browse your fish history with [peco](https://github.com/peco/peco).
* __osx__ - Integration with Finder and iTunes.
* __php__ Manage phphttp server. * __php__ Manage phphttp server.
* __plenv__ [plenv](https://github.com/tokuhirom/plenv) Perl binary manager integration. * __plenv__ [plenv](https://github.com/tokuhirom/plenv) Perl binary manager integration.
* __pyenv__ [Simple Python Version Management](https://github.com/yyuu/pyenv) integration. * __pyenv__ [Simple Python Version Management](https://github.com/yyuu/pyenv) integration.

View File

@ -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

104
plugins/osx/osx.load Normal file
View File

@ -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 <option>"
echo "option:"
echo \t"launch|play|pause|stop|rewind|resume|quit"
echo \t"mute|unmute\tcontrol volume set"
echo \t"next|previous\tplay next or previous track"
echo \t"shuf|shuffle [on|off|toggle]"\t"Set shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer."
echo \t"vol"\t"Set the volume, takes an argument from 0 to 100"
echo \t"help"\t"show this message and exit"
return 1
;;
end
osascript -e "tell application \"iTunes\" to $opt"
end