mirror of
https://github.com/oh-my-fish/oh-my-fish
synced 2024-11-03 15:40:32 +00:00
osx plugin: added descriptions, split up files, minor changes
This commit is contained in:
parent
98a8283511
commit
d4acc8148a
@ -6,12 +6,12 @@ osx
|
|||||||
Inspired by the oh-my-zsh plugin by [sorin-ionescu](https://github.com/sorin-ionescu)
|
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
|
https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/osx/osx.plugin.zsh
|
||||||
|
|
||||||
- `tab` - open the current directory in a new tab
|
- `tab` - Open the current directory in a new tab
|
||||||
- `pfd` - return the path of the frontmost Finder window
|
- `pfd` - Return the path of the frontmost Finder window
|
||||||
- `pfs` - return the current Finder selection
|
- `pfs` - Return the current Finder selection
|
||||||
- `cdf` - cd to the current Finder directory
|
- `cdf` - cd to the current Finder directory
|
||||||
- `pushdf` - pushd to the current Finder directory
|
- `pushdf` - pushd to the current Finder directory
|
||||||
- `ql` - Quick Look a specified file
|
- `ql` - Quick Look a specified file
|
||||||
- `manp` - open a specified man page in Preview
|
- `manp` - Open a specified man page in Preview
|
||||||
- `trash` - move a specified file to the Trash
|
- `trash` - Move a specified file to the Trash
|
||||||
- `itunes` - play, pause etc. iTunes
|
- `itunes` - Play, pause etc. iTunes
|
||||||
|
12
plugins/osx/cdf.fish
Normal file
12
plugins/osx/cdf.fish
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# cd to the current Finder directory
|
||||||
|
|
||||||
|
function cdf
|
||||||
|
if count $argv >/dev/null
|
||||||
|
switch $argv[1]
|
||||||
|
case -d --description
|
||||||
|
echo "cd to the current Finder directory"
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
cd (pfd)
|
||||||
|
end
|
36
plugins/osx/itunes.fish
Normal file
36
plugins/osx/itunes.fish
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# Play, pause etc. iTunes
|
||||||
|
|
||||||
|
function itunes
|
||||||
|
if count $argv >/dev/null
|
||||||
|
set -l opt $argv[1]
|
||||||
|
switch $opt
|
||||||
|
case -d --description
|
||||||
|
echo "Play, pause etc. iTunes. Use -h or --help for a more detailed description."
|
||||||
|
return 0
|
||||||
|
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
|
||||||
|
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"vol"\t"Set the volume, takes an argument from 0 to 100"
|
||||||
|
echo \t"help"\t"show this message and exit"
|
||||||
|
return 0
|
||||||
|
case '*'
|
||||||
|
echo "Unknown option $opt. Use -h or --help for a more detailed description."
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
osascript -e "tell application \"iTunes\" to $opt"
|
||||||
|
else
|
||||||
|
echo "Arguments expected. Use -h or --help for a more detailed description."
|
||||||
|
end
|
||||||
|
end
|
12
plugins/osx/manp.fish
Normal file
12
plugins/osx/manp.fish
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Open a specified man page in Preview
|
||||||
|
|
||||||
|
function manp
|
||||||
|
if count $argv >/dev/null
|
||||||
|
switch $argv[1]
|
||||||
|
case -d --description
|
||||||
|
echo "Open a specified man page in Preview"
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
man -t $argv | open -f -a Preview
|
||||||
|
end
|
@ -1,104 +0,0 @@
|
|||||||
# ------------------------------------------------------------------------------
|
|
||||||
# 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
|
|
15
plugins/osx/pfd.fish
Normal file
15
plugins/osx/pfd.fish
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# Return the path of the frontmost Finder window
|
||||||
|
|
||||||
|
function pfd
|
||||||
|
if count $argv >/dev/null
|
||||||
|
switch $argv[1]
|
||||||
|
case -d --description
|
||||||
|
echo "Return the path of the frontmost Finder window"
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
osascript 2>/dev/null -e '
|
||||||
|
tell application "Finder"
|
||||||
|
return POSIX path of (target of window 1 as alias)
|
||||||
|
end tell'
|
||||||
|
end
|
20
plugins/osx/pfs.fish
Normal file
20
plugins/osx/pfs.fish
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Return the path of the frontmost Finder window
|
||||||
|
|
||||||
|
function pfs
|
||||||
|
if count $argv >/dev/null
|
||||||
|
switch $argv[1]
|
||||||
|
case -d --description
|
||||||
|
echo "Return the path of the frontmost Finder window"
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
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
|
12
plugins/osx/pushdf.fish
Normal file
12
plugins/osx/pushdf.fish
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# pushd to the current Finder directory
|
||||||
|
|
||||||
|
function pushdf
|
||||||
|
if count $argv >/dev/null
|
||||||
|
switch $argv[1]
|
||||||
|
case -d --description
|
||||||
|
echo "pushd to the current Finder directory"
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
pushd (pfd)
|
||||||
|
end
|
14
plugins/osx/ql.fish
Normal file
14
plugins/osx/ql.fish
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# Quick Look a specified file
|
||||||
|
|
||||||
|
function ql
|
||||||
|
if count $argv >/dev/null
|
||||||
|
switch $argv[1]
|
||||||
|
case -d --description
|
||||||
|
echo "Quick Look a specified file"
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if count $argv > 0
|
||||||
|
qlmanage >/dev/null ^/dev/null -p Applications/ &
|
||||||
|
end
|
||||||
|
end
|
14
plugins/osx/tab.fish
Normal file
14
plugins/osx/tab.fish
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# Open the current directory in a new tab
|
||||||
|
function tab
|
||||||
|
if count $argv >/dev/null
|
||||||
|
switch $argv[1]
|
||||||
|
case -d --description
|
||||||
|
echo "Open the current directory in a new tab"
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
osascript 2>/dev/null -e '
|
||||||
|
tell application "System Events"
|
||||||
|
tell process "Terminal" to keystroke "t" using command down
|
||||||
|
end tell'
|
||||||
|
end
|
23
plugins/osx/trash.fish
Normal file
23
plugins/osx/trash.fish
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Move a specified file to the Trash
|
||||||
|
|
||||||
|
function trash
|
||||||
|
if count $argv >/dev/null
|
||||||
|
switch $argv[1]
|
||||||
|
case -d --description
|
||||||
|
echo "Move a specified file to the Trash"
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
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 current_time (date "+%H.%M.%S")
|
||||||
|
mv -f "$item" "$trash_dir/$item_name $current_time"
|
||||||
|
else
|
||||||
|
mv -f "$item" "$trash_dir/"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user